def concrete(): print("Started training linear regressor on concrete data set.") x_train, x_test, y_train, y_test = data_processing.concrete() result = {} # LR lr_best_model, lr_params = regression_cv.linear_regression(x_train, y_train, fold=3, iterations=20) result[constant.LR] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "concrete", "Linear Regression") # decision tree lr_best_model, lr_params = regression_cv.decision_tree(x_train, y_train, max_depth=20, fold=3, iterations=20) result[constant.DECISION_TREE] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "concrete", "Decision tree") # Random Forest lr_best_model, lr_params = regression_cv.random_forest(x_train, y_train, max_estimator=100, fold=3, iterations=20) result[constant.RANDOM_FOREST] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "concrete", "Random Forest") # SVM lr_best_model, lr_params = regression_cv.SVR(x_train, y_train, # ['linear', 'poly', 'rbf', 'sigmoid'], ['linear'], 0.01, 100, 1, 1000, fold=3, iterations=10) result[constant.SVC] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "concrete", "SVM") # AdaBoost lr_best_model, lr_params = regression_cv.ada_boost_regression(x_train, y_train, no_estimators=50, fold=3, iterations=20) result[constant.ADABOOST] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "concrete", "AdaBoost") # NeuralNet (not finish) #lr_best_model, lr_params = regression_cv.NeuralNetworkRegression(x_train, y_train, # hidden_layer_sizes=[(100,), (10,)], # alphas=[0.01, 0.05, 0.5, 1], # max_iter=[10, 20, 50, 100], # fold=3, iterations=20) #result[constant.NN] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, # "concrete", "NeuralNet") #GaussianProcessRegressor lr_best_model, lr_params = regression_cv.GPRegressor(x_train, y_train, fold=3, iterations=10) result[constant.GP] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "concrete", "Gaussian process") export_result(result, "result/concrete.json")
def red_wine_quality(): print("Started training linear regressor on red wine quality data set.") x_train, x_test, y_train, y_test = data_processing.red_wine_quality() result = {} # LR lr_best_model, lr_params = regression_cv.linear_regression(x_train, y_train, fold=3, iterations=20) result[constant.LR] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "Wine quality", "Linear Regression") # decision tree lr_best_model, lr_params = regression_cv.decision_tree(x_train, y_train, max_depth=20, fold=3, iterations=20) result[constant.DECISION_TREE] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "Wine quality", "Decision tree") # Random Forest lr_best_model, lr_params = regression_cv.random_forest(x_train, y_train, max_estimator=100, fold=3, iterations=20) result[constant.RANDOM_FOREST] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "Wine quality", "Random Forest") # SVM lr_best_model, lr_params = regression_cv.SVR(x_train, y_train, ['linear', 'poly', 'rbf', 'sigmoid'], 0.01, 100, 1, 1000, fold=3, iterations=20) result[constant.SVC] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "Wine quality", "SVM") # AdaBoost lr_best_model, lr_params = regression_cv.ada_boost_regression(x_train, y_train, no_estimators=50, fold=3, iterations=20) result[constant.ADABOOST] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "Wine quality", "AdaBoost") # NeuralNet lr_best_model, lr_params = regression_cv.NeuralNetworkRegression(x_train, y_train, hidden_layer_sizes=[(), (10,)], alphas=[0.01, 0.05, 0.5, 1], max_iter=[100, 200, 500, 1000], fold=3, iterations=20) result[constant.NN] = evaluate_regressor(x_train, x_test, y_train, y_test, lr_best_model, lr_params, "Wine quality", "NeuralNet") export_result(result, "result/red_wine.json")