Python中文
首页
教程
问答
标签
搜索
登录
注册
sklearn日志丢失不同数量的类
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我在用sklearn的logu loss</p> <pre><code>from sklearn.metrics import log_loss print log_loss(true, pred,normalize=False) </code></pre> <p>我有以下错误:</p> <pre><code>ValueError: y_true and y_pred have different number of classes 38, 2 </code></pre> <p>我真的很奇怪,因为数组看起来是有效的:</p> <pre><code>print pred.shape print np.unique(pred) print np.unique(pred).size (19191L,) [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37] 38 print true.shape print np.unique(true) print np.unique(true).size (19191L,) [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37] 38 </code></pre> <p>原木丢失怎么了?为什么会抛出错误?</p> <p>样本数据:</p> <pre><code>pred: array([ 0, 1, 2, ..., 3, 12, 16], dtype=int64) true: array([ 0, 1, 2, ..., 3, 12, 16]) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>在log_loss方法中,真正的数组由一个LabelBinarizer进行拟合和变换,该LabelBinarizer改变了数组的维数。因此,检查true和pred具有相似的维度并不意味着log_loss方法会工作,因为true的维度发生了变化。如果您只是有二进制类,我建议您使用这个log_loss cost函数,否则对于多个类,这个方法不起作用。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
VirtualEnvRapper错误:路径python2(来自python=python2)不存在
4 回答
virtualenvs上的pyinstaller,没有名为导入错误的模块
6 回答
virtualenvs是否可以退回到用户包而不是系统包?
10 回答
virtualenvwrapper CentOS7
9 回答
virtualenvwrapper IOError:[Errno 13]权限被拒绝
5 回答
virtualenvwrapper mkproject和shell在windows中的启动问题?
6 回答
virtualenvwrapper mkvirtualenv不工作但没有错误
9 回答
Virtualenvwrapper python bash
7 回答
virtualenvwrapper:“workon”何时更改到项目目录?
6 回答
virtualenvwrapper:mkvirtualenv可以工作,但是rmvirtualenv返回bash:没有这样的文件或目录
6 回答
virtualenvwrapper:virtualenv信息存储在哪里?
2 回答
virtualenvwrapper:命令“python设置.pyegg_info“失败,错误代码为1
3 回答
virtualenvwrapper:如何将mkvirtualenv的默认Python版本/路径更改为ins
8 回答
Virtualenvwrapper:模块“pkg_resources”没有属性“iter_entry_points”
6 回答
Virtualenvwrapper:没有名为virtualenvwrapp的模块
10 回答
Virtualenvwrapper.bash_profi的正确设置
8 回答
Virtualenvwrapper.hook:权限被拒绝
7 回答
virtualenvwrapper.sh:fork:资源暂时不可用Python/Djang
5 回答
Virtualenvwrapper.shlssitepackages命令不工作
5 回答
Virtualenvwrapper.sh函数在bash sh中不可用
9 回答