Skip to main content

Auto Logistic Regression

Overview

This project implements an Auto Logistic Regression framework for easy model training, evaluation, and prediction. The framework includes two main classes: AutoLogisticRegression and AutoPreprocessor.

AutoLogisticRegression Class

The AutoLogisticRegression class is designed to automate the process of logistic regression model training and evaluation. Key functionalities include:

  • Initialization: Accepts the path to the training dataset (data_path), the target column name (target_column), the output path for the model and predictions (output_path), and an optional parameter for the number of folds in cross-validation (num_folds).
  • Training: Uses logistic regression with cross-validation to train a model on the provided dataset. The best model is saved as a pickle file for future use.
  • Prediction: Given a new dataset, the trained model can be used to make predictions. The predictions are saved to a CSV file at the specified output path.

AutoPreprocessor Class

The AutoPreprocessor class handles the preprocessing steps required before training or making predictions with the logistic regression model. Key functionalities include:

  • Initialization: Accepts optional parameters for specifying categorical columns (categorical_columns), numeric columns (numeric_columns), and whether to perform oversampling (oversample).
  • Fit and Transform: Fits an imputer, encoder (for categorical columns), and scaler (for numeric columns) on the provided data. The transformations are then applied to the data.
  • Oversampling: Optionally applies oversampling to balance the class distribution in the training data.
  • Split Data: Splits the data into training and testing sets.

Usage

  1. Importing:
from autolr import AutoLogisticRegression
  1. Initialization: Create an instance of the AutoLogisticRegression class by providing the path to the training dataset, the target column name, and the output path for the model and predictions. Optionally, you can specify the number of folds for cross-validation.
auto_lr = AutoLogisticRegression(data_path='path/to/training_data.csv', target_column='target', output_path='output', num_folds=5)
  1. Training Model: After training, the model is automatically evaluated using metrics such as accuracy, classification report, and confusion matrix. The feature importance is also displayed.
# Training the model and evaluating it
auto_lr.train()
  1. Prediction: After training, you can use the trained model to make predictions on new data by providing the path to the new dataset.
predictions = auto_lr.predict(data_path='path/to/test_data.csv')

Dependencies

Notes

  • Ensure that the required dependencies are installed before running the code.
  • The AutoPreprocessor class is used internally for data preprocessing and is not intended for standalone use.
  • Customize and extend this framework based on your specific needs.
  • If you encounter any issues or have suggestions for improvements, please let us know.

Release files for autolr 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autolr 0.0.2
File Size Uploaded
autolr-0.0.2.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autolr 0.0.2
File Interpreter ABI Platform
autolr-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / autolr-0.0.2.tar.gz

Download URL autolr-0.0.2.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b646ec4e9d2b4095dd8c718744c43f10ca815caa14742306b8f2f85a4afa1eba
BLAKE2b-256 checksum
How to use checksums
f5852f2c1b6cd45afe5aea510f4bc846c1ea520eacd77030ff5ef1498d23b09c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / autolr-0.0.2-py3-none-any.whl

Download URL autolr-0.0.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4f90a33fd19d461d31c021c94e4506203d0936c7df8c662319fdeb2140f420e
BLAKE2b-256 checksum
How to use checksums
39479830c425f265b9bbb1a18968bcb3d84e027f508756e74882f62bc322b19a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page