generated from LufsX/Experiment-LogReg
This commit is contained in:
+2
-2
@@ -31,7 +31,7 @@ import numpy as np
|
|||||||
def sigmoid(z):
|
def sigmoid(z):
|
||||||
return 1 / (1 + np.exp(-z))
|
return 1 / (1 + np.exp(-z))
|
||||||
|
|
||||||
def train_logreg(X, y, learning_rate=0.01, iterations=1000):
|
def train_logreg(X, y, learning_rate=0.001, iterations=2000):
|
||||||
"""
|
"""
|
||||||
对率回归训练函数。
|
对率回归训练函数。
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ if __name__ == "__main__":
|
|||||||
X_test, y_test = load_data("./data/horse-colic.test")
|
X_test, y_test = load_data("./data/horse-colic.test")
|
||||||
|
|
||||||
# 训练对率回归模型
|
# 训练对率回归模型
|
||||||
weights = train_logreg(X_train, y_train, learning_rate=0.001, iterations=1000) # 修改学习率
|
weights = train_logreg(X_train, y_train, learning_rate=0.001, iterations=2000) # 修改迭代次数
|
||||||
|
|
||||||
# 测试单个数据
|
# 测试单个数据
|
||||||
y_pred = predict_logreg(X_test[11], weights)
|
y_pred = predict_logreg(X_test[11], weights)
|
||||||
|
|||||||
Reference in New Issue
Block a user