Open monikeguitar opened 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?
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 = {
'layer3':[5,10],
'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.
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)
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.
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.