繁体   English   中英

Scikit-neural_network输入数据有问题

[英]Scikit-neural_network has trouble with input data

我正在尝试使用sknn训练一些神经网络。 我已经通过熊猫数据框对数据进行了预处理。 当我在标准sklearn分类器上使用fit(x_train,y_train)时,预处理工作正常,但会引发属性错误

anaconda/envs/py3k/lib/python3.4/site-packages/pandas/core/generic.py", line 2360, in __getattr__
(type(self).__name__, name))
 AttributeError: 'DataFrame' object has no attribute 'todense'

或此错误:

/anaconda/envs/py3k/lib/python3.4/site-packages/pandas/core/indexing.py", line 1750, in maybe_convert_indices
raise IndexError("indices are out-of-bounds")

IndexError: indices are out-of-bounds

似乎是随机的(不同的运行,没有任何改变)。

相关的代码如下:

            x_train, x_test, y_train, y_test = cross_validation.train_test_split(X_data, Y_data, test_size=1/kfold)
            regr = linear_model.LinearRegression(copy_X=True,fit_intercept=True)
            abr = AdaBoostRegressor(base_estimator=tree.DecisionTreeRegressor(max_depth=max_depth_gridsearch_values[max_depth_counter]), n_estimators = n_estimators_gridsearch_values[n_estimators_counter])
            nn=nn_simple_regressor


            x_train_numeric = x_train.iloc[:,2:]
            x_test_numeric = x_test.iloc[:,2:]

            regr.fit(x_train_numeric, y_train)
            abr.fit(x_train_numeric, y_train)
            nn.fit(x_train_numeric,y_train)

回归器定义为

nn_simple_regressor = Regressor(
layers=[
    Layer("Rectifier", units=100),
    Layer("Linear")],
learning_rate=0.02,
n_iter=10)

我不明白为什么会这样,似乎对sknn的支持很小。 我怀疑问题实际上与预处理有关,但我不明白为什么它适用于前两个分类器,但不适用于我的NN。 有任何想法吗?

截至2016年2月,Sknn不支持熊猫。 为了解决问题中提到的问题,最好的方法是将数据帧转换为numpy数组。 在熊猫中使用.as_martix()函数是最简单的方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM