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

This commit is contained in:
2024-11-03 04:30:30 +08:00
parent 90e2759dcd
commit d217ae1b24
+2 -2
View File
@@ -78,7 +78,7 @@ def train_logreg(X, y, learning_rate=0.01, num_iterations=1000, regularization_s
return weights
# 对率回归预测函数
# 使用 0.4 阈值的对率回归预测函数
def predict_logreg(inX, weights):
"""
对率回归预测函数。
@@ -91,7 +91,7 @@ def predict_logreg(inX, weights):
- int: 预测的分类标签。
"""
probability = 1 / (1 + np.exp(-np.dot(inX, weights)))
return 1 if probability >= 0.5 else 0
return 1 if probability >= 0.4 else 0
if __name__ == "__main__":
# 以下代码可用于测试,可自行随意修改