Neural network with multiple outputs in sklearn

I am trying to build a neural network to predict the probability that each tennis player will win a facility when they play against each other. For the inputs, I would use the last N

matches that each player played, assuming the difference in ratings against their opponent and the actual probability of winning a point they had in the match.

For example, if you only look at 2 matches for each player, one entry would be

i=[-61, 25, 0.62, 0.64, 2, -35, 0.7, 0.65]

      

The first 4 numbers for the 1st player (rankings and probabilities that he had), the remaining 4 for the second. The conclusion will be

o=[0.65, 0.63]

      

So the learning inputs would be X=[i1, i2, i3,...]

and are outputy=[o1, o2, o3,...]

I have a couple of newbies:

  • Do I need to normalize the input data (ranks and probabilities respectively) across the entire dataset?
  • when i try to run this in python it says

ValueError: Multioutput target data not supported with label binarization

Can I get MLPClassifier to work with 2 outputs?

EDIT: added code

from sklearn.neural_network import MLPClassifier
clf = MLPClassifier(solver='lbfgs', alpha=1e-5,
                   hidden_layer_sizes=(5, 2), random_state=1)
X=[[-61, 25, 0.62, 0.64, 2, -35, 0.7, 0.65], [2,-5,0.58,0.7,-3,-15,0.65,0.52] ]
y=[ [0.63, 0.64], [0.58,0.61] ]
clf.fit(X,y)

      

this code returns the specified error. the data is not standardized here, but for now we will not ignore it.

+4


source to share


2 answers


Your first question is answered here in detail: why should we normalize the input for the artificial neural network? In short, yes, just normalize the values, it will make life easier.

The second question is addressed here :

MLPClassifier supports multi-class classification using Softmax as the inference function.




If you can add some of your code to the question, the answer might be more detailed.




edit

After reading the question more closely, I realized that you are trying to use a classifier function, i.e. you are trying to apply labels to your input. This means that the function expects binary output.

You are probably looking for a multi-layered Perceptron regressor that will give continuous outputs.

from sklearn.neural_network import MLPRegressor
clf = MLPRegressor(solver='lbfgs', alpha=1e-5,
                   hidden_layer_sizes=(5, 2), random_state=1)
X=[[-61, 25, 0.62, 0.64, 2, -35, 0.7, 0.65], [2,-5,0.58,0.7,-3,-15,0.65,0.52] ]
y=[ [0.63, 0.64], [0.58,0.61] ]
clf.fit(X,y)

      

MLPRegressor(activation='relu', alpha=1e-05, batch_size='auto', beta_1=0.9,
       beta_2=0.999, early_stopping=False, epsilon=1e-08,
       hidden_layer_sizes=(5, 2), learning_rate='constant',
       learning_rate_init=0.001, max_iter=200, momentum=0.9,
       nesterovs_momentum=True, power_t=0.5, random_state=1, shuffle=True,
       solver='lbfgs', tol=0.0001, validation_fraction=0.1, verbose=False,
       warm_start=False)

      

+7


source


I want to create an MLP regression model for a multi-input / output problem. I have 60 inputs and 13 outputs in total. All values ​​are continuous. But I have some prediction rules. As well as the value of Output1 must not be greater than Input3, and the value of Output5 must be between Input1 and Input2. How to achieve this type of rules in neural networks or decision trees and random forests?



Thank you.

0


source







All Articles