<jupyter_start><jupyter_text>Building a linear model (stadard Linear Regression)<jupyter_code>linear_model_def = LinearRegression()
multi_linear_model_def = MultiOutputRegressor(estimator=linear_model_def,
                                              n_jobs=-1)
multi_linear_model_def.fit(X_train,Y_train)
Y_train_pred = multi_linear_model_def.predict(X_train)
Y_test_pred = multi_linear_model_def.predict(X_test)
plot_error(Y_test,Y_test_pred)
plot_error_dist(Y_test,Y_test_pred)
print("train performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_train[:,0],Y_train_pred[:,0]),
               r2_score(Y_train[:,1],Y_train_pred[:,1]),
               r2_score(Y_train[:,2],Y_train_pred[:,2]),
               r2_score(Y_train[:,3],Y_train_pred[:,3])))
print("test performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_test[:,0],Y_test_pred[:,0]),
               r2_score(Y_test[:,1],Y_test_pred[:,1]),
               r2_score(Y_test[:,2],Y_test_pred[:,2]),
               r2_score(Y_test[:,3],Y_test_pred[:,3])))<jupyter_output>test performance
Theta0 : 0.924462
Theta1 : 0.930991
Theta2 : 0.939308
Theta3 : 0.931522<jupyter_text>Building a SGDRegressor Model<jupyter_code>sgd_reg_model_def = SGDRegressor()
multi_sgd_model_def = MultiOutputRegressor(estimator=sgd_reg_model_def,n_jobs=-1)
multi_sgd_model_def.fit(X_train,Y_train)
Y_train_pred = multi_sgd_model_def.predict(X_train)
Y_test_pred = multi_sgd_model_def.predict(X_test)
plot_error(Y_test,Y_test_pred)
plot_error_dist(Y_test,Y_test_pred)
print("train performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_train[:,0],Y_train_pred[:,0]),
               r2_score(Y_train[:,1],Y_train_pred[:,1]),
               r2_score(Y_train[:,2],Y_train_pred[:,2]),
               r2_score(Y_train[:,3],Y_train_pred[:,3])))
print("test performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_test[:,0],Y_test_pred[:,0]),
               r2_score(Y_test[:,1],Y_test_pred[:,1]),
               r2_score(Y_test[:,2],Y_test_pred[:,2]),
               r2_score(Y_test[:,3],Y_test_pred[:,3])))<jupyter_output>test performance
Theta0 : 0.922798
Theta1 : 0.930461
Theta2 : 0.936083
Theta3 : 0.926349<jupyter_text>Building a DecisionTree Regressor<jupyter_code>from sklearn.tree import DecisionTreeRegressor
dt_def = DecisionTreeRegressor()
multi_dt_model_def = MultiOutputRegressor(estimator=dt_def,n_jobs=-1)
multi_dt_model_def.fit(X_train,Y_train)
Y_train_pred = multi_dt_model_def.predict(X_train)
Y_test_pred = multi_dt_model_def.predict(X_test)
plot_error(Y_test,Y_test_pred)
plot_error_dist(Y_test,Y_test_pred)
print("train performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_train[:,0],Y_train_pred[:,0]),
               r2_score(Y_train[:,1],Y_train_pred[:,1]),
               r2_score(Y_train[:,2],Y_train_pred[:,2]),
               r2_score(Y_train[:,3],Y_train_pred[:,3])))
print("test performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_test[:,0],Y_test_pred[:,0]),
               r2_score(Y_test[:,1],Y_test_pred[:,1]),
               r2_score(Y_test[:,2],Y_test_pred[:,2]),
               r2_score(Y_test[:,3],Y_test_pred[:,3])))<jupyter_output>test performance
Theta0 : 0.990146
Theta1 : 0.992169
Theta2 : 0.995295
Theta3 : 0.992229<jupyter_text>Building a AdaBoost Regression using a standard SGD Regressor<jupyter_code>from sklearn.ensemble import AdaBoostRegressor
base_dt_model = DecisionTreeRegressor()
ada_def = AdaBoostRegressor(base_estimator=base_dt_model)

multi_ada_model_def = MultiOutputRegressor(estimator=ada_def,n_jobs=-1)
multi_ada_model_def.fit(X_train,Y_train)
from sklearn.ensemble import GradientBoostingRegressor
grad_boost_def = GradientBoostingRegressor(n_estimators=300)

multi_grad_boost_def = MultiOutputRegressor(estimator=grad_boost_def,n_jobs=-1)
multi_grad_boost_def.fit(X_train,Y_train)
Y_train_pred = multi_grad_boost_def.predict(X_train)
Y_test_pred = multi_grad_boost_def.predict(X_test)
plot_error(Y_test,Y_test_pred)
plot_error_dist(Y_test,Y_test_pred)
print("train performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_train[:,0],Y_train_pred[:,0]),
               r2_score(Y_train[:,1],Y_train_pred[:,1]),
               r2_score(Y_train[:,2],Y_train_pred[:,2]),
               r2_score(Y_train[:,3],Y_train_pred[:,3])))
print("test performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_test[:,0],Y_test_pred[:,0]),
               r2_score(Y_test[:,1],Y_test_pred[:,1]),
               r2_score(Y_test[:,2],Y_test_pred[:,2]),
               r2_score(Y_test[:,3],Y_test_pred[:,3])))
from xgboost import XGBRegressor
xg_boost_def = XGBRegressor()

multi_xg_boost_def = MultiOutputRegressor(estimator=xg_boost_def,n_jobs=-1)
multi_xg_boost_def.fit(X_train,Y_train)
Y_train_pred = multi_xg_boost_def.predict(X_train)
Y_test_pred = multi_xg_boost_def.predict(X_test)
plot_error(Y_test,Y_test_pred)
plot_error_dist(Y_test,Y_test_pred)
print("train performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_train[:,0],Y_train_pred[:,0]),
               r2_score(Y_train[:,1],Y_train_pred[:,1]),
               r2_score(Y_train[:,2],Y_train_pred[:,2]),
               r2_score(Y_train[:,3],Y_train_pred[:,3])))
print("test performance")
print("Theta0 : %f\n\
Theta1 : %f\n\
Theta2 : %f\n\
Theta3 : %f" %(r2_score(Y_test[:,0],Y_test_pred[:,0]),
               r2_score(Y_test[:,1],Y_test_pred[:,1]),
               r2_score(Y_test[:,2],Y_test_pred[:,2]),
               r2_score(Y_test[:,3],Y_test_pred[:,3])))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16244359597362026, 'fraction_numerical': 0.04599097535577924, 'mean_word_length': 5.170235546038544, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '460518', 'license': 'Apache-2.0', 'n_tokens_mistral': 2448, 'n_tokens_neox': 2434, 'n_words': 263, 'path': 'Suspended_Robot/ML4D/notebooks/ver2.1/modelling_std_ML_algo_multi_output.ipynb', 'repo_name': 'Machine-Learning-Tokyo/Agritech', 'size': '5762'}