标签:basic tap col ons ssi tmp port nbsp collect
from pyspark import SparkContext
from pyspark import SparkConf
from pyspark.mllib.regression import LabeledPoint
from pyspark.mllib.tree import GradientBoostedTrees
string_test = ‘pyspark_test‘
conf = SparkConf().setAppName(string_test).setMaster(‘yarn‘)
sc = SparkContext(conf=conf)
hdfs_data = sc.textFile("hdfs://dap/basicdata/dianzhang/phoenix/tmp_dianzhang_train_type/ds=2018-04-15/type=R1_C1/000000_0")
a = hdfs_data.map(lambda x:x.split(‘\t‘))
b = a.map(lambda x:LabeledPoint(x.pop(-1), x[3:]))
‘‘‘
弯路
c = b.collect()
model = GradientBoostedTrees.trainClassifier(sc.parallelize(c), {}, numIterations=10)
‘‘‘
model = GradientBoostedTrees.trainClassifier(b, {}, numIterations=10)
标签:basic tap col ons ssi tmp port nbsp collect
原文地址:https://www.cnblogs.com/kayy/p/8868500.html