No project description provided
Project description
ML Scorer
ML Scorer is the solution to your classification scores of ML algorithms.
Installation
pip install mlscorer
Preperation
Make a class mapping dictionary(map_class) using Method1 or Method2
Method 1
Make all the data categorical using following code snippet
map_class = dict(zip(df.classes.astype("category").cat.codes, df.classes))
print(map_class)
output: {1: 'positive', 0: 'negative'}
here, df is the Dataframe and classes is a column which may have class values like
- positive
- negative
[N.B. Don't change "category", it's a datatype]
or
Method 2
Make the Dictionary manually according to your classes
map_class = {
1: 'positive',
0: 'negative'
}
Usage
from sklearn.linear_model import LogisticRegression
import mlscorer as ms
classifier = LogisticRegression()
classifier.fit(X_train, y_train)
y_pred = classifier.predict(X_test)
ms.get_score_table(y_test, y_pred, map_class)
Output:
Parameters
y_test : target values of test set
y_pred : predicted target values
map_class : dict : your categoricl class mapping
metrics : list : use one or more evaluation metric from f1, precision, recall or accuracy
eg:
ms.get_score_table(y_test, y_pred, map_class, metrics=['precision', 'recall'])
Output:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.