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

Installation

Github : https://github.com/pratikrathod08/ML-Genius

Pypi : pip install ML-Genius==0.0.2

Read Data

from ml_genius.ml.preprocessor.datareader import ReadData

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

Describe Data

from ml_genius.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 ml_genius.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 ml_genius.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 ml_genius.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.2.tar.gz (13.2 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.2-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ml_genius-0.0.2.tar.gz
  • Upload date:
  • Size: 13.2 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.2.tar.gz
Algorithm Hash digest
SHA256 1c158888c871dfde77fbeda29e73ae361f8320dcfe49f513a8fb884b544b12ca
MD5 e3abac6ea1e6a23f03460d2ec14a1ad4
BLAKE2b-256 ae232af3cc2ca7ff8ab7cdd80f152846a08d6eb114c1dd23052285316378348b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ml_genius-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 18.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 79f6a9b21262353f38b6209e12323b513f0bad04952076bb263862de3e8c7630
MD5 da5e08e22ebdef511d8cbde7d4061a42
BLAKE2b-256 2d858f8c89c51a3cd95251ee0f177a95f0fe1aa06eb2a69429a875a3774bfa11

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