本文整理汇总了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]