feature(algo): add randomforest algorithm to the comparison
This commit is contained in:
@@ -15,6 +15,7 @@ from sklearn.model_selection import train_test_split
|
||||
from sklearn.tree import DecisionTreeClassifier
|
||||
from sklearn.naive_bayes import GaussianNB
|
||||
from sklearn.cluster import KMeans
|
||||
from sklearn.ensemble import RandomForestClassifier
|
||||
from sklearn.metrics import accuracy_score, classification_report, adjusted_rand_score
|
||||
|
||||
import numpy as np
|
||||
@@ -64,6 +65,7 @@ def evaluate(name, dataset, target_names):
|
||||
for classifier_name, classifier in [
|
||||
("Decision Tree", DecisionTreeClassifier(random_state=42)),
|
||||
("Naive Bayes", GaussianNB()),
|
||||
("Random Forest", RandomForestClassifier(n_estimators=100, random_state=42)),
|
||||
]:
|
||||
classifier.fit(X_train, y_train)
|
||||
y_pred = classifier.predict(X_test)
|
||||
|
||||
Reference in New Issue
Block a user