text_plain_output_1.png image_output_1.png
from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import confusion_matrix,precision_score,recall_score,f1_score,accuracy_score

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

data = pd.read_csv('/kaggle/input/adult-census-income/adult.csv')

def performance(y_test, pred, model_name):
    precision = precision_score(y_test, pred, pos_label='<=50K')
    recall = recall_score(y_test, pred, pos_label='<=50K')
    F1 = f1_score(y_test, pred, pos_label='<=50K')
    CM = confusion_matrix(y_test, pred)
    accuracy = accuracy_score(y_test, pred)

rf = RandomForestClassifier()
rf.fit(x_train, y_train)
pred_rf = rf.predict(x_test)
performance(y_test, pred_rf, 'rf')