Beispiel #1
0
import sys
sys.path.insert(0, "../myTools")

import joblib
import os

from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble import RandomForestRegressor
from sklearn.neighbors import KNeighborsRegressor
from loadDataSet import loadMainDataSet, loadTesteDataSet, loadCompletDataSet, loadMainDataSetWithElevation
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import train_test_split

dataSet, _, _ = loadMainDataSetWithElevation()

# Melhores modelos

# Modelo Magnésio
#6, 2, 'log2', True, 6, 33


def MELHOR_RESULTADO_MG():
    X = dataSet[:, :4]
    y = dataSet[:, 4]
    params = {
        'random_state': 0,
        'learning_rate': 0.05,
        'loss': 'lad',
        'max_depth': None,
        'max_features': 'log2',
        'min_samples_leaf': 5,
Beispiel #2
0
    ]

    reg =GridSearchCV(model, cv=3,param_grid=param_grid,verbose=0,n_jobs=-1,scoring=scores,refit='r2',iid=True)

    reg.fit(X_train,y_train)

    return reg.best_estimator_,reg.best_params_,reg.best_score_



args = sys.argv[1:]

y_column,random_state = verifyArgs(args)

# Load data set
dataSet = loadMainDataSetWithElevation()
#dataSet = loadTesteDataSet()
#dataSet = loadMainDataSet()
#Set features and target
y_column = 2 
X = dataSet[:,0:2]
y = dataSet[:,2]


best_model , best_params, best_score,best_seed = findBalancedDataSet(range(1,10),X,y,GridSearchCVKNeighborsRegressor)

print("#Best Params",best_params)
print("#Best Score",best_score)
print("#Best Seed",best_seed)

import sys
sys.path.insert(0, "../myTools")

import numpy as np

from dataSetPreProcessing import train_validation_test_split
from sklearn.model_selection import train_test_split
from loadDataSet import loadMainDataSet, loadTesteDataSet, loadCompletDataSet, loadMainDataSetWithElevation
from tools import verifyArgs, plotLeanrningCurve, findBalancedDataSet, pltResults, pltCorrelation, pltLossGraph, pltShow, plotXY, getMetrics, getBalancedDataSetIndexRandomState

from sklearn.metrics import r2_score, mean_squared_error
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.model_selection import GridSearchCV

# Load data set
dataSet, features_names, target_names = loadMainDataSetWithElevation()


def getParamGrid():
    '''Função que retorna os parâmetro utilizados para encontrar 
    o conjunto de treino balanceado e também na tunagem.
    '''
    param_grid_half = {
        'n_estimators': [100],
        'learning_rate': [0.05],
        'max_depth': [None],
        'min_samples_leaf': [3, 8],
        'max_features': ['auto', 'log2'],
        'loss': ['ls']
    }
    param_grid_full = {