Decision tree issue

my code has been working fine before defining the class. But after I try to print d.train this error is shown – "TypeError Traceback (most recent call last)
in ()
1 d = DecisionTree()
----> 2 d.train(data_cleaned)

in train(self, x_train)
17 self.val = x_train[self.fkey].mean()
18 print(“makin tree feature is”,self.fkey)
—> 19 data_left, data_right = divide_data(x_train, self.fkey, self.fval)
20 data_left = data_left.reset_index(drop = True)
21 data_right = data_right.reset_index(drop = True)

in divide_data(x_data, fkey, fval)
4 for i in range(x_data.shape[0]):
5 val = x_data[fkey].loc[i]
----> 6 if val > fval:
7 x_right = x_right.append(x_data.loc[i])
8 else:

TypeError: ‘>’ not supported between instances of ‘int’ and ‘NoneType’"

Hey sarthak,
I would suggest you to re check you code with what prateek bhaiya has written during the lecture
you can also see the code directly at github: cb.lk/ml18
If you are still not able to find the problem. Add your code on cb.lk/ide, I will have a look at it,

My code is the same and it is working well but only after defining the class i am having problems

This should not be the case :sweat_smile:
Then please share your code on cb.lk/ide

I have done that please have a look

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.