Search in sources :

Example 1 with LinearSGDTrainer

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;
}
Also used : LinearSGDTrainer(org.tribuo.regression.sgd.linear.LinearSGDTrainer) RegressionFactory(org.tribuo.regression.RegressionFactory) Model(org.opensearch.ml.common.parameter.Model) Regressor(org.tribuo.regression.Regressor)

Aggregations

Model (org.opensearch.ml.common.parameter.Model)1 RegressionFactory (org.tribuo.regression.RegressionFactory)1 Regressor (org.tribuo.regression.Regressor)1 LinearSGDTrainer (org.tribuo.regression.sgd.linear.LinearSGDTrainer)1