修改--添加对于没有标签的csv文件处理
This commit is contained in:
parent
9af1e44eba
commit
5297a81a81
@ -467,17 +467,14 @@ Content-Type: application/json
|
||||
|
||||
Request:
|
||||
{
|
||||
"train_path": "/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/breast_cancer_20250224_170615/train_breast_cancer_20250224_170615.csv",
|
||||
"val_path": "/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/breast_cancer_20250224_170615/val_breast_cancer_20250224_170615.csv",
|
||||
"algorithm": "XGBClassifier",
|
||||
"task_type": "classification",
|
||||
"train_path": "/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/train_FD001_20250407_174421/train_train_FD001_20250407_174421.csv",
|
||||
"val_path": "/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/train_FD001_20250407_174421/val_train_FD001_20250407_174421.csv",
|
||||
"algorithm": "RandomForestRegressor",
|
||||
"task_type": "regression",
|
||||
"parameters": {
|
||||
"n_estimators": 100,
|
||||
"learning_rate": 0.1,
|
||||
"max_depth": 6,
|
||||
"random_state": 42
|
||||
|
||||
},
|
||||
"experiment_name": "test_post_1"
|
||||
"experiment_name": "test_FD001_1"
|
||||
}
|
||||
|
||||
Response:
|
||||
@ -585,6 +582,18 @@ Request:
|
||||
"metrics": ["accuracy", "f1", "precision", "recall"]
|
||||
}
|
||||
|
||||
{
|
||||
"run_id": "bb9da59ee214462196f63b18fd715d7c",
|
||||
"data_path": "/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/train_FD001_20250407_174421/train_train_FD001_20250407_174421.csv",
|
||||
"output_path": "predictions/train_train_FD001_20250407_174421.csv",
|
||||
"batch_size": 32,
|
||||
"device": "cuda",
|
||||
"return_proba": true,
|
||||
"metrics": [
|
||||
"mae", "mse", "rmse"
|
||||
]
|
||||
}
|
||||
|
||||
Response:
|
||||
{
|
||||
"status": "success",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -343,9 +343,12 @@ class DataManager:
|
||||
|
||||
processor = self.feature_engineering_methods[method_name](**params)
|
||||
|
||||
# 分离特征和标签
|
||||
features = df.drop('target', axis=1)
|
||||
target = df['target']
|
||||
# # 分离特征和标签
|
||||
# features = df.drop('target', axis=1)
|
||||
# target = df['target']
|
||||
target_col = df.columns[-1]
|
||||
features = df.iloc[:, :-1] # 所有列除了最后一列作为特征
|
||||
target = df[target_col] # 最后一列作为目标列
|
||||
|
||||
# 根据不同类型的特征工程方法进行处理
|
||||
if method_name in ['LabelEncoder', 'OneHotEncoder']:
|
||||
|
||||
@ -38,7 +38,7 @@ class ModelManager:
|
||||
self.parameter_config = self._load_parameter_config()
|
||||
|
||||
# 初始化MLflow客户端
|
||||
self.mlflow_uri = self.config.get('mlflow_uri', 'http://10.0.0.202:5000')
|
||||
self.mlflow_uri = self.config.get('mlflow_uri', 'http://127.0.0.1:5000')
|
||||
mlflow.set_tracking_uri(self.mlflow_uri)
|
||||
self.client = MlflowClient()
|
||||
|
||||
@ -510,16 +510,23 @@ class ModelManager:
|
||||
|
||||
# 加载数据
|
||||
try:
|
||||
X = None
|
||||
data = pd.read_csv(data_path)
|
||||
if 'label' in data.columns:
|
||||
y_true = data.pop('label').values
|
||||
has_labels = True
|
||||
X = data.values
|
||||
elif 'target' in data.columns:
|
||||
y_true = data.pop('target').values
|
||||
has_labels = True
|
||||
X = data.values
|
||||
else:
|
||||
has_labels = False
|
||||
X = data.values
|
||||
# 将最后一列默认为真值
|
||||
target_col = data.columns[-1]
|
||||
X = data.iloc[:, :-1]
|
||||
y_true = data[target_col]
|
||||
has_labels = True
|
||||
|
||||
except Exception as e:
|
||||
return {
|
||||
'status': 'error',
|
||||
@ -823,10 +830,12 @@ class ModelManager:
|
||||
}
|
||||
|
||||
# 准备特征和标签
|
||||
X_train = train_data.drop('target', axis=1)
|
||||
y_train = train_data['target']
|
||||
X_val = val_data.drop('target', axis=1)
|
||||
y_val = val_data['target']
|
||||
target_col_train = train_data.columns[-1]
|
||||
target_col_val = val_data.columns[-1]
|
||||
X_train = train_data.iloc[:, :-1]
|
||||
y_train = train_data[target_col_train]
|
||||
X_val = val_data.iloc[:, :-1]
|
||||
y_val = val_data[target_col_val]
|
||||
|
||||
with mlflow.start_run() as run:
|
||||
# 记录基本信息
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
artifact_path: model
|
||||
flavors:
|
||||
python_function:
|
||||
env:
|
||||
conda: conda.yaml
|
||||
virtualenv: python_env.yaml
|
||||
loader_module: mlflow.sklearn
|
||||
model_path: model.pkl
|
||||
predict_fn: predict
|
||||
python_version: 3.9.19
|
||||
sklearn:
|
||||
code: null
|
||||
pickled_model: model.pkl
|
||||
serialization_format: cloudpickle
|
||||
sklearn_version: 1.5.2
|
||||
mlflow_version: 2.20.1
|
||||
model_size_bytes: 146181674
|
||||
model_uuid: e6e9a652b1454b419a61bf14ab18e620
|
||||
run_id: bb9da59ee214462196f63b18fd715d7c
|
||||
utc_time_created: '2025-04-07 10:01:44.355103'
|
||||
@ -0,0 +1,14 @@
|
||||
channels:
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- python=3.9.19
|
||||
- pip<=24.0
|
||||
- pip:
|
||||
- mlflow==2.20.1
|
||||
- cloudpickle==3.1.0
|
||||
- numpy==1.26.4
|
||||
- pandas==2.2.2
|
||||
- psutil==6.0.0
|
||||
- scikit-learn==1.5.2
|
||||
- scipy==1.13.1
|
||||
name: mlflow-env
|
||||
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
python: 3.9.19
|
||||
build_dependencies:
|
||||
- pip==24.0
|
||||
- setuptools==60.2.0
|
||||
- wheel==0.43.0
|
||||
dependencies:
|
||||
- -r requirements.txt
|
||||
@ -0,0 +1,7 @@
|
||||
mlflow==2.20.1
|
||||
cloudpickle==3.1.0
|
||||
numpy==1.26.4
|
||||
pandas==2.2.2
|
||||
psutil==6.0.0
|
||||
scikit-learn==1.5.2
|
||||
scipy==1.13.1
|
||||
@ -0,0 +1,15 @@
|
||||
artifact_uri: mlflow-artifacts:/403693873596104927/bb9da59ee214462196f63b18fd715d7c/artifacts
|
||||
end_time: 1744020107001
|
||||
entry_point_name: ''
|
||||
experiment_id: '403693873596104927'
|
||||
lifecycle_stage: active
|
||||
run_id: bb9da59ee214462196f63b18fd715d7c
|
||||
run_name: vaunted-goose-426
|
||||
run_uuid: bb9da59ee214462196f63b18fd715d7c
|
||||
source_name: ''
|
||||
source_type: 4
|
||||
source_version: ''
|
||||
start_time: 1744020088239
|
||||
status: 3
|
||||
tags: []
|
||||
user_id: admin-root
|
||||
@ -0,0 +1 @@
|
||||
1744020104350 0.5114799809623347 0
|
||||
@ -0,0 +1 @@
|
||||
1744020104339 43.59667474551624 0
|
||||
@ -0,0 +1 @@
|
||||
1744020104343 3082.0063123121668 0
|
||||
@ -0,0 +1 @@
|
||||
1744020104348 0.5106799014610408 0
|
||||
@ -0,0 +1 @@
|
||||
1744020104345 55.51582037862871 0
|
||||
@ -0,0 +1 @@
|
||||
['不容易过拟合,适用于复杂问题', '能够处理缺失数据']
|
||||
@ -0,0 +1 @@
|
||||
RandomForestRegressor
|
||||
@ -0,0 +1 @@
|
||||
/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/train_FD001_20250407_174421/train_train_FD001_20250407_174421.csv
|
||||
@ -0,0 +1 @@
|
||||
/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/train_FD001_20250407_174421/val_train_FD001_20250407_174421.csv
|
||||
@ -0,0 +1 @@
|
||||
['计算复杂度较高', '结果难以解释']
|
||||
@ -0,0 +1 @@
|
||||
随机森林回归通过集成多棵决策树的结果来提高预测精度,能够处理高维数据。
|
||||
@ -0,0 +1 @@
|
||||
regression
|
||||
@ -0,0 +1 @@
|
||||
[{"run_id": "bb9da59ee214462196f63b18fd715d7c", "artifact_path": "model", "utc_time_created": "2025-04-07 10:01:44.355103", "model_uuid": "e6e9a652b1454b419a61bf14ab18e620", "flavors": {"python_function": {"model_path": "model.pkl", "predict_fn": "predict", "loader_module": "mlflow.sklearn", "python_version": "3.9.19", "env": {"conda": "conda.yaml", "virtualenv": "python_env.yaml"}}, "sklearn": {"pickled_model": "model.pkl", "sklearn_version": "1.5.2", "serialization_format": "cloudpickle", "code": null}}}]
|
||||
@ -0,0 +1 @@
|
||||
vaunted-goose-426
|
||||
@ -0,0 +1 @@
|
||||
9af1e44eba8268173b6fa731efbdac5fc55b0c96
|
||||
@ -0,0 +1 @@
|
||||
main.py
|
||||
@ -0,0 +1 @@
|
||||
LOCAL
|
||||
@ -0,0 +1 @@
|
||||
admin-root
|
||||
6
mlruns/403693873596104927/meta.yaml
Normal file
6
mlruns/403693873596104927/meta.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
artifact_location: mlflow-artifacts:/403693873596104927
|
||||
creation_time: 1744019800920
|
||||
experiment_id: '403693873596104927'
|
||||
last_update_time: 1744019800920
|
||||
lifecycle_stage: active
|
||||
name: test_FD001_1
|
||||
Loading…
Reference in New Issue
Block a user