- 阅读权限
- 255
- 威望
- 1 级
- 论坛币
- 49655 个
- 通用积分
- 55.9937
- 学术水平
- 370 点
- 热心指数
- 273 点
- 信用等级
- 335 点
- 经验
- 57805 点
- 帖子
- 4005
- 精华
- 21
- 在线时间
- 582 小时
- 注册时间
- 2005-5-8
- 最后登录
- 2023-11-26
已卖:4900份资源
学术权威
还不是VIP/贵宾
TA的文库 其他... R资源总汇
Panel Data Analysis
Experimental Design
- 威望
- 1 级
- 论坛币
 - 49655 个
- 通用积分
- 55.9937
- 学术水平
- 370 点
- 热心指数
- 273 点
- 信用等级
- 335 点
- 经验
- 57805 点
- 帖子
- 4005
- 精华
- 21
- 在线时间
- 582 小时
- 注册时间
- 2005-5-8
- 最后登录
- 2023-11-26
 | 开心 2017-10-21 10:25:33 |
|---|
签到天数: 1 天 连续签到: 1 天 [LV.1]初来乍到
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- from __future__ import print_function
- from pyspark import SparkContext
- from pyspark.sql import SQLContext
- # $example on$
- from pyspark.ml.classification import MultilayerPerceptronClassifier
- from pyspark.ml.evaluation import MulticlassClassificationEvaluator
- # $example off$
- if __name__ == "__main__":
- sc = SparkContext(appName="multilayer_perceptron_classification_example")
- sqlContext = SQLContext(sc)
- # $example on$
- # Load training data
- data = sqlContext.read.format("libsvm")\
- .load("data/mllib/sample_multiclass_classification_data.txt")
- # Split the data into train and test
- splits = data.randomSplit([0.6, 0.4], 1234)
- train = splits[0]
- 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)
- layers = [4, 5, 4, 3]
- # create the trainer and set its parameters
- trainer = MultilayerPerceptronClassifier(maxIter=100, layers=layers, blockSize=128, seed=1234)
- # train the model
- model = trainer.fit(train)
- # compute precision on the test set
- result = model.transform(test)
- predictionAndLabels = result.select("prediction", "label")
- evaluator = MulticlassClassificationEvaluator(metricName="precision")
- print("Precision:" + str(evaluator.evaluate(predictionAndLabels)))
- # $example off$
- sc.stop()
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
|