当前位置: 首页>>代码示例>>Python>>正文


Python Row.fromSeq方法代码示例

本文整理汇总了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)
开发者ID:AkiraKane,项目名称:first-edition,代码行数:32,代码来源:ch08-listings.py


注:本文中的pyspark.sql.Row.fromSeq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。