diff --git a/doc/接口文档code.md b/doc/接口文档code.md index f2c2e0e..4d29cd9 100644 --- a/doc/接口文档code.md +++ b/doc/接口文档code.md @@ -500,26 +500,49 @@ Response: } ``` -### 2.8 模型预测 +### 2.9 模型预测 ```http -POST /api/predict +POST /api/model/predict Content-Type: application/json Request: { - "model_id": "model_20230820_001", + "run_id": "7970364d490f4e0aa0375c2db26215f3", "data": "dataset/dataset_processed/test.csv", - "output_path": "predictions/pred_20230820_001.csv" + "output_path": "predictions/pred_20250219_001.csv", + "batch_size": 32, + "device": "cuda", + "return_proba": true, + "metrics": ["accuracy", "f1", "precision", "recall"] } Response: { "status": "success", - "prediction_id": "pred_20230820_001", - "output_file": "predictions/pred_20230820_001.csv", - "metrics": { - "accuracy": 0.95, - "f1": 0.94 + "prediction": { + "id": "pred_20250219_001", + "run_id": "7970364d490f4e0aa0375c2db26215f3", + "model_name": "XGBClassifier", + "output_file": "predictions/pred_20250219_001.csv", + "prediction_time": "2025-02-19 15:30:45", + "samples_count": 1000, + "metrics": { + "accuracy": 0.956, + "f1": 0.948, + "precision": 0.962, + "recall": 0.935 + }, + "execution_time": "5.23s" + } +} + +Error Response: +{ + "status": "error", + "message": "模型预测失败", + "details": { + "error_type": "ValueError", + "error_message": "输入数据格式不正确" } } ``` diff --git a/example_model_delete.py b/example_model_delete.py new file mode 100644 index 0000000..4dc9e98 --- /dev/null +++ b/example_model_delete.py @@ -0,0 +1,6 @@ +from function.model_manager import ModelManager + +# 创建模型管理器实例 +manager = ModelManager() +back = manager.delete_model('7970364d490f4e0aa0375c2db26215f3') +print(back) \ No newline at end of file diff --git a/example_model_manager.py b/example_model_manager.py index a4791ab..f140197 100644 --- a/example_model_manager.py +++ b/example_model_manager.py @@ -7,7 +7,7 @@ manager = ModelManager() result = manager.get_finished_models( page=1, page_size=10, - experiment_name='breast_cancer_classification_2' + experiment_name='breast_cancer_classification_3' ) # 打印结果 diff --git a/example_model_predict.py b/example_model_predict.py new file mode 100644 index 0000000..68bcff2 --- /dev/null +++ b/example_model_predict.py @@ -0,0 +1,8 @@ +from function.model_manager import ModelManager + +model_manager = ModelManager() + +print(model_manager.predict(run_id = "33939ea6d8ce4d43a268f23f7361651e",\ + data_path="/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/breast_cancer_20250219_145614/test_breast_cancer_20250219_145614.csv",\ + output_path="predictions/pred_breast_cancer_20250219_145614.csv" ,\ + metrics= ["accuracy", "f1", "precision", "recall"] )) \ No newline at end of file diff --git a/example_model_trainer.py b/example_model_trainer.py index 285ad9f..ed0bc7b 100644 --- a/example_model_trainer.py +++ b/example_model_trainer.py @@ -30,7 +30,7 @@ model_config = { # 训练模型, 删除训练实验时要删除 mlruns/.trash/ 回收站里的文件 # 模型文件 直接在 mlruns/文件夹下 -for i in range(8, 20): +for i in range(3, 4): result = trainer.train_model( { 'features': X_train, diff --git a/function/__pycache__/model_manager.cpython-39.pyc b/function/__pycache__/model_manager.cpython-39.pyc index 16955e8..23d59e7 100644 Binary files a/function/__pycache__/model_manager.cpython-39.pyc and b/function/__pycache__/model_manager.cpython-39.pyc differ diff --git a/function/model_manager.py b/function/model_manager.py index 7abc74c..b8c36c5 100644 --- a/function/model_manager.py +++ b/function/model_manager.py @@ -4,9 +4,19 @@ import pandas as pd from typing import Dict, List, Optional import logging from pathlib import Path -import datetime +from datetime import datetime import yaml import json +import time +import os +import numpy as np +from sklearn.metrics import ( + accuracy_score, precision_score, recall_score, f1_score, roc_auc_score, + mean_absolute_error, mean_squared_error, r2_score, explained_variance_score, + adjusted_rand_score, homogeneity_score, completeness_score, silhouette_score +) +import torch +from torch.utils.data import DataLoader, TensorDataset class ModelManager: """模型管理类""" @@ -16,6 +26,7 @@ class ModelManager: self.config = config or {} self.logger = logging.getLogger(__name__) self._setup_logging() + self._metrics_map() # 初始化MLflow客户端 self.mlflow_uri = self.config.get('mlflow_uri', 'http://10.0.0.202:5000') @@ -28,13 +39,30 @@ class ModelManager: log_dir.mkdir(exist_ok=True) file_handler = logging.FileHandler( - log_dir / f'model_manager_{datetime.datetime.now():%Y%m%d_%H%M%S}.log' + log_dir / f'model_manager_{datetime.now():%Y%m%d_%H%M%S}.log' ) file_handler.setFormatter( logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ) self.logger.addHandler(file_handler) self.logger.setLevel(logging.INFO) + + def _metrics_map(self): + self.metrics_map={ + 'accuracy' : accuracy_score, + 'precision' : precision_score, + 'recall' : recall_score, + 'f1' : f1_score, + 'mae' : mean_absolute_error, + 'mse' : mean_squared_error, + # 'rmse' : np.sqrt(mean_absolute_error), # 这里要特殊处理一下 + 'r2': r2_score, + 'explained_variance' : explained_variance_score, + 'adjusted_rand' : adjusted_rand_score, + 'homogeneity' : homogeneity_score, + 'completeness': completeness_score, + 'silhouette' : silhouette_score + } def get_finished_models( self, @@ -269,4 +297,158 @@ class ModelManager: return { 'status': 'error', 'message': error_msg - } \ No newline at end of file + } + + def predict( + self, + run_id: str, + data_path: str, + output_path: str, + batch_size: int = 32, + device: str = 'cuda' if torch.cuda.is_available() else 'cpu', + return_proba: bool = True, + metrics: List[str] = None + ) -> Dict: + """ + 使用指定的模型进行预测 + + Args: + run_id: MLflow运行ID + data_path: 输入数据路径 + output_path: 预测结果保存路径 + batch_size: 批处理大小 + device: 计算设备 ('cuda' or 'cpu') + return_proba: 是否返回概率预测 + metrics: 评估指标列表 + + Returns: + 预测结果信息 + """ + # try: + start_time = time.time() + + # 获取模型信息 + run = self.client.get_run(run_id) + if not run: + return { + 'status': 'error', + 'message': f'未找到运行ID为 {run_id} 的模型' + } + + # 加载模型 + model = mlflow.pyfunc.load_model(f"runs:/{run_id}/model") + model_name = run.data.params.get('algorithm', 'Unknown') + + # 加载数据 + try: + data = pd.read_csv(data_path) + if 'label' in data.columns: + y_true = data.pop('label').values + has_labels = True + elif 'target' in data.columns: + y_true = data.pop('target').values + has_labels = True + else: + has_labels = False + X = data.values + except Exception as e: + return { + 'status': 'error', + 'message': '数据加载失败', + 'details': { + 'error_type': type(e).__name__, + 'error_message': str(e) + } + } + + # 创建预测ID + pred_id = f"pred_{datetime.now():%Y%m%d_%H%M%S}" + + # 进行预测 + if isinstance(model, torch.nn.Module): + # PyTorch模型预测 + model.to(device) + model.eval() + + dataset = TensorDataset(torch.FloatTensor(X)) + dataloader = DataLoader(dataset, batch_size=batch_size) + + predictions = [] + probas = [] + + with torch.no_grad(): + for batch in dataloader: + batch = batch[0].to(device) + outputs = model(batch) + + if return_proba: + proba = torch.softmax(outputs, dim=1) + probas.append(proba.cpu().numpy()) + + preds = outputs.argmax(dim=1) + predictions.append(preds.cpu().numpy()) + + predictions = np.concatenate(predictions) + if return_proba: + probas = np.concatenate(probas) + else: + # 其他模型预测 + predictions = model.predict(X) + if return_proba and hasattr(model, 'predict_proba'): + probas = model.predict_proba(X) + else: + probas = [] + + # 计算评估指标 + metrics_results = {} + if has_labels and metrics: + for metric in metrics: + if metric in self.metrics_map.keys(): + metrics_results[metric] = float(self.metrics_map[metric](y_true, predictions)) + + # 保存预测结果 + results_df = pd.DataFrame({ + 'prediction': predictions + }) + if return_proba and len(probas) > 0: + for i in range(probas.shape[1]): + results_df[f'probability_{i}'] = probas[:, i] + + # 确保输出目录存在 + os.makedirs(os.path.dirname(output_path), exist_ok=True) + results_df.to_csv(output_path, index=False) + + # 计算执行时间 + execution_time = time.time() - start_time + + # 记录日志 + self.logger.info( + f"预测完成 - Run ID: {run_id}, 模型: {model_name}, " + f"样本数: {len(predictions)}, 耗时: {execution_time:.2f}s" + ) + + return { + 'status': 'success', + 'prediction': { + 'id': pred_id, + 'run_id': run_id, + 'model_name': model_name, + 'output_file': output_path, + 'prediction_time': datetime.now().strftime('%Y-%m-%d %H:%M:%S'), + 'samples_count': len(predictions), + 'metrics': metrics_results, + 'execution_time': f"{execution_time:.2f}s" + } + } + + # except Exception as e: + # error_msg = f"预测过程发生错误: {str(e)}" + # self.logger.error(error_msg) + # return { + # 'status': 'error', + # 'message': '模型预测失败', + # 'details': { + # 'error_type': type(e).__name__, + # 'error_message': str(e) + # } + # } \ No newline at end of file diff --git a/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/MLmodel b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/MLmodel new file mode 100644 index 0000000..d646df5 --- /dev/null +++ b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/MLmodel @@ -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: 96534 +model_uuid: 80ec24f7f34643b9be9da8be761430eb +run_id: 725c551dce9c477391856e6ac41c75bf +utc_time_created: '2025-02-20 01:43:39.758338' diff --git a/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/conda.yaml b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/conda.yaml new file mode 100644 index 0000000..306a2fe --- /dev/null +++ b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/conda.yaml @@ -0,0 +1,15 @@ +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 + - xgboost==2.1.4 +name: mlflow-env diff --git a/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/model.pkl b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/model.pkl new file mode 100644 index 0000000..77a11d5 Binary files /dev/null and b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/model.pkl differ diff --git a/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/python_env.yaml b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/python_env.yaml new file mode 100644 index 0000000..48af243 --- /dev/null +++ b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/python_env.yaml @@ -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 diff --git a/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/requirements.txt b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/requirements.txt new file mode 100644 index 0000000..97e50bc --- /dev/null +++ b/mlartifacts/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts/model/requirements.txt @@ -0,0 +1,8 @@ +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 +xgboost==2.1.4 \ No newline at end of file diff --git a/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/MLmodel b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/MLmodel new file mode 100644 index 0000000..041b307 --- /dev/null +++ b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/MLmodel @@ -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: 96534 +model_uuid: 80a9b0fb66324b0f982aebb166759911 +run_id: d16c356bb3324ede819f9998d427780a +utc_time_created: '2025-02-20 01:44:24.622216' diff --git a/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/conda.yaml b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/conda.yaml new file mode 100644 index 0000000..306a2fe --- /dev/null +++ b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/conda.yaml @@ -0,0 +1,15 @@ +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 + - xgboost==2.1.4 +name: mlflow-env diff --git a/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/model.pkl b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/model.pkl new file mode 100644 index 0000000..77a11d5 Binary files /dev/null and b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/model.pkl differ diff --git a/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/python_env.yaml b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/python_env.yaml new file mode 100644 index 0000000..48af243 --- /dev/null +++ b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/python_env.yaml @@ -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 diff --git a/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/requirements.txt b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/requirements.txt new file mode 100644 index 0000000..97e50bc --- /dev/null +++ b/mlartifacts/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts/model/requirements.txt @@ -0,0 +1,8 @@ +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 +xgboost==2.1.4 \ No newline at end of file diff --git a/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/MLmodel b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/MLmodel new file mode 100644 index 0000000..53092bb --- /dev/null +++ b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/MLmodel @@ -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: 96534 +model_uuid: 770483f5da38405496fdedeef1cfe93f +run_id: 81b3390084a146bb949fec21c80dba2c +utc_time_created: '2025-02-20 01:43:43.110167' diff --git a/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/conda.yaml b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/conda.yaml new file mode 100644 index 0000000..306a2fe --- /dev/null +++ b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/conda.yaml @@ -0,0 +1,15 @@ +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 + - xgboost==2.1.4 +name: mlflow-env diff --git a/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/model.pkl b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/model.pkl new file mode 100644 index 0000000..77a11d5 Binary files /dev/null and b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/model.pkl differ diff --git a/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/python_env.yaml b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/python_env.yaml new file mode 100644 index 0000000..48af243 --- /dev/null +++ b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/python_env.yaml @@ -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 diff --git a/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/requirements.txt b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/requirements.txt new file mode 100644 index 0000000..97e50bc --- /dev/null +++ b/mlartifacts/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts/model/requirements.txt @@ -0,0 +1,8 @@ +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 +xgboost==2.1.4 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/meta.yaml b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/meta.yaml new file mode 100644 index 0000000..8965d9c --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: mlflow-artifacts:/189649205577051698/725c551dce9c477391856e6ac41c75bf/artifacts +end_time: 1740015822953 +entry_point_name: '' +experiment_id: '189649205577051698' +lifecycle_stage: active +run_id: 725c551dce9c477391856e6ac41c75bf +run_name: redolent-slug-558 +run_uuid: 725c551dce9c477391856e6ac41c75bf +source_name: '' +source_type: 4 +source_version: '' +start_time: 1740015819406 +status: 3 +tags: [] +user_id: admin-root diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/accuracy b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/accuracy new file mode 100644 index 0000000..92994bb --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/accuracy @@ -0,0 +1 @@ +1740015819735 0.961038961038961 0 diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/f1 b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/f1 new file mode 100644 index 0000000..b72cee5 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/f1 @@ -0,0 +1 @@ +1740015819747 0.9612318007520749 0 diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/precision b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/precision new file mode 100644 index 0000000..d1dcf35 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/precision @@ -0,0 +1 @@ +1740015819739 0.9617833147244911 0 diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/recall b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/recall new file mode 100644 index 0000000..64ce5ac --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/recall @@ -0,0 +1 @@ +1740015819743 0.961038961038961 0 diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/roc_auc b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/roc_auc new file mode 100644 index 0000000..5800c95 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/metrics/roc_auc @@ -0,0 +1 @@ +1740015819752 0.9607692307692308 0 diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/advantages b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/advantages new file mode 100644 index 0000000..000ed0a --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/advantages @@ -0,0 +1 @@ +['计算效率高,支持并行计算。', '具有内置的缺失值处理能力。'] \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/algorithm b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/algorithm new file mode 100644 index 0000000..66bf12d --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/algorithm @@ -0,0 +1 @@ +XGBClassifier \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/dataset b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/dataset new file mode 100644 index 0000000..054c281 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/dataset @@ -0,0 +1 @@ +/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/breast_cancer_20250219_144629 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/disadvantages b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/disadvantages new file mode 100644 index 0000000..88e781f --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/disadvantages @@ -0,0 +1 @@ +['参数较多,调优较复杂。'] \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/learning_rate b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/learning_rate new file mode 100644 index 0000000..ceab6e1 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/learning_rate @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/max_depth b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/max_depth new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/max_depth @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/n_estimators b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/n_estimators new file mode 100644 index 0000000..105d7d9 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/n_estimators @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/principle b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/principle new file mode 100644 index 0000000..517cab3 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/principle @@ -0,0 +1 @@ +XGBoost(Extreme Gradient Boosting)是一种基于梯度提升树(GBDT)的改进算法,具有更强的正则化和并行处理能力。 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/random_state b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/task_type b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/task_type new file mode 100644 index 0000000..21cdd17 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/params/task_type @@ -0,0 +1 @@ +classification \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.log-model.history b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.log-model.history new file mode 100644 index 0000000..0aaa7b4 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "725c551dce9c477391856e6ac41c75bf", "artifact_path": "model", "utc_time_created": "2025-02-20 01:43:39.758338", "model_uuid": "80ec24f7f34643b9be9da8be761430eb", "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}}}] \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.runName b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.runName new file mode 100644 index 0000000..00eb569 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.runName @@ -0,0 +1 @@ +redolent-slug-558 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.git.commit b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.git.commit new file mode 100644 index 0000000..1bafb01 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +7b99da7251d23ceb9b3dfbb599e96dc00054e961 \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.name b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.name new file mode 100644 index 0000000..6e8e26b --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.name @@ -0,0 +1 @@ +/home/admin-root/haotian/MLPlatform/example_model_trainer.py \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.type b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.user b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.user new file mode 100644 index 0000000..9c59705 --- /dev/null +++ b/mlruns/189649205577051698/725c551dce9c477391856e6ac41c75bf/tags/mlflow.user @@ -0,0 +1 @@ +admin-root \ No newline at end of file diff --git a/mlruns/189649205577051698/meta.yaml b/mlruns/189649205577051698/meta.yaml new file mode 100644 index 0000000..aae0aa2 --- /dev/null +++ b/mlruns/189649205577051698/meta.yaml @@ -0,0 +1,6 @@ +artifact_location: mlflow-artifacts:/189649205577051698 +creation_time: 1740015819325 +experiment_id: '189649205577051698' +last_update_time: 1740015819325 +lifecycle_stage: active +name: breast_cancer_classification_1 diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/meta.yaml b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/meta.yaml new file mode 100644 index 0000000..ab07d61 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: mlflow-artifacts:/433321862082712659/d16c356bb3324ede819f9998d427780a/artifacts +end_time: 1740015867827 +entry_point_name: '' +experiment_id: '433321862082712659' +lifecycle_stage: active +run_id: d16c356bb3324ede819f9998d427780a +run_name: skillful-swan-139 +run_uuid: d16c356bb3324ede819f9998d427780a +source_name: '' +source_type: 4 +source_version: '' +start_time: 1740015864275 +status: 3 +tags: [] +user_id: admin-root diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/accuracy b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/accuracy new file mode 100644 index 0000000..8d91454 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/accuracy @@ -0,0 +1 @@ +1740015864600 0.961038961038961 0 diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/f1 b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/f1 new file mode 100644 index 0000000..6a6b476 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/f1 @@ -0,0 +1 @@ +1740015864611 0.9612318007520749 0 diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/precision b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/precision new file mode 100644 index 0000000..a15f824 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/precision @@ -0,0 +1 @@ +1740015864604 0.9617833147244911 0 diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/recall b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/recall new file mode 100644 index 0000000..eb31212 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/recall @@ -0,0 +1 @@ +1740015864607 0.961038961038961 0 diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/roc_auc b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/roc_auc new file mode 100644 index 0000000..34e3ec2 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/metrics/roc_auc @@ -0,0 +1 @@ +1740015864616 0.9607692307692308 0 diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/advantages b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/advantages new file mode 100644 index 0000000..000ed0a --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/advantages @@ -0,0 +1 @@ +['计算效率高,支持并行计算。', '具有内置的缺失值处理能力。'] \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/algorithm b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/algorithm new file mode 100644 index 0000000..66bf12d --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/algorithm @@ -0,0 +1 @@ +XGBClassifier \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/dataset b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/dataset new file mode 100644 index 0000000..054c281 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/dataset @@ -0,0 +1 @@ +/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/breast_cancer_20250219_144629 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/disadvantages b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/disadvantages new file mode 100644 index 0000000..88e781f --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/disadvantages @@ -0,0 +1 @@ +['参数较多,调优较复杂。'] \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/learning_rate b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/learning_rate new file mode 100644 index 0000000..ceab6e1 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/learning_rate @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/max_depth b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/max_depth new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/max_depth @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/n_estimators b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/n_estimators new file mode 100644 index 0000000..105d7d9 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/n_estimators @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/principle b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/principle new file mode 100644 index 0000000..517cab3 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/principle @@ -0,0 +1 @@ +XGBoost(Extreme Gradient Boosting)是一种基于梯度提升树(GBDT)的改进算法,具有更强的正则化和并行处理能力。 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/random_state b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/task_type b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/task_type new file mode 100644 index 0000000..21cdd17 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/params/task_type @@ -0,0 +1 @@ +classification \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.log-model.history b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.log-model.history new file mode 100644 index 0000000..bae8e73 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "d16c356bb3324ede819f9998d427780a", "artifact_path": "model", "utc_time_created": "2025-02-20 01:44:24.622216", "model_uuid": "80a9b0fb66324b0f982aebb166759911", "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}}}] \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.runName b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.runName new file mode 100644 index 0000000..36cee8a --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.runName @@ -0,0 +1 @@ +skillful-swan-139 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.git.commit b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.git.commit new file mode 100644 index 0000000..1bafb01 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +7b99da7251d23ceb9b3dfbb599e96dc00054e961 \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.name b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.name new file mode 100644 index 0000000..6e8e26b --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.name @@ -0,0 +1 @@ +/home/admin-root/haotian/MLPlatform/example_model_trainer.py \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.type b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.user b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.user new file mode 100644 index 0000000..9c59705 --- /dev/null +++ b/mlruns/433321862082712659/d16c356bb3324ede819f9998d427780a/tags/mlflow.user @@ -0,0 +1 @@ +admin-root \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/meta.yaml b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/meta.yaml new file mode 100644 index 0000000..bc89591 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/meta.yaml @@ -0,0 +1,15 @@ +artifact_uri: mlflow-artifacts:/656341556838275234/81b3390084a146bb949fec21c80dba2c/artifacts +end_time: 1740015825618 +entry_point_name: '' +experiment_id: '656341556838275234' +lifecycle_stage: active +run_id: 81b3390084a146bb949fec21c80dba2c +run_name: rebellious-fish-472 +run_uuid: 81b3390084a146bb949fec21c80dba2c +source_name: '' +source_type: 4 +source_version: '' +start_time: 1740015822972 +status: 3 +tags: [] +user_id: admin-root diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/accuracy b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/accuracy new file mode 100644 index 0000000..51e98cf --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/accuracy @@ -0,0 +1 @@ +1740015823091 0.961038961038961 0 diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/f1 b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/f1 new file mode 100644 index 0000000..da0b868 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/f1 @@ -0,0 +1 @@ +1740015823104 0.9612318007520749 0 diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/precision b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/precision new file mode 100644 index 0000000..729a62a --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/precision @@ -0,0 +1 @@ +1740015823096 0.9617833147244911 0 diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/recall b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/recall new file mode 100644 index 0000000..3a33225 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/recall @@ -0,0 +1 @@ +1740015823100 0.961038961038961 0 diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/roc_auc b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/roc_auc new file mode 100644 index 0000000..75f0786 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/metrics/roc_auc @@ -0,0 +1 @@ +1740015823106 0.9607692307692308 0 diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/advantages b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/advantages new file mode 100644 index 0000000..000ed0a --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/advantages @@ -0,0 +1 @@ +['计算效率高,支持并行计算。', '具有内置的缺失值处理能力。'] \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/algorithm b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/algorithm new file mode 100644 index 0000000..66bf12d --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/algorithm @@ -0,0 +1 @@ +XGBClassifier \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/dataset b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/dataset new file mode 100644 index 0000000..054c281 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/dataset @@ -0,0 +1 @@ +/home/admin-root/haotian/MLPlatform/dataset/dataset_processed/breast_cancer_20250219_144629 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/disadvantages b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/disadvantages new file mode 100644 index 0000000..88e781f --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/disadvantages @@ -0,0 +1 @@ +['参数较多,调优较复杂。'] \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/learning_rate b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/learning_rate new file mode 100644 index 0000000..ceab6e1 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/learning_rate @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/max_depth b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/max_depth new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/max_depth @@ -0,0 +1 @@ +6 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/n_estimators b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/n_estimators new file mode 100644 index 0000000..105d7d9 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/n_estimators @@ -0,0 +1 @@ +100 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/principle b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/principle new file mode 100644 index 0000000..517cab3 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/principle @@ -0,0 +1 @@ +XGBoost(Extreme Gradient Boosting)是一种基于梯度提升树(GBDT)的改进算法,具有更强的正则化和并行处理能力。 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/random_state b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/random_state new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/random_state @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/task_type b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/task_type new file mode 100644 index 0000000..21cdd17 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/params/task_type @@ -0,0 +1 @@ +classification \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.log-model.history b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.log-model.history new file mode 100644 index 0000000..239c25d --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.log-model.history @@ -0,0 +1 @@ +[{"run_id": "81b3390084a146bb949fec21c80dba2c", "artifact_path": "model", "utc_time_created": "2025-02-20 01:43:43.110167", "model_uuid": "770483f5da38405496fdedeef1cfe93f", "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}}}] \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.runName b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.runName new file mode 100644 index 0000000..39841da --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.runName @@ -0,0 +1 @@ +rebellious-fish-472 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.git.commit b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.git.commit new file mode 100644 index 0000000..1bafb01 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.git.commit @@ -0,0 +1 @@ +7b99da7251d23ceb9b3dfbb599e96dc00054e961 \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.name b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.name new file mode 100644 index 0000000..6e8e26b --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.name @@ -0,0 +1 @@ +/home/admin-root/haotian/MLPlatform/example_model_trainer.py \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.type b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.type new file mode 100644 index 0000000..0c2c1fe --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.source.type @@ -0,0 +1 @@ +LOCAL \ No newline at end of file diff --git a/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.user b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.user new file mode 100644 index 0000000..9c59705 --- /dev/null +++ b/mlruns/656341556838275234/81b3390084a146bb949fec21c80dba2c/tags/mlflow.user @@ -0,0 +1 @@ +admin-root \ No newline at end of file diff --git a/predictions/pred_breast_cancer_20250219_145614.csv b/predictions/pred_breast_cancer_20250219_145614.csv new file mode 100644 index 0000000..ba9adf2 --- /dev/null +++ b/predictions/pred_breast_cancer_20250219_145614.csv @@ -0,0 +1,104 @@ +prediction +0 +1 +0 +0 +1 +0 +1 +1 +0 +1 +1 +0 +1 +1 +0 +1 +1 +0 +0 +0 +1 +1 +1 +0 +0 +0 +1 +1 +1 +1 +1 +0 +1 +1 +1 +0 +0 +0 +0 +0 +1 +0 +1 +0 +0 +1 +0 +1 +1 +1 +1 +1 +1 +0 +1 +1 +0 +1 +1 +0 +1 +1 +0 +0 +1 +1 +0 +0 +0 +0 +0 +1 +0 +1 +1 +0 +0 +1 +1 +0 +1 +0 +1 +1 +1 +1 +0 +1 +1 +1 +1 +1 +1 +1 +0 +1 +1 +1 +1 +1 +1 +1 +1 diff --git a/test_model_manager.py b/test_model_manager.py new file mode 100644 index 0000000..47b6471 --- /dev/null +++ b/test_model_manager.py @@ -0,0 +1,99 @@ +import pytest +import pandas as pd +import numpy as np +import mlflow +from pathlib import Path +from function.model_manager import ModelManager + +class TestModelManager: + @pytest.fixture + def model_manager(self): + return ModelManager() + + @pytest.fixture + def sample_data(self): + # 创建测试数据 + np.random.seed(42) + n_samples = 100 + X = np.random.randn(n_samples, 4) + y = (X[:, 0] + X[:, 1] > 0).astype(int) + + # 保存测试数据 + data_dir = Path("dataset/dataset_processed/test_data") + data_dir.mkdir(parents=True, exist_ok=True) + + df = pd.DataFrame(X, columns=[f'feature_{i}' for i in range(4)]) + df['label'] = y + + data_path = data_dir / "test_data.csv" + df.to_csv(data_path, index=False) + + return str(data_path) + + @pytest.fixture + def trained_model(self, sample_data): + # 训练一个简单的模型用于测试 + from sklearn.ensemble import RandomForestClassifier + + # 加载数据 + data = pd.read_csv(sample_data) + X = data.drop('label', axis=1).values + y = data['label'].values + + # 训练模型 + model = RandomForestClassifier(n_estimators=10, random_state=42) + model.fit(X, y) + + # 使用MLflow记录模型 + with mlflow.start_run() as run: + mlflow.sklearn.log_model(model, "model") + mlflow.log_param("algorithm", "RandomForestClassifier") + + return run.info.run_id + + def test_predict(self, model_manager, sample_data, trained_model): + # 设置输出路径 + output_dir = Path("predictions/test") + output_dir.mkdir(parents=True, exist_ok=True) + output_path = str(output_dir / "test_predictions.csv") + + # 执行预测 + result = model_manager.predict( + run_id=trained_model, + data_path=sample_data, + output_path=output_path, + metrics=['accuracy', 'f1'] + ) + + # 验证结果 + assert result['status'] == 'success' + assert 'prediction' in result + assert Path(result['prediction']['output_file']).exists() + assert result['prediction']['samples_count'] == 100 + assert 'accuracy' in result['prediction']['metrics'] + assert 'f1' in result['prediction']['metrics'] + + # 验证预测结果格式 + predictions = pd.read_csv(output_path) + assert 'prediction' in predictions.columns + assert len(predictions) == 100 + + def test_predict_invalid_run_id(self, model_manager, sample_data): + result = model_manager.predict( + run_id="invalid_run_id", + data_path=sample_data, + output_path="predictions/test/invalid.csv" + ) + + assert result['status'] == 'error' + assert '未找到运行ID' in result['message'] + + def test_predict_invalid_data_path(self, model_manager, trained_model): + result = model_manager.predict( + run_id=trained_model, + data_path="invalid/path/data.csv", + output_path="predictions/test/invalid.csv" + ) + + assert result['status'] == 'error' + assert '数据加载失败' in result['message'] \ No newline at end of file