From 0efb5eb6a505847ac9d43eee8af7c0da69cfd069 Mon Sep 17 00:00:00 2001 From: MauronMP Date: Wed, 16 Nov 2022 14:30:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20build(regression=20&&=20model.py?= =?UTF-8?q?):=20Delete,=20no=20son=20necesarios=20para=20#26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pmp_iv/enums/regression_algorithm.py | 7 ---- pmp_iv/forest_prediction/model_building.py | 47 ---------------------- 2 files changed, 54 deletions(-) delete mode 100644 pmp_iv/enums/regression_algorithm.py delete mode 100644 pmp_iv/forest_prediction/model_building.py diff --git a/pmp_iv/enums/regression_algorithm.py b/pmp_iv/enums/regression_algorithm.py deleted file mode 100644 index af08ddb..0000000 --- a/pmp_iv/enums/regression_algorithm.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import Enum - -class Regression_algorithm(Enum): - Lasso = 'Lasso' - Ridge = 'Ridge' - RandomForestRegressor = 'RandomForestRegressor' - KNeighborsRegressor = 'KNeighborsRegressor' \ No newline at end of file diff --git a/pmp_iv/forest_prediction/model_building.py b/pmp_iv/forest_prediction/model_building.py deleted file mode 100644 index bd1a847..0000000 --- a/pmp_iv/forest_prediction/model_building.py +++ /dev/null @@ -1,47 +0,0 @@ -from sklearn.preprocessing import StandardScaler -from sklearn.metrics import mean_absolute_error, r2_score -from sklearn.linear_model import Lasso -from sklearn.linear_model import Ridge -from sklearn.ensemble import RandomForestRegressor -from sklearn.neighbors import KNeighborsRegressor -from pmp_iv.forest_prediction.eda import * -from sklearn.model_selection import train_test_split -from pmp_iv.enums.regression_algorithm import * - -class model_building(): - - def __init__(self): - self.data_csv = EDA() - X = EDA().weather() - Y = EDA().by_property('area') - self.X_train, self.X_test, self.y_train, self.y_test = train_test_split(X,Y,test_size=0.20,shuffle=True,random_state=1) - - def scaler_standard(self, X_train, X_test): - scaler = StandardScaler() - X_train_scaled = scaler.fit_transform(X_train) - X_test_scaled = scaler.transform(X_test) - - return X_train_scaled, X_test_scaled - - def regresion_todos(self): - X_train_scaled, X_test_scaled = self.scaler_standard(self.X_train, self.X_test) - rSquare_mae = [] - - for i_regresion in (Lasso(), Ridge(), RandomForestRegressor(), KNeighborsRegressor()): - i_regresion.fit(X_train_scaled, self.y_train) - i_regresion_prediccion = i_regresion.predict(X_test_scaled) - mae = mean_absolute_error(self.y_test, i_regresion_prediccion) - r2 = r2_score(self.y_test, i_regresion_prediccion) - rSquare_mae.append([r2,mae]) - - j = 0 - for i in Regression_algorithm: - rSquare_mae[j].append(i.value) - j+=1 - - return rSquare_mae - - def get_best_results(self): - listado_resultados = self.regresion_todos() - listado_resultados = sorted(listado_resultados, key = lambda x: (-x[0])) - return listado_resultados[0][2] \ No newline at end of file