3
$\begingroup$

As we know all, after training a neural network, each neuron in the output layer presents one class. These class are in a numeric format for example 0 for sunny 1 for overcast and 3 for rainy. after the prediction phase, the model print for example 1, how to know that 1 corresponds to the class overcast?

$\endgroup$
  • $\begingroup$ which module are you using?, may be if you can give us the name, we can give a code example $\endgroup$ – InAFlash Jul 30 '18 at 12:33
  • $\begingroup$ Thank you for your answer. I used a multi layer perception for classification $\endgroup$ – user Jul 30 '18 at 19:45
2
$\begingroup$

You as the designer of the network specify each class in the training example. You set e.g. a car class to label $0$ and another class to $1$. During training your classifier tries to map the inputs to the corresponding class which are those numbers where you have specified in the dataset. This phase is called encoding. After outputting the label, you should decode the label which is a trivial task!

$\endgroup$
  • $\begingroup$ Thank you for your answer, can you give me please a script of code or a function to do this? $\endgroup$ – user Jul 30 '18 at 19:47
  • $\begingroup$ I don't know how your data is but try to exploit pandas.read_csv, add a new $,0$ for previous classes and store them. For new data try to zero the other entries and add one for the last. Are you familiar with pandas? $\endgroup$ – Media Jul 30 '18 at 19:49
  • $\begingroup$ I used this script to encode: le = preprocessing.LabelEncoder() df[name] = le.fit_transform(df[name]). Now how decode it? $\endgroup$ – user Jul 30 '18 at 19:51
  • $\begingroup$ I don't know your class preprocessing :) $\endgroup$ – Media Jul 30 '18 at 19:53
  • $\begingroup$ from sklearn import preprocessing $\endgroup$ – user Jul 30 '18 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.