[英]pyspark paramether type of MultilayerPerceptronClassifier
我需要在python中使用spark,並且需要執行二進制分類。 經過一些研究(我是新來的火花)我找到了 MultilayerPerceptronClassifier 但我不明白一些事情。
巫婆類型的類型必須是 labelCol 和 featuresCol? 可以是一個簡單的整數(0 或 1)和一個向量(VectorAssembler 的輸出)?
PySpark 獲取您的特征列並生成包含特征向量的單個列。 標簽列是目標變量,在您的情況下是二進制的。
這是向量匯編程序如何工作的示例。
from pyspark.ml.feature import VectorAssembler
# Input data frame consists of four columns id, hour, mobile, clicked.
dataset = spark.createDataFrame(
[(0, 18, 1.0, , 1.0)],
["id", "hour", "mobile", "clicked"])
# We take the first two features hour and mobile and create a vector of features.
# This column is named "features".
assembler = VectorAssembler(
inputCols=["hour", "mobile"],
outputCol="features")
# We use the VectorAssembler assembler to transform our dataset into an
# "data" data frame which is the same as dataset but with an additional column
# "features.
data = assembler.transform(dataset)
在此步驟之后,您可以應用您的預測模型。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.