Community Conundrum 28: News Engagement is live! Read More

Train multiple neural networks in one Analysis?

Level 3
Train multiple neural networks in one Analysis?

The title basically says it all. I want to try different hyperparameters for my Neural Network (or algorithms in general). For some, like random forest, I can specify a list - e.g., max_depth. What I need is a queue of Neural Networks with different hyperparameters, so that I can start them in the evening and come back to the results in the morning.



How to do this?



 



0 Kudos
4 Replies
Dataiker
Dataiker

Hello,



It is not possible at the moment on the visual interface.



Instead, for hyperparameter optimization on neural networks, we invite you to code your own custom Python model (in the Analysis > Design > Algorithms section). For instance, for a neural network from scikit-learn (MLP), you can use this:




 



from sklearn.neural_network import MLPClassifier
from sklearn.model_selection import GridSearchCV

parameters={
'alpha': [1,10,0.1],
'activation': ["logistic", "relu"]
}

mlp = MLPClassifier()

clf = GridSearchCV(
estimator=mlp,
param_grid=parameters,
n_jobs=-1,
verbose=2,
cv=5
)


 



Note that we are looking to integrate neural networks more deeply 😉 into our product. We will keep you posted!



Cheers,



Alex

Level 3
Author
Thanks! I will try the custom version as soon as the current NN classifier is finished.
0 Kudos
Level 3
Author
Unfortunately, I get the following error:
NameError: name 'gridSearchCV' is not defined
--> Fixed by using GridSearchCV instead.

After fixing this, I now get:
get_params() must be called with MLPClassifier instance as first argument.
and I'm not really sure what to do about that.
0 Kudos
Dataiker
Dataiker
Yes, you first need to declare an instance of MLPClassifier: `mlp=MLPClassifier()` before it can be passed to GridSearchCV.
0 Kudos
Labels (2)
A banner prompting to get Dataiku DSS