Skip to main content

No project description provided

Project description

Biased Classifier

Biased Classifier

Current version: 0.2.0

Install

Directly from PyPi servers:

pip install biasedclassifier

Use

Example using Random Forests from scikit-learn.

Assume 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.3 and 0.2 proportions are enough for the minority classes (from smaller up)

from biasedclassifier import BiasedClassifier
from sklearn.ensemble import RandomForestClassifier

clf = BiasedClassifier(
    k=5, 
    p=[0.3, 0.2], 
    unbiased_classifier=RandomForestClassifier(), 
    knn_jobs=1
)

# 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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BiasedClassifier-0.2.0.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

BiasedClassifier-0.2.0-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page