# Is it possible to know the output vectors of MLP Classifier of scikit learn?

I'm a beginner with scikiti-learn library. I have an ANN with 3 input, 2 hidden layers and 3 output.

mlp = MLPClassifier(hidden_layer_sizes= hidden_layers,max_iter=iterations, activation=activation_fun)


I read on the documentation that the classifier uses softmax for the output activation function and cross-entropy loss function. I have a multi-class problem where the three outputs will predict the classes 0,1,2. My question is that. How can I retrieve the vectors that enconds the classes 0,1,2? example: [1,0,0] -> 0 [0,1,0] -> 1 [0,0,1] -> 2

How did you create the labels in the first place? You can know which corresponds to which by using scikit-learn's Label Encoder. This handles the labeling and at the end you can use inverse transformation to get the label names.

For one-hot-encoding the labels, you can use Label Binarizer, which again has an inverse defined in the link.

• Than you for your help :) we have to use Label Encoder when we have to encode textual data in numerical label? I have already numerical labels. I tested it, but return the same labels. I'd like know the output vector of the neural network.. or maybe I don't understand how to apply it
– Paul
Commented Nov 15, 2019 at 9:26
• Then it's probably in numerical order. If you already tested the label encoder, you can try the inverse transform defined in the link above to make sure they are so. Commented Nov 15, 2019 at 9:35
• @Paul please also check the edited part Commented Nov 15, 2019 at 9:45
• It convert the label 0,1,2 into three vector. but how can I be sure that the same encoding is used by the mlp classifier?
– Paul
Commented Nov 15, 2019 at 14:18
• Here is the source code for the predict function for MLP. It returns the inverse transforms of the label binarizer. github.com/scikit-learn/scikit-learn/blob/1495f6924/sklearn/… Commented Nov 15, 2019 at 14:52

If you are interested on the probability output of your model, simply call mlp.predict_proba(X)