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

This commit is contained in:
2024-11-03 17:09:50 +08:00
parent af98d5ec62
commit efd5bbf165
+8 -1
View File
@@ -38,7 +38,13 @@ def preprocess_data(X):
def train_logreg(X, y):
X_processed = preprocess_data(X) # 预处理训练数据
model = RandomForestClassifier(n_estimators=200, max_depth=20, min_samples_split=5, random_state=42)
model = RandomForestClassifier(
n_estimators=300, # 增加树的数量
max_depth=25, # 调整最大深度
min_samples_split=5,
class_weight='balanced', # 处理类别不平衡
random_state=42
)
model.fit(X_processed, y)
return model # 返回训练好的模型
@@ -51,6 +57,7 @@ def predict_logreg(X, model):
if __name__ == "__main__":
# 数据加载和预处理保持不变
X, y = load_data("./data/horse-colic.data")
# 划分训练集和测试集