package org.jeecg.yw.spark

import org.apache.spark.ml.PipelineModel
import org.apache.spark.sql.SparkSession

object test {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .appName("Weather Temperature Prediction")
      .master("local[*]")
      .getOrCreate()

    // 加载模型
    val model = PipelineModel.load("hdfs://192.168.192.100:8020/Model")

    val newData = spark.createDataFrame(Seq(
      (5.0, 3.0, 2.0, 4.0)
    )).toDF("绿叶蔬菜", "水果", "大豆制品", "新鲜肉类")

    // 使用模型进行预测
    val predictions = model.transform(newData)
    predictions.select("prediction").show()

    spark.stop()
  }
}
