经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- // scalastyle:off println
- package org.apache.spark.examples.ml
- import org.apache.spark.sql.SQLContext
- import org.apache.spark.{SparkContext, SparkConf}
- // $example on$
- import org.apache.spark.ml.regression.AFTSurvivalRegression
- import org.apache.spark.mllib.linalg.Vectors
- // $example off$
- /**
- * An example for AFTSurvivalRegression.
- */
- object AFTSurvivalRegressionExample {
- def main(args: Array[String]): Unit = {
- val conf = new SparkConf().setAppName("AFTSurvivalRegressionExample")
- val sc = new SparkContext(conf)
- val sqlContext = new SQLContext(sc)
- // $example on$
- val training = sqlContext.createDataFrame(Seq(
- (1.218, 1.0, Vectors.dense(1.560, -0.605)),
- (2.949, 0.0, Vectors.dense(0.346, 2.158)),
- (3.627, 0.0, Vectors.dense(1.380, 0.231)),
- (0.273, 1.0, Vectors.dense(0.520, 1.151)),
- (4.199, 0.0, Vectors.dense(0.795, -0.226))
- )).toDF("label", "censor", "features")
- val quantileProbabilities = Array(0.3, 0.6)
- val aft = new AFTSurvivalRegression()
- .setQuantileProbabilities(quantileProbabilities)
- .setQuantilesCol("quantiles")
- val model = aft.fit(training)
- // Print the coefficients, intercept and scale parameter for AFT survival regression
- println(s"Coefficients: ${model.coefficients} Intercept: " +
- s"${model.intercept} Scale: ${model.scale}")
- model.transform(training).show(false)
- // $example off$
- sc.stop()
- }
- }
- // scalastyle:off println
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|