Skip to content

Instantly share code, notes, and snippets.

@groverpr
Created December 8, 2017 03:19
Show Gist options
  • Select an option

  • Save groverpr/5e9d371a29687859adba31ee7e2cc159 to your computer and use it in GitHub Desktop.

Select an option

Save groverpr/5e9d371a29687859adba31ee7e2cc159 to your computer and use it in GitHub Desktop.
code to find best split based on standard error
xi = x # initialization of input
yi = y # initialization of target
# x,y --> use where no need to change original y
ei = 0 # initialization of error
n = len(yi) # number of rows
predf = 0 # initial prediction 0
for i in range(30): # loop will make 30 trees (n_estimators).
tree = DecisionTree(xi,yi) # DecisionTree scratch code can be found in shared github/kaggle link.
# It just create a single decision tree with provided min. sample leaf
tree.find_better_split(0) # For selected input variable, this splits (<n and >n) data so that std. deviation of
# target variable in both splits is minimum as compared to all other splits
r = np.where(xi == tree.split)[0][0] # finds index where this best split occurs
left_idx = np.where(xi <= tree.split)[0] # index lhs of split
right_idx = np.where(xi > tree.split)[0] # index rhs of split
@Sandipan904

Copy link
Copy Markdown

Which decion tree library is used.I am confused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment