擅长:python、mysql、java
<p><code>keras.utils.to_categorical</code>生成一个热编码类向量,即错误消息中提到的<code>multilabel-indicator</code>。<code>StratifiedKFold</code>不是设计用来处理这种输入的;从<code>split</code>方法<a href="http://scikit-learn.org/stable/modules/generated/sklearn.model_selection.StratifiedKFold.html#sklearn.model_selection.StratifiedKFold.split" rel="noreferrer">docs</a>:</p>
<blockquote>
<p><strong><code>split</code><em/></strong>(X, y, groups=None)</p>
<p>[...]</p>
<p><strong>y</strong> : array-like, shape (n_samples,)</p>
<p>The target variable for supervised learning problems. Stratification is done based on the y labels.</p>
</blockquote>
<p>也就是说,你的<code>y</code>必须是你的类标签的一维数组。</p>
<p>本质上,您所要做的只是反转操作的顺序:先拆分(使用初始的<code>y_train</code>),然后再转换<code>to_categorical</code>。</p>