Q2

H.E.L.P.

File "C:\Users\COMPAQ\Anaconda3\lib\site-packages\sklearn\tree\tree.py", line 236, in fit "number of samples=%d" % (len(y), n_samples))

ValueError: Number of labels=100 does not match number of samples=400

why am i getting this error. i have only 100 samples. why its talkin bout 400 samples?:(

import pandas as pd

import numpy as np

d= pd.read_csv("dataset100.csv")

x = d.drop(['SampleNo','Y','x4','x6'], axis=1).values.reshape(-1, 1)  
y = d['Y'].values.reshape(-1, 1)  

from sklearn.tree import DecisionTreeRegressor
tree_reg = DecisionTreeRegressor()  
tree_reg.fit(x,y)

tree_reg.predict([[5.5]])
x_ = np.arange(min(x),max(x),0.01).reshape(-1,1)
y_head = tree_reg.predict(x_)

0 Answers