このコード
import numpy as np
def some_method(y, threshold):
print type(y), y.shape, y.dtype
c = np.zeros(y.shape)
c[y > threshold] = 1
結果は
<type 'numpy.ndarray'> (484L,) [('target', '<f8')]
DeprecationWarning: using a boolean instead of an integer will result in an error in the future
c[y > threshold] = 1
これについては、Googleでもnumpyのリリースノートでも何も見つかりません。これはブール値によるインデックス付けに関するものだと思いますか? これが将来どのようにエラーを引き起こす可能性があるのか わかりません。どうすれば修正できますか?
Python 2.7.6 (デフォルト、2013 年 11 月 10 日 19:24:24) [MSC v.1500 64 ビット (AMD64)] (win32)
でこぼこのバージョン: 1.8.0
編集: 配列が ndarray であることを示すために、コードに print ステートメントを追加しました
EDIT2:コメントからy
、構造体配列であり、チェックを行う正しい方法がy['target'] > threshold
. ただし、y
複数の列、または異なる列名を持つこともできますが、構造化された配列でこれを柔軟に行う方法はありますか?