Untitled
unknown
python
3 years ago
594 B
5
Indexable
from sklearn.ensemble import RandomForestClassifier X = training_data.drop(['diabetes_mellitus'], axis=1) y = training_data['diabetes_mellitus'] model = RandomForestClassifier(n_estimators=100, max_depth=5, min_samples_split=20, max_features='sqrt', max_samples=0.005) model.fit(X, y) #from sklearn.metrics import accuracy_score, confusion_matrix, precision_score, recall_score, f1_score def score(m, x_train, y_train, x_test, y_test, train=True): pred=m.predict(x_test) print(f"F1 score: {f1_score(y_test, pred)*100:.2f}%") score(model, X, y, x_validation, y_validation, train=False)
Editor is loading...