Module Expr Str Print NameLoad Import alias identifier Import alias identifier ImportFrom alias Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num Assign NameStore Call AttributeLoad NameLoad attr BinOpSub BinOpMult Num Call AttributeLoad NameLoad attr Num Num Num keyword Num Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr ListLoad BinOpMult AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr BinOpMult AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr attr AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice BinOpSub Num Call AttributeLoad NameLoad attr Num Num Assign NameStore Call NameLoad keyword Num Assign NameStore Call NameLoad keyword Num Assign NameStore Call NameLoad keyword Num Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Num Num Num ExtSlice Slice Index AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assign NameStore Num Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Index Num SubscriptLoad NameLoad ExtSlice Slice Index Num keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Index Num SubscriptLoad NameLoad ExtSlice Slice Index Num keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Index Num SubscriptLoad NameLoad ExtSlice Slice Index Num keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Index Num SubscriptLoad NameLoad ExtSlice Slice Index Num keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr ListLoad Num Num Expr Call AttributeLoad NameLoad attr ListLoad Num Num Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr
N/A N/A 
===================================================================
Multi-output Decision Tree Regression
===================================================================

An example to illustrate multi-output regression with decision tree.

The :ref:`decision trees <tree>`
is used to predict simultaneously the noisy x and y observations of a circle
given a single underlying feature. As a result, it learns local linear
regressions approximating the circle.

We can see that if the maximum depth of the tree (controlled by the
`max_depth` parameter) is set too high, the decision trees learn too fine
details of the training data and learn from the noise, i.e. they overfit.
 N/A __doc__ N/A numpy np N/A matplotlib.pyplot plt sklearn.tree DecisionTreeRegressor N/A rng N/A N/A N/A np random RandomState 1 N/A X N/A N/A np sort N/A N/A 200 N/A N/A rng rand 100 1 100 axis 0 N/A y N/A N/A N/A np array N/A N/A N/A np pi N/A N/A N/A N/A np sin X ravel N/A N/A np pi N/A N/A N/A N/A np cos X ravel T N/A N/A y N/A N/A 5 N/A N/A 0.5 N/A N/A rng rand 20 2 N/A regr_1 N/A DecisionTreeRegressor max_depth 2 N/A regr_2 N/A DecisionTreeRegressor max_depth 5 N/A regr_3 N/A DecisionTreeRegressor max_depth 8 N/A N/A N/A regr_1 fit X y N/A N/A N/A regr_2 fit X y N/A N/A N/A regr_3 fit X y N/A X_test N/A N/A N/A np arange -100.0 100.0 0.01 N/A N/A N/A N/A np newaxis N/A y_1 N/A N/A regr_1 predict X_test N/A y_2 N/A N/A regr_2 predict X_test N/A y_3 N/A N/A regr_3 predict X_test N/A N/A N/A plt figure N/A s 50 N/A N/A N/A plt scatter N/A y N/A N/A N/A 0 N/A y N/A N/A N/A 1 c navy s s label data N/A N/A N/A plt scatter N/A y_1 N/A N/A N/A 0 N/A y_1 N/A N/A N/A 1 c cornflowerblue s s label max_depth=2 N/A N/A N/A plt scatter N/A y_2 N/A N/A N/A 0 N/A y_2 N/A N/A N/A 1 c c s s label max_depth=5 N/A N/A N/A plt scatter N/A y_3 N/A N/A N/A 0 N/A y_3 N/A N/A N/A 1 c orange s s label max_depth=8 N/A N/A N/A plt xlim N/A -6 6 N/A N/A N/A plt ylim N/A -6 6 N/A N/A N/A plt xlabel target 1 N/A N/A N/A plt ylabel target 2 N/A N/A N/A plt title Multi-output Decision Tree Regression N/A N/A N/A plt legend N/A N/A N/A plt show