A professional, scalable machine learning library with modular architecture for preprocessing, modeling, evaluation, clustering, and exploration.
- 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
- 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
- Comprehensive metrics for classification and regression
- Confusion matrices and classification reports
- ROC AUC and other advanced metrics
- Performance tracking and comparison
- Statistical summaries and data profiling
- Missing value analysis with visualizations
- Correlation analysis with heatmaps
- Distribution plots for all features
- Automated EDA reports
# Clone or download the repository
cd mltools
# Install dependencies
pip install -r requirements.txt
# Install in editable mode (recommended for development)
pip install -e .After installation, you can run the examples:
python examples/classification_example.py
python examples/clustering_example.py
python examples/full_pipeline_example.pyfrom 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()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_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()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
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)See the examples/ directory for complete examples:
classification_example.py- Full classification workflowclustering_example.py- Clustering analysisfull_pipeline_example.py- End-to-end ML pipeline
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
- 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
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue on the GitHub repository.