LinearModel is datatable’s general-purpose linear model. It supports linear regression, binomial classification, and multinomial classification, all trained with parallel stochastic gradient descent (SGD). Both .fit() and .predict() are fully parallel.
Creating a LinearModel
LinearModel lives in datatable.models:
Hyperparameters
| Parameter | Default | Description |
|---|---|---|
eta0 | 0.005 | Initial learning rate. Must be positive. |
eta_decay | 0.0001 | Decay factor for "time-based" and "step-based" schedules. |
eta_drop_rate | 10.0 | Drop rate for the "step-based" schedule. |
eta_schedule | "constant" | Learning rate schedule: "constant", "time-based", "step-based", or "exponential". |
lambda1 | 0.0 | L1 regularization. Non-negative. |
lambda2 | 0.0 | L2 regularization. Non-negative. |
nepochs | 1 | Training epochs. Fractional values train on a partial final pass. |
model_type | "auto" | "auto", "binomial", "multinomial", or "regression". |
negative_class | False | Create a “negative” class for multinomial classification. |
seed | 0 | Seed for quasi-random data shuffling. 0 disables shuffling. |
double_precision | False | Use float64 internally (doubles memory use). |
Learning Rate Schedules
Wheneta_schedule is not "constant", the learning rate eta is updated after each training iteration:
| Schedule | Update rule |
|---|---|
"constant" | eta = eta0 |
"time-based" | eta = eta0 / (1 + eta_decay * epoch) |
"step-based" | eta = eta0 * eta_decay ^ floor((1 + epoch) / eta_drop_rate) |
"exponential" | eta = eta0 / exp(eta_decay * epoch) |
Training
X_train is a Frame of shape (nrows, ncols) and y_train a Frame of shape (nrows, 1). The model_type is inferred from the target column dtype when set to "auto".
Early Stopping
Predicting
Frame of shape (X_test.nrows, nlabels) with predicted values or probabilities. The test frame must have the same number of columns as the training frame.
Checking Model Status
Resetting the Model
Complete Examples
- Regression
- Binary classification
When to Use LinearModel
Good fit
- Regression tasks with numeric targets
- Binary or multinomial classification with linearly separable data
- When you need an interpretable, coefficient-based model
- Large datasets where batch methods are too slow
Consider alternatives
- Non-linear relationships in data (tree-based methods may work better)
- Very high-dimensional sparse text/categorical data (consider FTRL instead)
- Tasks that require probability calibration out of the box