Model Api
fit!
fit!(model, X)
;fit!(model, X, y)
Trains
model
on the input dataX
andy
(for supervised learning) or on justX
(for unsupervised learning). Themodel
object is always returned, allowing code likeclassifier = fit!(LogisticRegression(), X, y)
partial_fit!
partial_fit!(model, X)
;partial_fit!(model, X, y)
Incrementally trains model on the new data
X
andy
. For instance, this might perform a stochastic gradient descent step.
predict
predict(model, X)
returns the predicted class of each row inX
(for classifiers) or the predicted value (for regressors).
predict_proba
predict_proba(model, X)
returns an(N, C)
matrix containing the probability that the nth sample belongs to the cth class. Callget_classes(model)
to get the ordering of the classes.
predictlogproba
predict_log_proba(model, X)
is equivalent tolog(predict_proba(model, X))
but can be more accurate (for small probabilities) and faster (avoiding the exponential).
transform
For unsupervised learning models and for preprocessing,
transform(model, X)
applies the transformation frommodel
toX
, and returns a similar array (same number of rows, possibly different number of columns).
get_components
For unsupervised learning models,
get_components(model)
returns the matrix of the latent space, in (ncomponents, nfeatures) form. For matrix factorization methods, this corresponds to the principal components or latent vectors.
fit_transform!
fit_transform!(model, X)
is equivalent totransform(fit!(model, X), X)
but can sometimes be more efficient.
fit_predict!
fit_predict!(model, X)
is equivalent topredict(fit!(model, X), X)
but can sometimes be more efficient.
inverse_transform
inverse_transform(model, X)
applies the inverse of the model transformation.
score_samples
For probabilistic models,
score_samples(model, X)
evaluates the density model on X.
score
score(model, X)
andscore(model, X, y)
assign a score to how likelyX
ory|X
is given the learned model parameters. The higher this score is, the better the model. This is used for cross-validation.
decision_function
decision_function(model, X)
returns the distance of the samples to the decision boundary.
Model Internals
clone(model)
returns a new object of the same type as model, with the same hyperparameters, but unfit.set_params!(model, param1=value1, param2=value2, ...)
changes the model hyperparameters.get_params(model)
returns all the model hyperparameters that can be changed withset_params!
is_classifier(model)
is true ifmodel
is a classifier.get_feature_names(model)
returns the name of the output featuresget_classes(model)
returns the label of each class