[scikit-learn] question about using sklearn.neural_network.MLPClassifier?

2016-11-23 Thread linjia
Hi everyone I try to use sklearn.neural_network.MLPClassifier to test the XOR operation, but I found the result is not satisfied. The following is code, can you tell me if I use the lib incorrectly? from sklearn.neural_network import MLPClassifier X = [[0, 0], [0, 1], [1, 0], [1, 1]] y =

[scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Jaidev Deshpande
Hi, Sometimes when using GridSearchCV, I realize that in the grid there are certain combinations of hyperparameters that are either incompatible or redundant. For example, when using an MLP, if I specify the following grid: grid = {'solver': ['sgd', 'adam'], 'learning_rate': ['constant', 'invscal

Re: [scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Raghav R V
Hi! What you could do is specify lists of dicts to group the parameters which apply together in one dict... [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': 'sgd'}, {'solver': 'adam'}] ```py from sklearn.neural_network import MLPClassifier from sklearn.model_selection import

Re: [scikit-learn] question about using sklearn.neural_network.MLPClassifier?

2016-11-23 Thread Raghav R V
Hi, If you keep everything at their default values, it seems to work - ```py from sklearn.neural_network import MLPClassifier X = [[0, 0], [0, 1], [1, 0], [1, 1]] y = [0, 1, 1, 0] clf = MLPClassifier(max_iter=1000) clf.fit(X, y) res = clf.predict([[0, 0], [0, 1], [1, 0], [1, 1]]) print(res) ```

[scikit-learn] 答复: question about using sklearn.neural_network.MLPClassifier?

2016-11-23 Thread linjia
Yes,you are right @ Raghav R V, thx! However, i found the key param is ‘hidden_layer_sizes=[2]’, I wonder if I misunderstand the meaning of parameter of hidden_layer_sizes? Is it related to the topic : http://stackoverflow.com/questions/36819287/mlp-classifier-of-scikit-neuralnetwork-not-work

Re: [scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Jaidev Deshpande
On Wed, 23 Nov 2016 at 16:29 Raghav R V wrote: > Hi! > > What you could do is specify lists of dicts to group the parameters which > apply together in one dict... > > [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': > 'sgd'}, {'solver': 'adam'}] > > ```py > from sklearn.neural

Re: [scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Joel Nothman
Raghav's example of [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': 'sgd'}, {'solver': 'adam'}] was not correct. Should be [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': ['sgd']}, {'solver': ['adam']}] (Note all values of dicts are lists) On 23 Nov

Re: [scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Jaidev Deshpande
On Wed, 23 Nov 2016 at 17:31 Joel Nothman wrote: > Raghav's example of > > > [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': > 'sgd'}, {'solver': 'adam'}] > > was not correct. > > Should be > > > [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': > ['sgd']},

Re: [scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Raghav R V
On Wed, Nov 23, 2016 at 12:59 PM, Joel Nothman wrote: > Raghav's example of > > > [{'learning_rate': ['constant', 'invscaling', 'adaptive'], 'solver': > 'sgd'}, {'solver': 'adam'}] > > was not correct. > Oops sorry. Ah I ran into that, corrected it in the snipped but forgot to update the line be

Re: [scikit-learn] Specifying exceptions to ParameterGrid

2016-11-23 Thread Roman Yurchak
Hi Jaidev, well, `param_grid` in GridSearchCV can also be a list of dictionaries, so you could directly specify the cases you are interested in (instead of the full grid - exceptions), which might be simpler? On 23/11/16 11:15, Jaidev Deshpande wrote: > Hi, > > Sometimes when using GridSearchCV,

Re: [scikit-learn] question about using sklearn.neural_network.MLPClassifier?

2016-11-23 Thread Sebastian Raschka
> If you keep everything at their default values, it seems to work - > > ```py > from sklearn.neural_network import MLPClassifier > X = [[0, 0], [0, 1], [1, 0], [1, 1]] > y = [0, 1, 1, 0] > clf = MLPClassifier(max_iter=1000) > clf.fit(X, y) > res = clf.predict([[0, 0], [0, 1], [1, 0], [1, 1]])