Using `DecisionTreeRegressor`. It handles the recursive splitting for you.
from sklearn.tree import DecisionTreeRegressor
# 1. Create Model
# random_state=0 ensures same results every time
model = DecisionTreeRegressor(random_state=0)
# 2. Train (Fit)
# It finds the best splits automatically
model.fit(X, y)
# 3. Predict new value
pred = model.predict([[6.5]])
print(pred)
# Output: [0.25] (Average of leaf node)