Las matrices utilizadas como índices deben ser de tipo entero (o booleano)
Los errores son así:
Traceback (most recent call last):
File "NearestCentroid.py", line 53, in <module>
clf.fit(X_train.todense(),y_train)
File "/usr/local/lib/python2.7/dist-packages/scikit_learn-0.13.1-py2.7-linux-i686.egg/sklearn/neighbors/nearest_centroid.py", line 115, in fit
variance = np.array(np.power(X - self.centroids_[y], 2))
IndexError: arrays used as indices must be of integer (or boolean) type
Los códigos son así:
distancemetric=['euclidean','l2']
for mtrc in distancemetric:
for shrkthrshld in [None]:
#shrkthrshld=0
#while (shrkthrshld <=1.0):
clf = NearestCentroid(metric=mtrc,shrink_threshold=shrkthrshld)
clf.fit(X_train.todense(),y_train)
y_predicted = clf.predict(X_test.todense())
estoy usandoscikit-learn
paquete,X-train
, y_train
están en formato LIBSVM,X
es la característica: par de valor,y_train
es el objetivo / etiqueta,X_train
está en formato matricial CSR, lashrink_threshold
no es compatible con la matriz dispersa de CSR, así que agrego.todense()
aX_train
, luego recibí este error, ¿podría alguien ayudarme a arreglar esto? ¡Muchas gracias!