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

This commit is contained in:
2024-11-03 21:25:54 +08:00
parent 164dbd8c09
commit afa2480af3
+2 -7
View File
@@ -58,20 +58,15 @@ if __name__ == "__main__":
# 加载训练集
X_train, y_train = load_data("./data/horse-colic.data")
# 数据标准化
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
# 训练逻辑回归模型
model, _ = train_logreg(X_train, y_train) # 只需要模型和缩放器
model, scaler = train_logreg(X_train, y_train) # 直接使用 train_logreg 处理标准化
# 测试单个数据
X_test, y_test = load_data("./data/horse-colic.test")
X_test = scaler.transform(X_test) # 同样标准化测试集
X_test = scaler.transform(X_test) # 标准化测试集
# 进行预测
y_pred = predict_logreg(model, scaler, X_test[11]) # 传递模型和缩放器
print(f"预测结果: {y_pred}, 实际结果: {y_test[11]}")