<s> max_depth_array = np . arange ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> train_error = np . zeros ( len ( max_depth_array ) ) <EOL> cv_error = np . zeros ( len ( max_depth_array ) ) <EOL> for i , max_depth in enumerate ( max_depth_array ) : <EOL> print '<STR_LIT>' % ( max_depth , max_depth_array [ - <NUM_LIT:1> ] ) <EOL> clf = DecisionTreeRegressor ( max_depth = max_depth ) <EOL> clf . fit ( X_train , y_train ) <EOL> y_train_pred = clf . predict ( X_train ) <EOL> y_cv_pred = clf . predict ( X_cv ) <EOL> train_error [ i ] = compute_outlier_fraction ( y_train_pred , y_train ) <EOL> cv_error [ i ] = compute_outlier_fraction ( y_cv_pred , y_cv ) <EOL> pl . figure ( ) <EOL> pl . plot ( max_depth_array , cv_error , label = '<STR_LIT>' ) <EOL> pl . plot ( max_depth_array , train_error , label = '<STR_LIT>' ) <EOL> pl . legend ( loc = <NUM_LIT:0> ) <EOL> pl . xlabel ( '<STR_LIT>' ) <EOL> pl . ylabel ( '<STR_LIT:error>' ) <EOL> max_depth = max_depth_array [ np . argmin ( cv_error ) ] <EOL> print "<STR_LIT>" % max_depth </s>
