sklearn中具有多个输出的神经网络 [英] neural network with multiple outputs in sklearn

查看:894
本文介绍了sklearn中具有多个输出的神经网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立一个神经网络,以预测每位网球运动员在彼此比赛时赢得服务分的概率.对于输入,我将使用每位玩家进行的最后一次N比赛,计算与对手的排名差异以及赢得比赛中某个积分的实际概率.

I'm trying to build a neural network to predict the probability of each tennis player winning a service point when they play against each other. For inputs I would use last N matches that each player played, taking the ranking difference against his opponent and the actual probability of winning a point he had in the match.

例如,每位玩家只看2个比赛,一个输入就是

For example, looking at only 2 matches for each player, one input would be

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

前4个数字代表第一个玩家(排名差异和他所拥有的概率),其他4个代表第二位. 输出将是

First 4 numbers are for 1st player (ranking differences and probabilities he had), other 4 for second. Output would be

o=[0.65, 0.63]

因此训练输入为X=[i1, i2, i3,...]而输出为y=[o1, o2, o3,...]

So training inputs would be X=[i1, i2, i3,...] and outputs y=[o1, o2, o3,...]

我有几个新手问题:

  1. 是否有必要对整个数据集的输入(分别为等级和概率)进行标准化?
  2. 当我尝试在python中运行时,它说

ValueError:标签二值化不支持多输出目标数据

ValueError: Multioutput target data is not supported with label binarization

我可以使MLPClassifier与2个输出一起使用吗?

Can I make MLPClassifier work with 2 outputs?

编辑:添加了一些代码

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)

该代码返回上述错误.数据未在此处标准化,但现在暂时忽略它.

that code return the mentioned error. data isn't normalized here, but let's ignore that for now.

推荐答案

在这里详细回答了您的第一个问题:

Your first question is answered here in detail: Why do we have to normalize the input for an artificial neural network? In short, yes, just normalize the values, it makes life easier.

第二个问题在此处:

MLPClassifier通过应用Softmax支持多类分类 作为输出功能.

MLPClassifier supports multi-class classification by applying Softmax as the output function.


如果您可以在问题中添加一些代码,则答案可能会更详细.


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

修改

再次仔细阅读问题后,我意识到您正在尝试使用分类器功能,即您正在尝试将标签应用于输入数据.这意味着该函数期望二进制输出.

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

您可能正在寻找多层感知器回归器,它将提供连续的输出值.

You are probably looking for a Multi-layer Perceptron regressor which will give continuous output values.

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)

这篇关于sklearn中具有多个输出的神经网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆