import numpy as np import scipy.linalg as linalg from sklearn.datasets import * import matplotlib.pyplot as plt import sklearn.svm as svm np.random.seed(0) X,Y = make_classification(n_features=2,n_redundant=0,n_informative=2) iy = (Y==1) iny =(Y==0) plt.scatter(X[iy,0],X[iy,1],marker='o') plt.scatter(X[iny,0],X[iny,1],marker='x') clf = svm.SVC(kernel='linear',C=1.0) clf.fit(X,Y) xx,yy = np.meshgrid(np.linspace(-3,3,500),np.linspace(-3,3,500)) Z = clf.decision_function(np.c_[xx.ravel,yy.ravel]) Z = Z.reshape(xx.shape) plt.show()
と python support.py と書いたコードを実行すると
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/collections.py:548: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison if self._edgecolors == 'face':
と出ました。次にpython support.py -W とファイルを実行すると
Traceback (most recent call last): File "support.py", line 18, in <module> Z = clf.decision_function(np.c_[xx.ravel,yy.ravel]) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/svm/base.py", line 547, in decision_function dec = self._decision_function(X) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/svm/base.py", line 404, in _decision_function X = self._validate_for_predict(X) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/svm/base.py", line 459, in _validate_for_predict X = check_array(X, accept_sparse='csr', dtype=np.float64, order="C") File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/utils/validation.py", line 382, in check_array array = np.array(array, dtype=dtype, order=order, copy=copy) TypeError: float() argument must be a string or a number
と出ました。これは何のエラーなのでしょうか?
どこを直せば良いのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。