倒小叮 发表于 2020-5-26 15:06:04

代码报错不知道怎么修改

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values

# Encoding categorical data
# Encoding the Independent Variable
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X = LabelEncoder()
X[:, 0] = labelencoder_X.fit_transform(X[:, 0])
onehotencoder = OneHotEncoder(categorical_features = )
X = onehotencoder.fit_transform(X).toarray()
# Encoding the Dependent Variable
labelencoder_y = LabelEncoder()
y = labelencoder_y.fit_transform(y)


是对分类数据进行编码,但是我一运行就会报错:__init__() got an unexpected keyword argument 'categorical_features'
我大概知道是这个函数可能更新了,现在没有 'categorical_features'了,但是不知道怎么改,在spyder里我怎么查看这个函数怎么用呢?

qiuyouzhi 发表于 2020-5-26 15:08:38

没用过spyder,你试试Ctrl+鼠标左键点击那个函数?
或许会跳转到函数定义位置,你可以看看参数

倒小叮 发表于 2020-5-26 17:10:28

qiuyouzhi 发表于 2020-5-26 15:08
没用过spyder,你试试Ctrl+鼠标左键点击那个函数?
或许会跳转到函数定义位置,你可以看看参数

好呢
页: [1]
查看完整版本: 代码报错不知道怎么修改