Choosing an estimator#
Start from the task. Each row names the estimators to try first and links the guide page for that family.
Every estimator follows the scikit-learn conventions: construct it with hyperparameters, then call fit,
predict, predict_proba, transform or score. Inputs are float32 arrays.
Task |
Try first |
Also available |
Guide |
|---|---|---|---|
Classify rows of tabular data |
|
|
|
Classify into more than two classes with boosting |
|
||
Predict a number |
|||
Rank items within groups |
|
|
|
Fit an interpretable linear model |
|||
Predict with an uncertainty estimate |
|||
Group similar rows |
|||
Reduce the number of features |
|||
Draw a 2-D map of the data |
|||
Find the nearest rows exactly |
|||
Search millions of vectors quickly |
|||
Flag unusual rows |
|||
Forecast a series |
|||
Split a series into trend and season |
|||
Scale, encode or impute features |
|||
Keep the most useful features |
|||
Score a model with cross-validation |
|||
Build or run neural network layers |
|||
Train or run a language model |
A first pass on tabular data#
When you are unsure, fit one tree ensemble and one linear model and compare their scores on held-out rows:
import numpy as np
import mojolearn
rng = np.random.default_rng(0)
X = rng.random((10_000, 20), dtype=np.float32)
y = (X[:, 0] + X[:, 1] > 1.0).astype(np.int64)
X_train, X_test, y_train, y_test = X[:8_000], X[8_000:], y[:8_000], y[8_000:]
forest = mojolearn.RandomForestClassifier(n_estimators=100).fit(X_train, y_train)
linear = mojolearn.LogisticRegression().fit(X_train, y_train)
print(forest.score(X_test, y_test), linear.score(X_test, y_test))
Devices and numeric modes#
In identical mode, mojolearn returns the same bits on Apple, NVIDIA and AMD GPUs. identical is the
default, so every example in these guides runs in it without extra settings. On Apple GPUs you can
choose fast instead, which is tuned for speed and does not promise identical bits:
mojolearn.set_numeric_mode("fast")
See Numeric modes and Devices and the CPU.