Когда я использовал Onehotencoder
ошибка в python 3.7, появляется следующая ошибка. Пожалуйста, дайте решение.
# -*- coding: utf-8 -*-
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('dataset.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X = LabelEncoder()
X[:, 3] = labelencoder_X.fit_transform(X[:, 3])
onehotencoder = OneHotEncoder(categories=X[3])
X = onehotencoder.fit_transform(X)
Я получаю такую ошибку
Traceback (most recent call last):
File "<ipython-input-81-a28c69982fc5>", line 15, in <module>
X = onehotencoder.fit_transform(X).values.reshape(-1,1)
File "C:\Users\HP\anaconda3\lib\site-packages\sklearn\preprocessing\_encoders.py", line 372, in fit_transform
return super().fit_transform(X, y)
File "C:\Users\HP\anaconda3\lib\site-packages\sklearn\base.py", line 571, in fit_transform
return self.fit(X, **fit_params).transform(X)
File "C:\Users\HP\anaconda3\lib\site-packages\sklearn\preprocessing\_encoders.py", line 347, in fit
self._fit(X, handle_unknown=self.handle_unknown)
File "C:\Users\HP\anaconda3\lib\site-packages\sklearn\preprocessing\_encoders.py", line 76, in _fit
if self.categories != 'auto':
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()