feature(algo): add randomforest algorithm to the comparison

This commit is contained in:
2026-05-01 14:32:22 +02:00
parent ab483da421
commit d8898598ba
2 changed files with 37 additions and 0 deletions
@@ -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)