【发布时间】:2015-04-25 13:16:01
【问题描述】:
我有一个感知器算法的实现,它根据词袋模型运行,定义了一系列权重来分离两个特征向量。
例子:
Document 1 = ["I", "am", "awesome"]
Document 2 = ["I", "am", "great", "great"]
字典是:
["I", "am", "awesome", "great"]
所以作为向量的文档看起来像:
Document 1 = [1, 1, 1, 0]
Document 2 = [1, 1, 0, 2]
然后算法学习一个决策边界方程,即:
feature_0 * weight_0 +
feature_1 * weight_1 +
feature_2 * weight_2 +
feature_3 * weight_3 +
bias
现在我有一个测试集,其格式与上面描述的训练集非常相似。根据我的决策边界方程测试这些值并为它们分配标签的伪代码是什么?
我猜它类似于(伪代码):
For each word in the test set
if that word exists in the global dict
value = the frequency of that word * the learned weight
if value >= 0
return 1
else
return -1
但是我想捕获整个特征向量的类,而不是一个词,所以我猜肯定是求和?
【问题讨论】:
标签: java machine-learning perceptron