- 阅读权限
- 255
- 威望
- 1 级
- 论坛币
- 49635 个
- 通用积分
- 55.6937
- 学术水平
- 370 点
- 热心指数
- 273 点
- 信用等级
- 335 点
- 经验
- 57805 点
- 帖子
- 4005
- 精华
- 21
- 在线时间
- 582 小时
- 注册时间
- 2005-5-8
- 最后登录
- 2023-11-26
已卖:4897份资源
学术权威
还不是VIP/贵宾
TA的文库 其他... R资源总汇
Panel Data Analysis
Experimental Design
- 威望
- 1 级
- 论坛币
 - 49635 个
- 通用积分
- 55.6937
- 学术水平
- 370 点
- 热心指数
- 273 点
- 信用等级
- 335 点
- 经验
- 57805 点
- 帖子
- 4005
- 精华
- 21
- 在线时间
- 582 小时
- 注册时间
- 2005-5-8
- 最后登录
- 2023-11-26
 | 开心 2017-10-21 10:25:33 |
|---|
签到天数: 1 天 连续签到: 1 天 [LV.1]初来乍到
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- /**
- * An example for Multilayer Perceptron Classification.
- */
- object MultilayerPerceptronClassifierExample {
- def main(args: Array[String]): Unit = {
- val conf = new SparkConf().setAppName("MultilayerPerceptronClassifierExample")
- val sc = new SparkContext(conf)
- val sqlContext = new SQLContext(sc)
- // $example on$
- // Load the data stored in LIBSVM format as a DataFrame.
- val data = sqlContext.read.format("libsvm")
- .load("data/mllib/sample_multiclass_classification_data.txt")
- // Split the data into train and test
- val splits = data.randomSplit(Array(0.6, 0.4), seed = 1234L)
- val train = splits(0)
- val test = splits(1)
- // specify layers for the neural network:
- // input layer of size 4 (features), two intermediate of size 5 and 4
- // and output of size 3 (classes)
- val layers = Array[Int](4, 5, 4, 3)
- // create the trainer and set its parameters
- val trainer = new MultilayerPerceptronClassifier()
- .setLayers(layers)
- .setBlockSize(128)
- .setSeed(1234L)
- .setMaxIter(100)
- // train the model
- val model = trainer.fit(train)
- // compute precision on the test set
- val result = model.transform(test)
- val predictionAndLabels = result.select("prediction", "label")
- val evaluator = new MulticlassClassificationEvaluator()
- .setMetricName("precision")
- println("Precision:" + evaluator.evaluate(predictionAndLabels))
- // $example off$
- sc.stop()
- }
- }
- // scalastyle:off println
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
|