上传文件至 /
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 29s

This commit is contained in:
2024-11-03 16:01:58 +08:00
parent c629ff8070
commit cd6439c534
+4 -4
View File
@@ -30,14 +30,14 @@ def preprocess_data(X):
return X_poly
def train_logreg(X, y):
X_processed = preprocess_data(X) # 预处理训练数据
model = RandomForestClassifier(n_estimators=113, max_depth=10, random_state=42)
model.fit(X, y)
model.fit(X_processed, y)
return model # 返回训练好的模型
def predict_logreg(model, X):
return model.predict(X.reshape(1, -1))[0] # 确保 model 是训练好的模型
X_processed = preprocess_data(X.reshape(1, -1)) # 预处理测试数据
return model.predict(X_processed)[0] # 确保 model 是训练好的模型
if __name__ == "__main__":
X, y = load_data("./data/horse-colic.data")
# 这里可能需要确保调用和处理的逻辑符合你的数据处理需求