generated from LufsX/Experiment-LogReg
This commit is contained in:
+8
-1
@@ -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")
|
||||
|
||||
# 划分训练集和测试集
|
||||
|
||||
Reference in New Issue
Block a user