本文整理匯總了Python中sklearn.multiclass.OutputCodeClassifier.predict方法的典型用法代碼示例。如果您正苦於以下問題:Python OutputCodeClassifier.predict方法的具體用法?Python OutputCodeClassifier.predict怎麽用?Python OutputCodeClassifier.predict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.multiclass.OutputCodeClassifier
的用法示例。
在下文中一共展示了OutputCodeClassifier.predict方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_haar_features
# 需要導入模塊: from sklearn.multiclass import OutputCodeClassifier [as 別名]
# 或者: from sklearn.multiclass.OutputCodeClassifier import predict [as 別名]
row += get_haar_features(im, top_left, bottom_right)
train_ecoc_table[ind] = row
test_ecoc_table = np.zeros(shape=(np.shape(test_images)[0], 200))
for ind, im in enumerate(test_images):
row = []
for (top_left, bottom_right) in rectangles:
row += get_haar_features(im, top_left, bottom_right)
test_ecoc_table[ind] = row
clf = OutputCodeClassifier(AdaBoostClassifier(DecisionTreeClassifier(max_depth=1), n_estimators=200), code_size=5, random_state=0)
clf.fit(train_ecoc_table, labels)
train_pred = np.array(clf.predict(train_ecoc_table))
print "Digits Training Accuracy: %f" % (np.sum(train_pred == np.array(labels)).astype(np.float)/np.shape(train_pred)[0])
test_pred = np.array(clf.predict(test_ecoc_table))
print "Digits Testing Accuracy: %f" % (np.sum(test_pred == np.array(test_labels)).astype(np.float)/np.shape(test_pred)[0])
# ecoc_table = []
# for im in images:
#
# im_preprocess = np.matrix([[np.sum(im[:i,:j]) for i in range(1, 29)] for j in range(1, 29)])
#
# def get_black_rectangle(top_left, bottom_right):
# x1, y1 = top_left
# x2, y2 = bottom_right
#
# return im_preprocess[x2, y2] - im_preprocess[x2, y1] - im_preprocess[x1, y2] + im_preprocess[x1, y1]