-
Notifications
You must be signed in to change notification settings - Fork 74
Model Training
Yin Lou edited this page Apr 5, 2016
·
3 revisions
All learning algorithms in MLTK inherits mltk.predictor.Learner
class. To build models from command line, use the following command (using LassoLearner
as example):
$ java mltk.predictor.glm.LassoLearner
It should output a message like this:
Usage: mltk.predictor.glm.LassoLearner
-t train set path
[-g] task between classification (c) and regression (r) (default: r)
[-r] attribute file path
[-o] output model path
[-V] verbose (default: true)
[-m] maximum num of iterations (default: 0)
[-l] lambda (default: 0)
Using LassoLearner
as example, the following code builds a L1-regularized classification model:
LassoLearner learner = new LassoLearner();
learner.setTask(Task.CLASSIFICATION);
learner.setLambda(0.01);
learner.setMaxNumIters(100);
GLM glm = learner.build(trainSet);
It is recommended to use build
method to train the model since it is the most flexible method and other meta learning algorithms such as BaggedEnsembleLearner
will call this method to build models. Some learning algorithms will have other public methods for training to avoid pre-setting all parameters. For example, the following code does the same thing:
LassoLearner learner = new LassoLearner();
GLM glm = learner.buildClassifier(trainSet, 100, 0.01);