我有以下型号:
case class Product(price:Int,distance:Int)
我有数据告诉我,如果距离是y(真/假),客户是否愿意以x的价格购买产品。
我在火花上使用了逻辑回归,现在可以预测(价格,距离)对。如果我现在想知道距离x可以收取的最高价格怎么办?
代码:
val products:List[(Product,Double)] = getProductVotes()
val points:List[LabeledPoints] = products.map{ case (product,vote) =>
LabeledPoint(vote,Vectors.dense(product.price,product.distance)) }
val data: RDD[LabeledPoint] = sc.parallelize(points)
val splits = data.randomSplit(Array(0.6, 0.4), seed = 11L)
val training = splits(0).cache()
val test = splits(1).cache()
val model = new LogisticRegressionWithLBFGS()
.setNumClasses(10)
.run(training)
答案 0 :(得分:0)
知道给定距离X的最高价格。