// Create our one hot encoder
val oneHotEncoder = OneHotEncoder(shape = NodeShape.vector(1, 2,
inputCol = "a_string_index",
outputCol = "a_string_oh"),
model = OneHotEncoderModel(2, dropLast = false))
// Assemble some features together for use
// By our linear regression
val featureAssembler = VectorAssembler(
shape = NodeShape().withInput("input0", "a_string_oh").
model = VectorAssemblerModel(Seq(TensorShape(2), ScalarShape())))
// Create our linear regression
// It has two coefficients, as the one hot encoder
// Outputs vectors of size 2
val linearRegression = LinearRegression(shape = NodeShape.regression(3),
model = LinearRegressionModel(Vectors.dense(2.0, 3.0, 6.0), 23.5))
// Create a pipeline from all of our transformers
val pipeline = Pipeline(
// Transform our leap frame using the pipeline
val predictions = (for(lf <- pipeline.transform(leapFrame);
lf2 <- lf.select("prediction")) yield {
lf2.dataset.map(_.getDouble(0))
}).get.toSeq
// Print our predictions
// > 365.70000000000005
println(predictions.mkString("\n"))