I'm new in python and ML. I wrote this code for practicing. It displays this error. how do I solve this reshape problem?
import pandas as pd
import sklearn as skl
data=pd.read_csv('housing.csv')
housing=data['ocean_proximity']
from sklearn.preprocessing import OneHotEncoder
encoder=OneHotEncoder()
housing_cat_fac=housing.factorize()
housing_final=encoder.fit_transform(housing_cat_fac.reshape(1,-1))
AttributeError Traceback (most recent call last)
<ipython-input-31-b13a23adc636> in <cell line: 9>()
7 encoder=OneHotEncoder()
8 housing_cat_fac=housing.factorize()
----> 9 housing_final=encoder.fit_transform(housing_cat_fac.reshape(1,-1))
AttributeError: 'tuple' object has no attribute 'reshape'
x.y
gives an attribute error, either you read the docs forx
class objects wrong, or (more likely)
x` isn't the class you expected. Withreshape
you probably expectedx
to be an array, not a tuple. Either way you need to reread the relevant docs.