generated from LufsX/Experiment-LogReg
This commit is contained in:
+4
-4
@@ -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")
|
||||
|
||||
# 这里可能需要确保调用和处理的逻辑符合你的数据处理需求
|
||||
|
||||
Reference in New Issue
Block a user