小编nvs*_*ash的帖子

错误:AttributeError:'DataFrame' 对象没有属性 '_jdf'

我想使用 pyspark 执行 k 折交叉验证来微调参数,我正在使用 pyspark.ml。我收到属性错误。

AttributeError: 'DataFrame' 对象没有属性 '_jdf'

我最初尝试使用 pyspark.mllib 但未能成功执行 k 折交叉验证

import pandas as pd
from pyspark import SparkConf, SparkContext
from pyspark.ml.classification import DecisionTreeClassifier

data=pd.read_csv("file:///SparkCourse/wdbc.csv", header=None)
type(data)
print(data)

conf = SparkConf().setMaster("local").setAppName("SparkDecisionTree")
sc = SparkContext(conf = conf)

# Create initial Decision Tree Model
dt = DecisionTreeClassifier(labelCol="label", featuresCol="features", 
maxDepth=3)

# Train model with Training Data
dtModel = dt.fit(data)

# I expect the model to be trained but I'm getting the following error 
AttributeError: 'DataFrame' object has no attribute …
Run Code Online (Sandbox Code Playgroud)

pyspark

13
推荐指数
1
解决办法
8629
查看次数

标签 统计

pyspark ×1