0
我有一个感知器算法的实现,它根据单词袋模型进行操作,定义一系列权重来分离两个特征向量。如何实现感知器测试
实施例:
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
但我想捕捉该类整个特征向量的,不只是一个字,所以我想它必须是一个总结?
我想我明白了,你可以看看我的代码,看看你是否同意?这是在我的[github页面](https://github.com/h1395010/perceptron/blob/master/src/file_dict_createur/Perceptron.java)我评论了我在哪里做测试。 – 2015-02-24 03:00:01
似乎对我来说是正确的,但不要把它理所当然,因为我有点累Atm :)如果一切正确,你可以设置测试=火车设置,并应该获得接近100%的正确参数。 – runDOSrun 2015-02-24 03:05:53
所以,我可以在该感知器类中切换测试集和训练集?我想如果我这样做,我将不得不将我的权重初始化为零而不是随机数,不是吗?然后我应该得到相同的结果? – 2015-02-24 03:18:14