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

This commit is contained in:
2024-11-03 15:54:03 +08:00
parent 7a87d84eb9
commit c629ff8070
+3 -4
View File
@@ -18,7 +18,6 @@ def load_data(filepath):
data = np.array(data)
data = np.nan_to_num(data, nan=np.nanmean(data, axis=0))
# 这里需要根据具体数据格式调整
X = data[:, :-1] # 特征
y = data[:, -1] # 标签
return X, y
@@ -33,12 +32,12 @@ def preprocess_data(X):
def train_logreg(X, y):
model = RandomForestClassifier(n_estimators=113, max_depth=10, random_state=42)
model.fit(X, y)
return model
return model # 返回训练好的模型
def predict_logreg(model, X):
# X 应该是一个单独的样本,确保它的形状是 (1, n_features)
return model.predict(X.reshape(1, -1))[0]
return model.predict(X.reshape(1, -1))[0] # 确保 model 是训练好的模型
if __name__ == "__main__":
X, y = load_data("./data/horse-colic.data")
# 这里可能需要确保调用和处理的逻辑符合你的数据处理需求