Models Contrast
A simple package for compare the performance of two ML models in sklearn, python.
Installation
Use the package manager pip to install model-contrast.
pip install model-contrast
Usage
Compare 2 Binary Classifiers
from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
# create two demo models
X, y = make_classification(n_samples=700, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.2, random_state=42)
model1 = RandomForestClassifier(n_estimators=10, random_state=42)
model2 = LogisticRegression()
#train the models
model1.fit(X_train, y_train)
model2.fit(X_train, y_train)
Now let's compare them with our package:
from model_contrast import classificator_contrast
classificator_contrast(model1, model2, X_test, y_test)
and it return:
Compare Multi-Class Classifiers
from sklearn.datasets import make_classification
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
# create two demo models
X, y = make_classification(n_samples=700, random_state=42, n_classes=4, n_informative=4)
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.2, random_state=42)
model1 = RandomForestClassifier(n_estimators=10, random_state=42)
model2 = LogisticRegression()
#train the models
model1.fit(X_train, y_train)
model2.fit(X_train, y_train)
Compare them:
from model_contrast import classificator_contrast
classificator_contrast(model1, model2, X_test, y_test)
and it returns:
Compare 2 Regressors
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.ensemble import RandomForestRegressor
#create the regressor
X, y = make_regression(n_samples=700, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y,
test_size=0.2, random_state=42)
model1 = RandomForestRegressor(n_estimators=10, random_state=42)
model2 = LinearRegression()
#train the regressors
model1.fit(X_train, y_train)
model2.fit(X_train, y_train)
Compare them:
from model_contrast import regressor_contrast
regressor_contrast(model1, model2, X_test, y_test)
and it returns:
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Release files for model-contrast 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| model contrast-0.1.8.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| model_contrast-0.1.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / model contrast-0.1.8.tar.gz
| Download URL | model contrast-0.1.8.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a911c1867ebae2d99e077423685cecf086178ed845f3d03b94b3d9b312d35857
|
|
BLAKE2b-256 checksum How to use checksums |
e7525bb1dbb93ea16e1909745d6fd596fa0dd569e27364c565a2997ef1bfc86a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.11
|
Release files / model_contrast-0.1.8-py3-none-any.whl
| Download URL | model_contrast-0.1.8-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31ac543d771cc431294dcdb35f3f3a7e27010320116e3a015bf3b69752a48261
|
|
BLAKE2b-256 checksum How to use checksums |
27b3997fb6c6079303b63e302dfc344c457146a1ceac9cc99494e31881155114
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.11
|