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:
mlcli list-trainersTraditional ML
3 trainersRandom Forest
mlcli train -m random_forestEnsemble of decision trees with bootstrap sampling.
SVM
mlcli train -m svmSupport Vector Machine with various kernels.
Logistic Regression
mlcli train -m logisticLinear model for binary and multiclass classification.
Gradient Boosting
3 trainersXGBoost
mlcli train -m xgboostGradient boosting with regularization for high performance.
LightGBM
mlcli train -m lightgbmFast gradient boosting with leaf-wise tree growth and native categorical support.
CatBoost
mlcli train -m catboostGradient boosting with excellent handling of categorical features.
Clustering
2 trainersK-Means
mlcli train -m kmeansPartition-based clustering with automatic optimal K detection via elbow method.
DBSCAN
mlcli train -m dbscanDensity-based clustering with automatic noise detection and optimal eps finder.
Anomaly Detection
2 trainersIsolation Forest
mlcli train -m isolation_forestTree-based anomaly detection using isolation principle.
One-Class SVM
mlcli train -m one_class_svmNovelty detection using support vector methods.
Deep Learning
3 trainersDNN
mlcli train -m tf_dnnDeep Neural Network with customizable layers.
CNN
mlcli train -m tf_cnnConvolutional Neural Network for image-like data.
RNN
mlcli train -m tf_rnnRecurrent Neural Network for sequential data.
Using Trainers
Train a model using the --model or -m flag:
# 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 labelCreating Custom Trainers
You can create custom trainers by extending the BaseTrainer class:
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
passRegister your custom trainer with the model registry:
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 labelNext Steps
Learn more about specific trainers: