[英]Apache Spark MLLib get maximum value
I have the following model: 我有以下模型:
case class Product(price:Int,distance:Int)
and I have data that tells me if a customer is willing to buy the product for price x if distance is y (true/false). 并且我有数据告诉我,如果距离为y(是/否),那么客户是否愿意以价格x购买产品。
I used a logistic regression in spark on it and can now predict (price,distance) pairs. 我对它进行了逻辑回归,现在可以预测(价格,距离)对。 What if I now want to know the maximum price I can charge for distance x? 如果我现在想知道距离x可以收取的最高价格怎么办?
code: 码:
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)
To know the maximum price for a given distance X. 知道给定距离X的最高价格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.