Skip to content

Commit 5ec8a5e

Browse files
author
sheng.xu
committed
fix
1 parent 9d97dff commit 5ec8a5e

File tree

7 files changed

+445
-3
lines changed

7 files changed

+445
-3
lines changed

.idea/Python-Machine-Learning-Algorithm.iml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 229 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Chapter_3 Factorization Machine/FM_train.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def stocGradAscent(dataMatrix, classLabels, k, max_iter, alpha):
8787

8888
# 3、返回最终的FM模型的参数
8989
return w0, w, v
90-
90+
9191
def getCost(predict, classLabels):
9292
'''计算预测准确性
9393
input: predict(list)预测值
@@ -166,11 +166,11 @@ def save_model(file_name, w0, w, v):
166166
f.write("\t".join(v_tmp) + "\n")
167167
f.close()
168168

169-
169+
170170
if __name__ == "__main__":
171171
# 1、导入训练数据
172172
print "---------- 1.load data ---------"
173-
dataTrain, labelTrain = loadDataSet("data_1.txt")
173+
dataTrain, labelTrain = loadDataSet("data.txt")
174174
print "---------- 2.learning ---------"
175175
# 2、利用随机梯度训练FM模型
176176
w0, w, v = stocGradAscent(np.mat(dataTrain), labelTrain, 3, 10000, 0.01)
6.44 KB
Binary file not shown.

0 commit comments

Comments
 (0)