本文整理汇总了Python中pyspark.sql.Row.fromSeq方法的典型用法代码示例。如果您正苦于以下问题:Python Row.fromSeq方法的具体用法?Python Row.fromSeq怎么用?Python Row.fromSeq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyspark.sql.Row
的用法示例。
在下文中一共展示了Row.fromSeq方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StructField
# 需要导入模块: from pyspark.sql import Row [as 别名]
# 或者: from pyspark.sql.Row import fromSeq [as 别名]
StructField("pix6",DoubleType(),True),
StructField("pix7",DoubleType(),True),
StructField("pix8",DoubleType(),True),
StructField("pix9",DoubleType(),True),
StructField("pix10",DoubleType(),True),
StructField("pix11",DoubleType(),True),
StructField("pix12",DoubleType(),True),
StructField("pix13",DoubleType(),True),
StructField("pix14",DoubleType(),True),
StructField("pix15",DoubleType(),True),
StructField("pix16",DoubleType(),True),
StructField("label",DoubleType(),True)
])
pen_raw = sc.textFile("first-edition/ch08/penbased.dat", 4).map(lambda x: x.split(", ")).map(lambda row: [float(x) for x in row])
dfpen = sqlContext.createDataFrame(pen_raw.map(Row.fromSeq(_)), penschema)
def parseRow(row):
d = {("pix"+str(i)): row[i-1] for i in range(1,17)}
d.update({"label": row[16]})
return d
dfpen = sqlContext.createDataFrame(pen_raw.map(parseRow), penschema)
va = VectorAssembler(outputCol="features", inputCols=dfpen.columns[0:-1])
penlpoints = va.transform(dfpen).select("features", "label")
pensets = penlpoints.randomSplit([0.8, 0.2])
pentrain = pensets[0].cache()
penvalid = pensets[1].cache()
penlr = LogisticRegression(regParam=0.01)