Machine Learning package for quick fast model generation and comparison
Project description
modelcreator - AutoML package
This package contains a Machine which is meant to do the learning for you. It can automaticly create a fitting predictive model for given data.
Instalation
To use the package run:
pip install modelcreator
Usage
The input may be either a path to csv file or a pandas DataFrame object.
CSV path input
The library assumes that the last column of the training dataset contains the expected results. The dataset (both training and predictive) must be provided as a csv file.
If the results column contains text the Machine will do its best to learn to classify the data correctly. In case of a number in it regression will be performed.
If the file contains headers you shall add header_in_csv=True
parameter to the method. If you want the learning or predicting to be silent add verbose=False
.
Example 1 Iris
from modelcreator import Machine
# Create automl machine instance
machine = Machine()
# Train machine learning model
machine.learn('example-data/iris.csv')
# Predict the outcomes
machine.predict('example-data/iris-pred.csv', 'output.csv')
This example is also available in the example.py
file. Consider trying it on your own.
DataFrame input
But what to do if a result column is not the last in the given csv? It may be inconvenient to rewrite the whole csv just to swap the columns. Because of this problem Machine has learnFromDf
and predictFromDf
methods. The Df in method names stands for DataFrame from pandas module. This way you can handle reading the file by yourself.
Example 2 Titanic
from modelcreator import Machine
import pandas as pd
# Create DataFrame object from file
train = pd.read_csv("titanic/train.csv")
# Get features columns from DataFrame
X_train = train.drop(['Survived'], axis=1)
# And labels (results) column
y_train = train["Survived"].astype(str)
# Create the instance of Machine
machine = Machine()
# Train machine learning model
machine.learnFromDf(X_train, y_train)
# Show parameters of the model
machine.showParams()
# Load test set from fole
X_test = pd.read_csv("titanic/test.csv")
# Predict the labels
results = machine.predictFromDf(X_test)
# Save results to a new file
results.to_csv("results")
Simple? That's right! Just note that we used astype(str)
in order to treat data as classes, not numbers, because the Titanic dataset used in the example above has values 0 and 1 in "Survived"
column to indicate whether a person made it through the disaster.
Saving the model
If you want your model to avoid re-learning on the whole dataset just to make a simple prediction you can save the state of Machine to a file.
# Save Machine with trained model to "machine.pkl"
machine.saveMachine('machine.pkl')
# Create new machine based on a schema file
machine2 = Machine('machine.pkl')
Development
Have a feature idea or just want to help? Take a look at the issues tab!
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
Hashes for modelcreator-0.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d2843f1c0f44d0855676e484a4340b11161d3ebb3ca1ab6afe190bfd1bb528c |
|
MD5 | 02e6e498cb0dd4177146c5ef1996e6c3 |
|
BLAKE2b-256 | 2f318df647c14f3dcb1efed0b03d909b810e8e52d5dc1f83481d4b23f2b66854 |