Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oob score changes test accuracy #343

Open
rflperry opened this issue Feb 7, 2020 · 0 comments
Open

oob score changes test accuracy #343

rflperry opened this issue Feb 7, 2020 · 0 comments
Labels

Comments

@rflperry
Copy link
Member

rflperry commented Feb 7, 2020

When oob=True, the classification accuracy doesn't match oob=False and also shows variability even with a set seed.

from rerf.rerfClassifier import rerfClassifier

# Import scikit-learn dataset library
from sklearn import datasets
# Load dataset
iris = datasets.load_iris()
import pandas as pd
from sklearn.model_selection import train_test_split
X = data[["sepal length", "sepal width", "petal length", "petal width"]]  # Features
y = data["species"]  # Labels
# Split dataset into training set and test set
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.3
)  # 70% training and 30% test
clf1 = rerfClassifier(n_estimators=10, oob_score=False, random_state=2)
clf2 = rerfClassifier(n_estimators=10, oob_score=True, random_state=2)
clf1.fit(X_train, y_train)
clf2.fit(X_train, y_train)
rerfClassifier(feature_combinations=1.5, image_height=None, image_width=None,
               max_depth=None, max_features='auto', min_samples_split=1,
               n_estimators=10, n_jobs=None, oob_score=True,
               patch_height_max=None, patch_height_min=1, patch_width_max=None,
               patch_width_min=1, projection_matrix='RerF', random_state=2)
y_pred1 = clf1.predict(X_test)
y_pred2 = clf2.predict(X_test)
from sklearn import metrics
print("Accuracy:", metrics.accuracy_score(y_test, y_pred1))
print("Accuracy oob:", metrics.accuracy_score(y_test, y_pred2))
Accuracy: 0.9555555555555556
Accuracy oob: 0.9333333333333333
@rflperry rflperry added the bug label Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant