<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi, Thomas,<div class="">we had a related thread on the email list some time ago, let me post it for reference further below. Regarding your question, I think you may want make sure that you standardized the features (which makes the learning generally it less sensitive to learning rate and random weight initialization). However, even then, I would try at least 1-3 different random seeds and look at the cost vs time — what can happen is that you land in different minima depending on the weight initialization as demonstrated in the example below (in MLPs you have the problem of a complex cost surface).<div class=""><br class=""></div><div class="">Best,</div><div class="">Sebastian</div><div class=""><div class=""><br class=""></div><div class=""></div><blockquote type="cite" class=""><div class="">The default is set 100 units in the hidden layer, but theoretically, it should work with 2 hidden logistic units (I think that’s the typical textbook/class example). I think what happens is that it gets stuck in local minima depending on the random weight initialization. E.g., the following works just fine:<br class=""><br class="">from sklearn.neural_network import MLPClassifier<br class="">X = [[0, 0], [0, 1], [1, 0], [1, 1]]<br class="">y = [0, 1, 1, 0]<br class="">clf = MLPClassifier(solver='lbfgs', <br class="">                    activation='logistic', <br class="">                    alpha=0.0, <br class="">                    hidden_layer_sizes=(2,),<br class="">                    learning_rate_init=0.1,<br class="">                    max_iter=1000,<br class="">                    random_state=20)<br class="">clf.fit(X, y)  <br class="">res = clf.predict([[0, 0], [0, 1], [1, 0], [1, 1]])<br class="">print(res)<br class="">print(clf.loss_)<br class=""><br class=""><br class="">but changing the random seed to 1 leads to:<br class=""><br class="">[0 1 1 1]<br class="">0.34660921283<br class=""><br class="">For comparison, I used a more vanilla MLP (1 hidden layer with 2 units and logistic activation as well; <a href="https://github.com/rasbt/python-machine-learning-" class="">https://github.com/rasbt/python-machine-learning-</a>book/blob/master/code/ch12/ch12.ipynb), essentially resulting in the same problem:</div><div class=""><img apple-inline="yes" id="737219ED-FBE9-48E1-A6BB-178B62248751" height="218" width="320" apple-width="yes" apple-height="yes" src="cid:FD616E59-2479-47A4-94C1-CA655C974B57" class=""><img apple-inline="yes" id="F2CB20A8-D0B5-42CD-B89B-C9B126345918" height="223" width="320" apple-width="yes" apple-height="yes" src="cid:35DFE39C-EF93-4CC2-9193-CFD2E0B01575" class=""></div></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><br class=""><blockquote type="cite" class="">On Dec 7, 2016, at 6:45 PM, Thomas Evangelidis <<a href="mailto:tevang3@gmail.com" class="">tevang3@gmail.com</a>> wrote:<br class=""><br class="">I tried the sklearn.neural_network.MLPClassifier with the default parameters using the input data I quoted in my previous post about Nu-Support Vector Classifier. The predictions are great but the problem is that sometimes when I rerun the MLPClassifier it predicts no positive observations (class 1). I have noticed that this can be controlled by the random_state parameter, e.g. MLPClassifier(random_state=0) gives always no positive predictions. My question is how can I chose the right random_state value in a real blind test case?<br class=""><br class="">thanks in advance<br class="">Thomas<br class=""><br class=""><br class="">-- <br class="">======================================================================<br class="">Thomas Evangelidis<br class="">Research Specialist<br class="">CEITEC - Central European Institute of Technology<br class="">Masaryk University<br class="">Kamenice 5/A35/1S081, <br class="">62500 Brno, Czech Republic <br class=""><br class="">email: <a href="mailto:tevang@pharm.uoa.gr" class="">tevang@pharm.uoa.gr</a><br class="">         <span class="Apple-tab-span" style="white-space:pre">    </span>tevang3@gmail.com<br class=""><br class="">website: https://sites.google.com/site/thomasevangelidishomepage/<br class=""><br class=""><br class="">_______________________________________________<br class="">scikit-learn mailing list<br class="">scikit-learn@python.org<br class="">https://mail.python.org/mailman/listinfo/scikit-learn<br class=""></blockquote><br class=""></div></div></div></body></html>