Skip to main content

A Python package for performing classification on datasets in CSV or Excel format.

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.7.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: classifierAgent-1.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 832cddf3bd3d9da855a83488c2886d2ea9050629118a2e3658aaf4fa6e86ce1e
MD5 fdec96df757b1f814bdb04819e9237f4
BLAKE2b-256 2806315247b80c6f0e32997e8b49290307e8f637d08d0d5925584fb40a199f44

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for classifierAgent-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 55b43507ac65c83c3c68e0ff29ffe8179b0e6f4d047d0b6512ea1e475aad8a8e
MD5 a02e641031c059b3e33b61ce565fb155
BLAKE2b-256 14d68a99b86d666be38c7e3a24aedd16ce96e9f7afc8a3079d9fa6fe9f73dceb

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