Coding a Decision Tree from Scratch in Python p.11: Regression from Scratch

preview_player
Показать описание
In this part of the series we are going to adjust our decision tree algorithm so that we can also use it to do a regression task. And in this video, we are going to implement the actual changes in the code.

Links:
Рекомендации по теме
Комментарии
Автор

Educational videos are so underrated in Youtube. Coz you definitely deserve much much more than this. Good job man!

sreenjaysen
Автор

Unfortunately, OBS recorded the text cursor in black even though it was white on my screen while I created the video. So, at times, it is a little bit difficult to see. I will try to fix the problem for the next video.

SebastianMantey
Автор

Hi Sebastian
I have a question, as I understand it, your random forest model code trains to receive the same data that was already there in the past, only with a deviation?, how can the Code changed to predict the Future, Not the past ?

metehan
Автор

Overall_metric might be used as np.inf against True/False with 1'st iteration. In my ipinion it looks clearer on an intuitive level.

hopelesssuprem
Автор

How to visualize decision tree by graphviz or any other visualization library? instead of using pprint(tree).

abdurrehmananwarqureshi
Автор

Hi Sebastian

Great job!

Listen, I tried your calculate_r_squared function () but there seems to be an error

Basicly, python does not like your statement grid_search = pd.DataFrame()

It's only when I set the grid_search name to df that the error vanishes, however then I have to set a loop for printing - in this case I write if max_depth = 6 then
print(df) and I get a list of 17 items.

[see below]

This is not very elegant but works after all.

Can you please explain explain why I get this error?

Many thanks

ViG

df = pd.DataFrame(grid_search)
df.sort_values("r_squared_val", ascending=False).head()

dfs = df.groupby('max_depth')

dfs_updated = [ ]

for _, df in dfs:
df['id'] = df.groupby(['max_depth', 'min_samples', 'r_squared_train', 'r_squared_val']).ngroup()+1
dfs_updated.append(df)
df_new = pd.concat(dfs_updated)
df_new

if max_depth == 6:
print(f"")
print(df_new)

vglez
visit shbcf.ru