Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.25 KB

learner.md

File metadata and controls

56 lines (40 loc) · 1.25 KB

Learner

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 it a training dataset:

public train(Dataset $training) : void

Example

$estimator->train($dataset);

Note: Calling the train() method on an already trained learner will erase the previous training. If you would like to train a model incrementally, refer to the Online interface.

Is the Learner Trained?

Return whether or not the learner has been trained:

public trained() : bool

Example

var_dump($estimator->trained());
bool(true)

Predict a Single Sample

Predict a single sample and return the result:

public predictSample(array $sample) : mixed

Example

use Rubix\ML\Datasets\Unlabeled;

// Import samples

$dataset = new Unlabeled($samples);

$prediction = $estimator->predictSample($dataset[2]); // Predict the third sample in dataset

var_dump($prediction);
string(3) "cat"