Add Random Forest classifier simulator #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Testing
from models.random_forest import train_random_forest, evaluate_random_forest
from utils.data_helpers import generate_sample_classification
from sklearn.model_selection import train_test_split
X, y = generate_sample_classification(n_samples=300, n_features=6, n_informative=4, n_redundant=1, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, stratify=y, random_state=42)
model = train_random_forest(X_train, y_train, n_estimators=100, max_depth=None, criterion='gini', random_state=42)
y_pred, y_proba, metrics = evaluate_random_forest(model, X_test, y_test)
print('Metrics:', metrics)
print('Proba available:', y_proba is not None)
PY
Closes #58.