Quickly try out several ML models on a given dataset
Project description
Hundred Hammers
"At least one of them is bound to do the trick."
Hundred Hammers is a Python package that helps you batch-test ML models in a dataset. It can be used out-of-the-box to run most popular ML models and metrics, or it can be easily extended to include your own.
- Supports both classification and regression.
- Already comes strapped with most sci-kit learn models.
- Already comes with several plots to visualize the results.
- Easy to integrate with parameter tuning from GridSearch CV.
- Already gives you the average metrics from training, test, validation (train) and validation (test) sets.
- Allows you to define how many seeds to consider, so you can increase the significance of your results.
- Produces a Pandas DataFrame with the results (which can be exported to CSV and analyzed elsewhere).
Installation
The recommended way to install the library is through pip install hundred_hammers. However, if you want to fiddle around with the repo yourself, you can clone this repository, and run pip install -e hundred_hammers/
Examples
Full examples can be found in the examples directory. As an appetizer, here's a simple one of how to use Hundred Hammers to run a
batch classification on Iris data:
from hundred_hammers.classifier import HundredHammersClassifier
from hundred_hammers.plots import plot_batch_results
from sklearn.datasets import load_iris
data = load_iris()
X, y = data.data, data.target
hh = HundredHammersClassifier()
df_results = hh.evaluate(X, y)
plot_batch_results(df_results, metric_name="Accuracy", title="Iris Dataset")
This already gives us a DataFrame with the results from several different models, and a nice plot of the results:
Other plots
We can also use Hundred Hammers to produce nice confusion matrices plots and regression predictions:
from hundred_hammers.plots import plot_confusion_matrix
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
data = load_iris()
X, y = data.data, data.target
plot_confusion_matrix(X, y, class_dict={0: "Setosa", 1: "Versicolor", 2: "Virginica"},
model=DecisionTreeClassifier(), title="Iris Dataset")
from hundred_hammers.plots import plot_regression_pred
from sklearn.datasets import load_diabetes
from sklearn.metrics import mean_squared_error
from sklearn.dummy import DummyRegressor
data = load_diabetes()
X, y = data.data, data.target
plot_regression_pred(X, y, models=[DummyRegressor(strategy='median'), best_model], metric=mean_squared_error,
title="Diabetes", y_label="Diabetes (Value)")
Finally, it is also possible to compare different datasets and compare their results (each dot is a model).
data = load_iris()
X, y = data.data, data.target
hh = HundredHammersClassifier()
df = []
for i, feature_name in enumerate(data.feature_names):
X_i = X[:, [j for j in range(X.shape[1]) if j != i]]
for degree in range(8):
df_i = hh.evaluate(X_i ** degree, y, optim_hyper=False)
df_i["Dataset"] = f"$X^{degree}$, w/out $x_{i}$"
df.append(df_i)
df_results = pd.concat(df, ignore_index=True)
plot_multiple_datasets(df_results, metric_name="Avg ACC (Validation Test)", id_col="Dataset", title="Iris Dataset", display=True)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hundred-hammers-1.0.4.tar.gz.
File metadata
- Download URL: hundred-hammers-1.0.4.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8235d89309bf7ec539d512171e32dd710734f86069687bd117f2144f34b79201
|
|
| MD5 |
e34003555cbe1fb314bf8dc0360deb72
|
|
| BLAKE2b-256 |
138967c6f836143176682c64d939ab5d9c1ecf1e36ec52ebbfb789cf17e88172
|
File details
Details for the file hundred_hammers-1.0.4-py3-none-any.whl.
File metadata
- Download URL: hundred_hammers-1.0.4-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51f6a12917adea0b96add52865c10d6a7a719ddf2d20d0388ecdcc0069b13cbc
|
|
| MD5 |
c44f7236a9fb5a3b79b7c1d74cb829fd
|
|
| BLAKE2b-256 |
edf5124d0b2b4499d654873ef25be22aeae155897220acdc2e582a055bf2ce3c
|