use of org.tribuo.regression.sgd.linear.LinearSGDTrainer in project ml-commons by opensearch-project.
the class LinearRegression method train.
@Override
public Model train(DataFrame dataFrame) {
MutableDataset<Regressor> trainDataset = TribuoUtil.generateDatasetWithTarget(dataFrame, new RegressionFactory(), "Linear regression training data from opensearch", TribuoOutputType.REGRESSOR, parameters.getTarget());
Integer epochs = Optional.ofNullable(parameters.getEpochs()).orElse(DEFAULT_EPOCHS);
LinearSGDTrainer linearSGDTrainer = new LinearSGDTrainer(objective, optimiser, epochs, DEFAULT_INTERVAL, DEFAULT_BATCH_SIZE, seed);
org.tribuo.Model<Regressor> regressionModel = linearSGDTrainer.train(trainDataset);
Model model = new Model();
model.setName(FunctionName.LINEAR_REGRESSION.name());
model.setVersion(1);
model.setContent(ModelSerDeSer.serialize(regressionModel));
return model;
}
Aggregations