更新 function.py
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 11s

This commit is contained in:
2024-11-03 12:50:05 +08:00
parent d9d35afd7f
commit 0abb6cac5a
+2 -9
View File
@@ -20,8 +20,8 @@ import numpy as np
"""
请在这里填写学号和姓名,不填写即成绩无效。
"""
id = "202210423120"
name = "袁焜"
id = ""
name = ""
# 这里写自己的代码实现
import numpy as np
@@ -139,12 +139,5 @@ if __name__ == "__main__":
# 测试模型
final_test_accuracy = accuracy(X_test, y_test, final_weights)
print(f"最终测试集的准确率: {final_test_accuracy:.4f}")
# 加载测试集
X_test, y_test = load_data("./data/horse-colic.test")
# 训练对率回归模型
weights = train_logreg(X_train, y_train, learning_rate=0.01, iterations=1000)
# 测试单个数据
y_pred = predict_logreg(X_test[11], weights)
print(f"预测结果: {y_pred}, 实际结果: {y_test[11]}")