Skip to content

Repository files navigation

MLTools - Comprehensive Machine Learning Library

A professional, scalable machine learning library with modular architecture for preprocessing, modeling, evaluation, clustering, and exploration.

Features

🔧 Preprocessing

  • Multi-format data loading (CSV, Excel, JSON, Parquet, Feather, etc.)
  • Automatic feature type detection (numerical, categorical, datetime, text, boolean)
  • Smart missing value handling with multiple strategies
  • Memory optimization for large datasets
  • Adaptive scaling that selects optimal method based on data distribution
  • Feature engineering with polynomial features, interactions, and more

🤖 Models

  • Classification: Multiple algorithms with auto-tuning
    • Random Forest, Gradient Boosting, Logistic Regression
    • SVM, KNN, Decision Tree, Extra Trees, Naive Bayes
  • Clustering: Automatic cluster detection
    • KMeans, Hierarchical, DBSCAN, Spectral, Gaussian Mixture
  • Hyperparameter optimization using GridSearch and RandomSearch
  • Cross-validation for robust model selection

📊 Evaluation

  • Comprehensive metrics for classification and regression
  • Confusion matrices and classification reports
  • ROC AUC and other advanced metrics
  • Performance tracking and comparison

🔍 Exploration

  • Statistical summaries and data profiling
  • Missing value analysis with visualizations
  • Correlation analysis with heatmaps
  • Distribution plots for all features
  • Automated EDA reports

Installation

From Source (Development Mode)

# Clone or download the repository
cd mltools

# Install dependencies
pip install -r requirements.txt

# Install in editable mode (recommended for development)
pip install -e .

Running Examples

After installation, you can run the examples:

python examples/classification_example.py
python examples/clustering_example.py
python examples/full_pipeline_example.py

Quick Start

Classification Example

from mltools import DataProcessor, Classifier, ModelEvaluator

# Load and preprocess data
processor = DataProcessor(data='data.csv', target_column='target')
processor.preprocess()
X_train, X_test, y_train, y_test = processor.split_data()

# Train models
classifier = Classifier()
classifier.fit(X_train, y_train, tune_hyperparameters=True)

# Make predictions
y_pred = classifier.predict(X_test)

# Evaluate
evaluator = ModelEvaluator()
metrics = evaluator.evaluate_classification(y_test, y_pred)
evaluator.print_report()

Clustering Example

from mltools import DataProcessor, ClusteringSystem

# Load and preprocess data
processor = DataProcessor(data='data.csv')
processor.preprocess()
data = processor.get_data()

# Perform clustering
clustering = ClusteringSystem()
clustering.fit(data, algorithms=['kmeans', 'hierarchical'])

# Get best model
best_name, best_model = clustering.get_best_model()
labels = clustering.labels_

Exploratory Data Analysis

from mltools import DataExplorer

# Create explorer
explorer = DataExplorer(data)

# Generate summary statistics
summary = explorer.summary_statistics()

# Analyze missing values
missing = explorer.analyze_missing_values()

# Plot correlations
explorer.plot_correlation_heatmap()

# Generate complete report
report = explorer.generate_report()

Library Structure

mltools/
├── __init__.py                 # Main package interface
├── preprocessing/              # Data preprocessing
│   ├── __init__.py
│   ├── data_processor.py      # Main preprocessing class
│   ├── feature_engineering.py # Feature engineering utilities
│   └── scalers.py             # Adaptive scaling transformers
├── models/                     # ML models
│   ├── __init__.py
│   ├── classifier.py          # Classification models
│   └── clustering.py          # Clustering models
├── evaluation/                 # Model evaluation
│   ├── __init__.py
│   └── evaluator.py           # Evaluation metrics
├── exploration/                # EDA tools
│   ├── __init__.py
│   └── explorer.py            # Data exploration
└── utils/                      # Utilities
    ├── __init__.py
    ├── config.py              # Configuration management
    ├── logger.py              # Logging utilities
    └── helpers.py             # Helper functions

Configuration

Customize behavior using the Config class:

from mltools import Config

config = Config()
config.preprocessing['scale_numerical'] = 'robust'
config.modeling['cv'] = 10
config.random_state = 123

# Use with any component
processor = DataProcessor(data, config=config)
classifier = Classifier(config=config)

Examples

See the examples/ directory for complete examples:

  • classification_example.py - Full classification workflow
  • clustering_example.py - Clustering analysis
  • full_pipeline_example.py - End-to-end ML pipeline

API Design

MLTools follows scikit-learn's API conventions:

  • .fit() - Train/fit the model or transformer
  • .transform() - Transform data using fitted parameters
  • .predict() - Make predictions
  • .fit_transform() - Fit and transform in one step

Requirements

  • Python >= 3.7
  • numpy >= 1.21.0
  • pandas >= 1.3.0
  • scikit-learn >= 1.0.0
  • matplotlib >= 3.4.0
  • seaborn >= 0.11.0
  • scipy >= 1.7.0
  • joblib >= 1.0.0

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please open an issue on the GitHub repository.

About

MLTools is a comprehensive and professional Python library for machine learning, designed to simplify and accelerate the process of building and developing ML models. Built on scikit-learn, it provides a unified and user-friendly interface for common machine learning tasks

Resources

Stars

18 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages