I try to fit the iris dataset with this Perceptron class but I got an error in fitting Jupyter notebook snapshot
for the .ipynb file: https://mega.nz/file/m25R2QZb#21OKd7DTASEmOymuFcOiOQwZaf8fhMzHLeQc8XzyKUI
Anybody know how to avoid this error, thanks for replying .
CodePudding user response:
In your code, you give the DataFrame x to the fit function. If you check closely, the first zipped item in the loop for xi, target in zip(X, y):
is the column names, not the first data item. You can check that by printing xi in the loop.
So what you want to do is convert your data to an array beforehand:
x=np.array(df.iloc[0:100 , [0,2]])
or alternatively what you did for the targets y as well, use only the values of the DataFrame:
x=df.iloc[0:100 , [0,2]].values