我正在尝试修改默认的make_moons数据集,我相信它只是一个整数数组。
我收到错误:
C:\Users\Thomas\Anaconda3\python.exe C:/Users/Thomas/Desktop/!UFV/CIS480/project/SKLTest-testingForArray.py
C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
C:\Users\Thomas\Anaconda3\lib\site-packages\sklearn\lda.py:6: DeprecationWarning: lda.LDA has been moved to discriminant_analysis.LinearDiscriminantAnalysis in 0.17 and will be removed in 0.19
"in 0.17 and will be removed in 0.19", DeprecationWarning)
Traceback (most recent call last):
File "C:/Users/Thomas/Desktop/!UFV/CIS480/project/SKLTest-testingForArray.py", line 208, in <module>
for name, (X, y) in [('moon', newer_make_moons(noise=0.3, random_state=0)),
TypeError: 'tuple' object is not callable
Process finished with exit code 1
这是数组&#39; newer_make_moons&#39;:
newer_make_moons = (np.array(
[
[1,2],
[3,4],
[5,6]
]),
np.array(
[(
[
1,
0,
0
])
], dtype=int))
以下是使用数组的位置,以及发生错误的位置:
for name, (X, y) in [('moon', newer_make_moons(noise=0.3, random_state=0)),
('circles', make_circles(noise=0.2, factor=0.5, random_state=1)),
('linear', linearly_separable)]:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.4, random_state=1)
# standardize data
scaler = StandardScaler().fit(X_train)
datasets[name] = {'X_train': scaler.transform(X_train), 'y_train': y_train,
'X_test': scaler.transform(X_test), 'y_test': y_test}
est = KNeighborsClassifier(n_neighbors=1)
# plots the datasets - see Appendix
plot_datasets(est)
答案 0 :(得分:0)
也许您正试图调用make_moons
函数。将newer_make_moons
替换为
make_moons
for name, (X, y) in [('moon', newer_make_moons(noise=0.3, random_state=0)), ('circles', make_circles(noise=0.2, factor=0.5, random_state=1)), ('linear', linearly_separable)]:
答案 1 :(得分:0)
错误的原因是您尝试将newer_make_moons
作为一项功能进行调用,但它实际上是一个元组。如果删除所有数据,newer_make_moons
的格式是一个元组,其中包含两个np.array()
个对象。那些阵列也没有能力被称为函数。
此外,newer_make_moons
有点乱。你不需要第二个括号中的所有括号。这就是你所需要的:
newer_make_moons = (
np.array([
[1,2],
[3,4],
[5,6]
]),
np.array([1, 0, 0], dtype=int)
)