TrainedLearner¶
- class nimble.core.interfaces.TrainedLearner¶
Returned by nimble.train to access the learner trained model.
Provides methods for interfacing with the trained model including methods for applying, testing and accessing cross-validation results and other learned attributes.
See also
Examples
>>> lst = [[1, 0, 1], [0, 1, 2], [0, 0, 3], [1, 1, 4]] * 10 >>> lstTest = [[1, 0, 1], [0, -1, 2], [0, 1, 2], [1, 1, 4]] >>> ftNames = ['a', 'b' , 'label'] >>> trainData = nimble.data(lst, featureNames=ftNames) >>> testData = nimble.data(lstTest, featureNames=ftNames) >>> tl = nimble.train('nimble.KNNClassifier', trainX=trainData, ... trainY='label') >>> tl.apply(testX=testData[:, :'b']) <Matrix 4pt x 1ft label ┌────── 0 │ 1 1 │ 3 2 │ 2 3 │ 4 > >>> tl.test(testX=testData, testY='label', ... performanceFunction=nimble.calculate.fractionIncorrect) 0.25
Attributes
The original arguments passed to the learner.
The name of the learner used for training.
The type of learner that has been trained.
Identifier for this object within the log.
The random seed used for the learner.
Tuning object storing validation results.
Methods
apply
(testX[, arguments, scoreMode, useLog])Apply the learner to the test data.
The attributes associated with this learner.
getScores
(testX[, arguments])The scores for all labels for each data point.
incrementalTrain
(trainX[, trainY, ...])Extend the training of this learner with additional data.
retrain
(trainX[, trainY, arguments, ...])Train the model on new data.
save
(outputPath)Save model to a file.
test
(performanceFunction, testX[, testY, ...])Evaluate the performance of the trained learner.