Skip to main content

An AutoML framework with classification, regression, etc.

Project description

🤖 ML-Genius

ML-Genius is a lightweight Python library that automates key machine learning tasks including preprocessing, training, and evaluation — with just a few lines of code. It supports both regression and classification pipelines and enables users to quickly test multiple models, select the best one, and store reusable components.


🚀 Features

  • One-line data preprocessing with support for CSV/Excel
  • Automated model training and evaluation
  • Supports both regression and classification
  • Easily store and reuse trained models and preprocessors
  • Extensible for new models and components

How to use

Install test package

pip install --extra-index-url https://test.pypi.org/simple/ Auto-MachineLearning==0.1.1

Read Data

from auto_machinelearning.ml.preprocessor.datareader import ReadData

reader = ReadData()
df = reader.read_csv("data.csv")

Describe Data

from auto_machinelearning.ml.preprocessor.datadescriber import DataDescribe

desc = DataDescribe(df_csv, target_column="target_column")
desc.summarize()  # Print summary
summary_data = desc.get_summary_dict()

Preprocess Data

from auto_machinelearning.ml.preprocessor.preprocess import AutoPreprocess

# Create the processor instance
processor = AutoPreprocess(
    path="data.csv",                                        # Path to the file
    file_type="csv",                                        # "csv" or "excel"
    store_path="output/processed.csv",                      # Path to save the result
    target_column="price",                                  # Target column name
    preprocessor_store_path="output/preprocessor.pkl",      # path to store preprocessor 
    encoding="utf-8",                                       # Optional parameters passed to read_csv
    delimiter=","                                           # Optional (if CSV uses different delimiter)
)

# Run the full processing pipeline
processed_df= processor.process()

# You can now work with processed_df
print(processed_df.head())

Use stored preprocessor

import pandas as pd 
import joblib 

preprocessor = joblib.load("output/preprocessor.pkl")
csv_path = "data/data.csv"
df = pd.read_csv(csv_path)
preprocessed_df = preprocessor.transform(df)
preprocessed_df = pd.DataFrame(preprocessed_df)

## Note : add headers and output column in processed df as it is returning processed raw data. 

Train Model

Regression

from auto_machinelearning.ml.regression import AutoRegression

regression = AutoRegression(path="processed.csv", filetype="csv", target_column="target_column")
result = regression.train_model()
print(result)

Models Available

  • Linear Regression
  • Ridge Regression
  • Decision Tree
  • Random Forest
  • Gradiant Boosting

Output Parameters

  • best_model_name
  • model
  • model_params
  • r2_score
  • rmse
  • mse

Save and Use Trained Model

import joblib 
import numpy as np
import pandas as pd 
from sklearn.metrics import r2_score, mean_squared_error

## Store trained model to local system
model = result.get("model")
joblib.dump(model, "model.pkl")

## Load model
model = joblib.load("model.pkl")

## Import data and predict
df = pd.read_csv("processed.csv")
X = df.drop(columns=['target_column'])
y = df["target_column"]

y_pred = model.predict(X)

## Evaluate model 
print("r2_score : ", r2_score(y_pred, y))
print("mse : ", mean_squared_error(y_pred, y))
print("rmse : ", np.sqrt(mean_squared_error(y_pred, y)))

Classification

from auto_machinelearning.ml.classification import AutoClassification

classification = AutoClassification(path="processed.csv", filetype="csv", target_column="target_column")
result = classification.train_model()
print(result)

Models Available

  • Logistic Regression
  • KNN
  • Naive Bayes
  • Decision Tree
  • Random Forest
  • Gradiant Boosting
  • ADA Boost

Output Parameters

  • best_model_name
  • model
  • model_params
  • accuracy
  • precision
  • recall
  • f1_score

Save and Use Trained Model

import joblib 
import numpy as np
import pandas as pd 
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score

## Store trained model to local system
model = result.get("model")
joblib.dump(model, "model.pkl")

## Load model
model = joblib.load("model.pkl")

## Import data and predict
df = pd.read_csv("processed.csv")
X = df.drop(columns=['target_column'])
y = df["target_column"]

y_pred = model.predict(X)

## Evaluate model 
print("accuracy score : ", accuracy_score(y_pred, y))
print("precision score : ", precision_score(y_pred, y))
print("recall score : ", recall_score(y_pred, y))
print("f1 score : ", f1_score(y_pred, y))

🤝 Contributing

Contributions are welcome! If you'd like to improve the code, add features, or fix bugs, please follow the steps below:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature-name
  3. Make your changes.
  4. Test your changes.
  5. Commit and push: git commit -m 'Add some feature' && git push origin feature-name
  6. Create a Pull Request.

Guidelines

  • Follow PEP8 coding style.
  • Write meaningful commit messages.
  • Add docstrings and comments where necessary.

If you add a new model or preprocessor, please update the documentation.

Issues & Discussions

  • Use the GitHub Issues to report bugs or suggest features.
  • You can also start a discussion if you're unsure about a change.

📄 License

This project is licensed under the MIT License – see the LICENSE file for details.

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

ml_genius-0.0.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ml_genius-0.0.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file ml_genius-0.0.1.tar.gz.

File metadata

  • Download URL: ml_genius-0.0.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ml_genius-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bee9f22843dc3b2555a989c820daa3d72295ce1f17694e6ac1e08ad974c0a4e7
MD5 51ce5f9526b5c0122723f09797c4b0e7
BLAKE2b-256 de8a7e951bd454bb7a0ecef11666fb98f714ed18f0355f8bdb379805c7dc4444

See more details on using hashes here.

File details

Details for the file ml_genius-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ml_genius-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for ml_genius-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 825057de24307ed01b76f297db2c435d66c9b8d062790234019aafe8c617c98d
MD5 77ff63116d3633e9b377b1560dcb0825
BLAKE2b-256 11d55d7ac3b7fc500b732756e16945fd3c05da4478ff25e4b99ee04ecc190024

See more details on using hashes here.

Supported by

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