E://论文程序//LBPGLCM_SVM_Project-main//LBP朱笔特改.py:84: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray./n data = np.array(data)/nTraceback (most recent call last):/n File /'E://论文程序//LBPGLCM_SVM_Project-main//LBP朱笔特改.py/', line 97, in /n clf.fit(X_train, y_train)/n File /'E://Anaconda//envs//XIN//lib//site-packages//sklearn//svm/_base.py/', line 192, in fit/n X, y = self._validate_data(/n File /'E://Anaconda//envs//XIN//lib//site-packages//sklearn//base.py/', line 584, in _validate_data/n X, y = check_X_y(X, y, **check_params)/n File /'E://Anaconda//envs//XIN//lib//site-packages//sklearn//utils//validation.py/', line 1106, in check_X_y/n X = check_array(/n File /'E://Anaconda//envs//XIN//lib//site-packages//sklearn//utils//validation.py/', line 902, in check_array/n raise ValueError(/nValueError: Expected 2D array, got 1D array instead:/narray=[0.]./nReshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.这段错误是什么意思 两个数组分别是data和labels应该怎么修改内容:这个错误表示输入的数据数组是一维的,而算法期望的是二维数组。根据错误消息的建议,你可以使用array.reshape(-1, 1)来将数据数组转换为二维形式。/n/n对于data数组,你可以将其修改为以下代码来进行转换:/n/npython/ndata = np.array(data).reshape(-1, 1)/n/n/n对于labels数组,你可以使用以下代码进行转换:/n/npython/nlabels = np.array(labels).reshape(-1, 1)/n/n/n这样修改后,你将得到二维的datalabels数组,然后可以继续进行训练。


原文地址: https://www.cveoy.top/t/topic/pHsM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录