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