11
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 11s

This commit is contained in:
lzh
2024-11-02 13:39:47 +08:00
parent 8259bce15c
commit b78122073e
+3 -2
View File
@@ -27,7 +27,7 @@ name = "廖子豪"
# 这里写自己的代码实现 # 这里写自己的代码实现
def load_data(filepath(horse-colic.test)): def load_data(filepath):
""" """
从文件中加载数据。 从文件中加载数据。
@@ -49,6 +49,7 @@ def load_data(filepath(horse-colic.test)):
X = np.nan_to_num(X, nan=np.nanmean(X, axis=0)) X = np.nan_to_num(X, nan=np.nanmean(X, axis=0))
return X, y return X, y
def train_logreg(X, y, learning_rate=0.01, iterations=1000): def train_logreg(X, y, learning_rate=0.01, iterations=1000):
""" """
对率回归训练函数。 对率回归训练函数。
@@ -98,4 +99,4 @@ if __name__ == "__main__":
# 测试单个数据 # 测试单个数据
y_pred = predict_logreg(X_test[11], weights) y_pred = predict_logreg(X_test[11], weights)
print(f"预测结果: {y_pred}, 实际结果: {y_test[11]}") print(f"预测结果: {y_pred}, 实际结果: {y_test[11]}")