Skip to main content

A Python package for performing classification on datasets.

Project description

classifierAgent: Machine Learning Classification Python Package

Python Scikit-Learn

Overview

This Python package provides a comprehensive solution for performing classification tasks using various popular machine learning algorithms. It allows you to read a dataset, preprocess it, train multiple classifiers, perform hyperparameter tuning, and visualize model performance. Additionally, it provides options for scaling data, saving trained models, and customizing the output display.

Features

  1. Classification Algorithms:

    • Logistic Regression
    • K-Nearest Neighbors
    • Decision Tree
    • Random Forest
    • Gradient Boosting
    • Support Vector Classifier
    • Gaussian Naive Bayes
    • Bernoulli Naive Bayes
  2. Advanced Functionality:

    • Data Scaling: Options for Min-Max Scaling or Standard Normalization.
    • Hyperparameter Tuning: Option to perform Grid Search for finding the best model parameters.
    • Model Persistence: Save and load trained models using joblib.
    • Visualization: Option to plot confusion matrices and detailed classification reports.
    • Cross-Validation: Evaluate models using cross-validation scores.
    • Configurable Outputs: Options to control the display of confusion matrices and classification reports.
  3. Results:

    • Returns a DataFrame with model names, accuracy, F1-score, and optionally the best hyperparameters.

Parameters

The package takes the following parameters as input:

  • dataset: Path to the CSV or Excel dataset file or a pandas DataFrame.
  • output_column: Name of the output column containing the target variable.
  • train_test_ratio: Ratio in which the dataset is divided into train and test splits (must be between 0 and 1).
  • scaling_method (optional): Method to scale the data ('minmax' or 'normalize').
  • perform_grid_search (optional): Whether to perform grid search for hyperparameter tuning (default is False).
  • save_models (optional): Whether to save trained models to disk (default is False).
  • show_confusion_matrix (optional): Whether to display confusion matrix plots (default is False).
  • show_classification_report (optional): Whether to print classification reports (default is False).

Installation

Make sure you have Python installed on your system. You can install the package using pip:

pip install classifierAgent

Usage

Here's an example of how to use the package:

from classifierAgent import classifierAgent

dataset_path = "sampleFile.csv"
output_column = "Outcome"
train_test_ratio = 0.25
scaling_method = 'minmax'  # Choose 'minmax' or 'normalize'
perform_grid_search = True  # Whether to perform grid search
save_models = True  # Whether to save models
show_confusion_matrix = True  # Whether to plot the confusion matrix
show_classification_report = True  # Whether to print the classification report

results = classifierAgent(dataset_path, output_column, train_test_ratio, scaling_method, perform_grid_search, save_models, show_confusion_matrix, show_classification_report)
print(results)

Example Output

The output is a DataFrame that looks like this:

Classifier Accuracy F1-Score Best Parameters
KNeighborsClassifier 0.78 0.76 {'n_neighbors': 5, 'weights': 'uniform'}
LogisticRegression 0.80 0.79 {'C': 0.1, 'solver': 'liblinear'}
DecisionTreeClassifier 0.72 0.70 {'criterion': 'entropy', 'max_depth': 20}
RandomForestClassifier 0.85 0.84 {'n_estimators': 200, 'max_depth': 20}
GradientBoostingClassifier 0.83 0.82 {'n_estimators': 200, 'learning_rate': 0.1}
SVC 0.81 0.80 {'C': 1, 'kernel': 'rbf'}
GaussianNB 0.75 0.73 {}
BernoulliNB 0.73 0.72 {}

Publishing to PyPI

To publish this package to PyPI, follow these steps:

  1. Ensure Your Package is Ready:

    • Make sure your setup.py and README.md are correctly configured.
    • Verify that your package is properly structured and tested.
  2. Create Distribution Archives: Run the following command to create distribution archives of your package:

    python setup.py sdist bdist_wheel
    
  3. Install Twine: If you haven't already, install Twine, a utility for publishing packages to PyPI:

    pip install twine
    
  4. Upload to PyPI: Use Twine to upload your package to PyPI:

    twine upload dist/*
    

    You will be prompted to enter your PyPI username and password.

  5. Verify Upload: After uploading, check your package on PyPI to ensure it appears correctly.

For more detailed instructions, refer to the PyPI documentation.

Automated Publishing with GitHub Actions

To automate the publishing of your package to PyPI, GitHub Actions is setup. This allows to push updates to PyPI whenever changes are made to the main branch.

Setting Up GitHub Actions

  1. Add Your PyPI Token to GitHub Secrets:

    • Go to your repository settings.
    • Navigate to "Secrets and variables" > "Actions".
    • Add a new secret with the name PYPI_TOKEN and paste your PyPI token as the value.
  2. Create a GitHub Actions Workflow File:

    • Add a .github/workflows/publish.yml file to your repository with the following content:

This setup will automatically build and publish your package to PyPI whenever you push changes to the main branch. Make sure to test your workflow to ensure that everything works as expected.

Notes

  • The package is actively developed and may receive updates.
  • The project is developed with Python version 3.10.
  • If you encounter any issues or have questions, feel free to contact me on LinkedIn.

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

classifierAgent-1.0.8.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

classifierAgent-1.0.8-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file classifierAgent-1.0.8.tar.gz.

File metadata

  • Download URL: classifierAgent-1.0.8.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for classifierAgent-1.0.8.tar.gz
Algorithm Hash digest
SHA256 cd306f89cdd8e21b5745477305c13bc0bc6f3cd73ebc8641125d5a2468454f07
MD5 e0bf47e6d95d0bc2c604fef76a4fe229
BLAKE2b-256 3e3b7338bca46d1515ad053489a80351e7358bfeefac0f85e0ca235b76564183

See more details on using hashes here.

Provenance

File details

Details for the file classifierAgent-1.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for classifierAgent-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fa45287cc928d68989b39661b4eed3549fe87776fb6e491521a1e3c4406029c1
MD5 746c2806b95bb2faf40bf5ba165bd7cd
BLAKE2b-256 dd27372803ef9582fa4f5b1af1368c7079afafa55940f6891a2c38cbc9dfc319

See more details on using hashes here.

Provenance

Supported by

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