Most estimators have the ability to be trained with data. These estimators are called Learners and require training before they are can make predictions. Training is the process of feeding data to the learner so that it can form a generalized internal function that maps future unknown samples to good predictions.
Train a Learner#
To train a learner pass a training dataset to the
public train(Dataset $training) : void
Note: Calling the
train()method on an already trained learner will erase its previous training. If you would like to train a model incrementally, you can do so with learners implementing the Online interface.
Is the Learner Trained?#
Return whether or not the learner has been trained:
public trained() : bool
Predict a Single Sample#
Pass a single sample and return the prediction:
public predictSample(array $sample) : mixed
use Rubix\ML\Datasets\Unlabeled; // Import samples $dataset = new Unlabeled($samples); $prediction = $estimator->predictSample($dataset->sample(2)); // Predict the third sample in the dataset var_dump($prediction);