Reputation: 922
I'm using RandomForestClassifier to categorize my data into 2 types -- 0 or 1. Currently I am using the below code and get the overall score of all of the testing data. What I'd like to do is get the seperate scores for type 0 data and type 1 data. Any help appreciated!
X = features_enc
Y = np.asarray(df[target_column])
x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=0.33, random_state=42)
random.seed(100)
rf = RandomForestClassifier(n_estimators=100)
rf.fit(x_train, y_train)
score = rf.score(x_test, y_test)
print(score)
Upvotes: 1
Views: 149
Reputation: 776
You can import the following from sklearn:
from sklearn.metrics import classification_report
This will provide you with all possible scores:
# --snip--
predicted = rf.predict(x_test)
print(classification_report(y_test, predicted))
This should print a nicely formatted evaluation. See docs for further info
Upvotes: 3