monikeguitar / Project

0 stars 0 forks source link

Params #1

Open monikeguitar opened 4 years ago

monikeguitar commented 4 years ago

Olá @tolandwehr

Estou trabalhando em um projeto parecido. Você poderia me enviar o código funcionando com este erro resolvido? Link: https://github.com/scikit-learn/scikit-learn/issues/14564

Tentei utilizar aqui mas deu erro.

monikeguitar commented 4 years ago

Good morning, @tolandwehr

I am working on a similar project. I tried to use what you did here, but it gave error: Link: scikit-learn / scikit-learn # 14564

Could you send me the code working with this error resolved?

tolandwehr commented 4 years ago

Hi there,

so actually the central solution is posted within the issue, but here a more extensive version of the whole process. It's not exactly professional, but I hope it helps:

grid_param_LSTM = {

     'layer1':[250,225],

     'layer2':[170,120,70],

     'layer3':[5,10],

   'batch_size': [300,256,200],

     'epochs': [8,12],   

    'learning_rate':[0.0008,0.001,0.004],     'optimizer': ['Nadam', 'Adam'],     'loss': ['logcosh', 'mse'],      'activation': ['relu', 'tanh'],      'dropout_rate':[0.5,0.65] }

def CustomReshaper(X,y):     X_RNN=X.reshape(3,Train_Num,1)     y_RNN=y.reshape(3,Train_Num,1)     return X_RNN     def CustomR2(y_true, y_pred):     y_true=y_true.reshape(len(y_true[:,1])Train_Num,1)          if np.isnan(y_pred).any():         result=-1000000     else:         y_pred=y_pred.reshape(len(y_pred[:,1])Train_Num,1)         result=r2_score(y_true, y_pred)

    return result

pipe = Pipeline([     ('Reshaper',FunctionTransformer(CustomReshaper(X_train_smallLSTM, y_train_smallLSTM))),     ('Regressor',model_LSTM) ])

GridLSTM = GridSearchCV(model_LSTM,                      param_grid=grid_param_LSTM,                      scoring=scorer,                      cv=3)

X_train_R_Grid=X_train_smallLSTM.reshape(3,Train_Num,1) y_train_R_Grid=y_train_smallLSTM.reshape(3,Train_Num,1)

GridLSTM.fit(X_train_R_Grid, y_train_R_Grid)

print(GridLSTM.bestparams) print(GridLSTM.bestscore)

Best regards, Tobias

On Thursday, April 09, 2020 16:22 CEST, monikeguitar notifications@github.com wrote:     Good morning, @tolandwehr I am working on a similar project. I tried to use what you did here, but it gave error: Link: scikit-learn / scikit-learn # 14564 Could you send me the code working with this error resolved? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.  

monikeguitar commented 4 years ago

Thank you, @tolandwehr It's still in error. : / Wouldn't you have a notebook with the code working? With all imports and working, you could make it available.

NameError Traceback (most recent call last)

in () 45 cv=3) 46 ---> 47 X_train_R_Grid=X_train_smallLSTM.reshape(4,Train_Num,1) 48 y_train_R_Grid=y_train_smallLSTM.reshape(4,Train_Num,1) 49 NameError: name 'X_train_smallLSTM' is not defined
tolandwehr commented 4 years ago

Der Monikeguitar,

of course you should apply your own training sets which have their own respective variable names (I presume, X_train_smallLSTM' is not defined anywhere (as your training set has a completely different name)) This should resolve the problems.

Best regars, Tobias Landwehr

On Thursday, April 09, 2020 23:59 CEST, monikeguitar notifications@github.com wrote:     Thank you, @tolandwehr It's still in error. : / Wouldn't you have a notebook with the code working? With all imports and working, you could make it available. NameError Traceback (most recent call last) in () 45 cv=3) 46 ---> 47 X_train_R_Grid=X_train_smallLSTM.reshape(4,Train_Num,1) 48 y_train_R_Grid=y_train_smallLSTM.reshape(4,Train_Num,1) 49 NameError: name 'X_train_smallLSTM' is not defined — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.