No project description provided
Current version: 0.3.0
pip install biasedclassifier
BiasedClassifier( p=[0.0], unbiased_estimator=None, knn=None )
unbiased_estimator is the base estimator to use (and to biased towards critical set). We pass a
k-NearestNeighbor object directly via the paramter
Example using Random Forests from
X, y is a training set with three classes and two heavily inbalanced classes. In this case, we'd like to bias two classifiers into these subsets. We've decided that
0.2 proportions are enough for the minority classes (from smaller up) and
k=10 neighbors to collect for critical set. Our unbiased estimator will be a random forest of size 200.
from biasedclassifier import BiasedClassifier from sklearn.neighbors import NearestNeighbors from sklearn.ensemble import RandomForestClassifier clf = BiasedClassifier( p=[0.3, 0.2], unbiased_classifier=RandomForestClassifier(n_estimators=200), knn=NearestNeighbors(n_neighbors=10) ) # Train clf.fit(X,y) # Obtain probabilities for each class prob = clf.predict_proba(X) # Predicted values y_pred = clf.predict(X) # Average accuracy score score = clf.score(X, y)
It is important to note that
BiasedEstimator does not change the state of both objects
knn. Instead, it uses clones internally to do its operations.
This model is compatible with all of the capabilities offered by
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for BiasedClassifier-0.3.1-py3-none-any.whl