15+ Algorithms

Trainers

mlcli supports 15+ machine learning algorithms out of the box including classification, regression, clustering, and anomaly detection.

Available Trainers

List all available trainers with:

Terminal
mlcli list-trainers

Traditional ML

3 trainers

Random Forest

scikit-learn
Classification / Regression
mlcli train -m random_forest

Ensemble of decision trees with bootstrap sampling.

SVM

scikit-learn
Classification / Regression
mlcli train -m svm

Support Vector Machine with various kernels.

Logistic Regression

scikit-learn
Classification
mlcli train -m logistic

Linear model for binary and multiclass classification.

Gradient Boosting

3 trainers

XGBoost

XGBoost
Classification / Regression
mlcli train -m xgboost

Gradient boosting with regularization for high performance.

LightGBM

LightGBM
Classification / Regression
mlcli train -m lightgbm

Fast gradient boosting with leaf-wise tree growth and native categorical support.

CatBoost

CatBoost
Classification / Regression
mlcli train -m catboost

Gradient boosting with excellent handling of categorical features.

Clustering

2 trainers

K-Means

scikit-learn
Clustering
mlcli train -m kmeans

Partition-based clustering with automatic optimal K detection via elbow method.

DBSCAN

scikit-learn
Clustering
mlcli train -m dbscan

Density-based clustering with automatic noise detection and optimal eps finder.

Anomaly Detection

2 trainers

Isolation Forest

scikit-learn
Anomaly Detection
mlcli train -m isolation_forest

Tree-based anomaly detection using isolation principle.

One-Class SVM

scikit-learn
Anomaly Detection
mlcli train -m one_class_svm

Novelty detection using support vector methods.

Deep Learning

3 trainers

DNN

TensorFlow
Classification / Regression
mlcli train -m tf_dnn

Deep Neural Network with customizable layers.

CNN

TensorFlow
Classification
mlcli train -m tf_cnn

Convolutional Neural Network for image-like data.

RNN

TensorFlow
Classification / Regression
mlcli train -m tf_rnn

Recurrent Neural Network for sequential data.

Using Trainers

Train a model using the --model or -m flag:

Terminal
# Train Random Forest (Classification/Regression)
mlcli train -d data.csv -m random_forest --target label

# Train LightGBM (Gradient Boosting)
mlcli train -d data.csv -m lightgbm --target label

# Train K-Means (Clustering - no target needed)
mlcli train -d data.csv -m kmeans

# Train Isolation Forest (Anomaly Detection)
mlcli train -d data.csv -m isolation_forest

# Train Deep Neural Network
mlcli train -d data.csv -m tf_dnn --target label

Creating Custom Trainers

You can create custom trainers by extending the BaseTrainer class:

my_trainer.py
from mlcli.trainers.base_trainer import BaseTrainer

class MyCustomTrainer(BaseTrainer):
    """Custom trainer implementation."""

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        # Initialize your model here

    def train(self, X_train, y_train, X_val=None, y_val=None):
        """Train the model."""
        # Implement training logic
        pass

    def predict(self, X):
        """Make predictions."""
        # Implement prediction logic
        pass

    def save(self, path):
        """Save the model."""
        # Implement model saving
        pass

    def load(self, path):
        """Load a saved model."""
        # Implement model loading
        pass

Register your custom trainer with the model registry:

Python
from mlcli.utils.registry import ModelRegistry

# Register the custom trainer
ModelRegistry.register("my_custom", MyCustomTrainer)

# Now use it with mlcli
# mlcli train -d data.csv -m my_custom --target label

Next Steps

Learn more about specific trainers: