Created
August 27, 2020 10:42
-
-
Save willprice76/eab80ac67c5c01bf29ad055c5bda6c9b to your computer and use it in GitHub Desktop.
controller endpoint to train sentiment model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@PostMapping("/sentiment/train") | |
public String train(@RequestBody List<TextData> data) throws IOException { | |
Instant start = Instant.now(); | |
Dataset<Row> input = spark.createDataFrame(data, TextData.class); | |
LOG.debug("Running training with {} rows of text data", data.size()); | |
Pipeline pipeline = getSentimentTrainingPipeline(); | |
PipelineModel newPipelineModel = pipeline.fit(input); | |
long trainingTime = Duration.between(start, Instant.now()).toMillis(); | |
//Overwrite the existing scoring pipeline | |
scoringPipeline = new LightPipeline(newPipelineModel, false); | |
return String.format("Training completed in %s milliseconds", trainingTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment