本文整理汇总了Python中sklearn.linear_model.Perceptron.decision_function方法的典型用法代码示例。如果您正苦于以下问题:Python Perceptron.decision_function方法的具体用法?Python Perceptron.decision_function怎么用?Python Perceptron.decision_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.linear_model.Perceptron
的用法示例。
在下文中一共展示了Perceptron.decision_function方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dc
# 需要导入模块: from sklearn.linear_model import Perceptron [as 别名]
# 或者: from sklearn.linear_model.Perceptron import decision_function [as 别名]
# training set: train_d aka x, (mon4, mon5); train_t aka y, (mon6)
# testing set: test_d aka x, (mon4, mon5, mon6); test_t aka y, (mon7)
train_d = dc(mon4)
train_d.extend(mon5)
test_d = dc(train_d)
test_d.extend(mon6)
train_t = dc(mon6)
test_t = dc(mon7)
# processing data
train_d = pp.process_activity(train_d)
train_t = pp.process_activity(mon6)
train_d = pp.normalization(train_d)
train_x,train_y = pp.get_train_data(train_d,train_t)
test_d = pp.process_activity(test_d)
test_d = pp.normalization(test_d)
test_t = pp.process_activity(test_t)
# using percetron to train model
pcpt = Perceptron()
pcpt.fit(train_x, train_y)
# geting 3000 best prediction data
result = heapq.nlargest(2000,test_d,lambda x:pcpt.decision_function(test_d[x]))
# calculating the quality of result
precision, recall, f1 = pp.get_comments(result, test_t)
print "Precision rate: %f\nRecall rate: %f\nF1: %f\n" % (precision,recall,f1)