AI开发平台MODELARTS-模型配置文件编写说明:预测分析模型配置文件示例

时间:2024-08-16 20:39:15

预测分析模型配置文件示例

如下代码以TensorFlow引擎为例,您可以根据实际使用的引擎类型修改model_type参数后使用。

  • 模型输入
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    {
        "data": {
            "req_data": [
                {
                    "buying_price": "high",
                    "maint_price": "high",
                    "doors": "2",
                    "persons": "2",
                    "lug_boot": "small",
                    "safety": "low",
                    "acceptability": "acc"
                },
                {
                    "buying_price": "high",
                    "maint_price": "high",
                    "doors": "2",
                    "persons": "2",
                    "lug_boot": "small",
                    "safety": "low",
                    "acceptability": "acc"
                }
            ]
        }
    }
    
  • 模型输出
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    {
        "data": {
            "resp_data": [
                {
                    "predict_result": "unacc"
                },
                {
                    "predict_result": "unacc"
                }
            ]
        }
    }
    
  • 配置文件

    代码中request结构和response结构中的data参数是json schema数据结构。data/properties里面的内容对应“模型输入”“模型输出”

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    {
        "model_type": "TensorFlow",
        "model_algorithm": "predict_analysis",
        "metrics": {
            "f1": 0.345294,
            "accuracy": 0.462963,
            "precision": 0.338977,
            "recall": 0.351852
        },
        "apis": [
            {
                "url": "/",
                "method": "post",
                "request": {
                    "Content-type": "application/json",
                    "data": {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "req_data": {
                                        "items": [
                                            {
                                                "type": "object",
                                                "properties": {}
                                            }
                                        ],
                                        "type": "array"
                                    }
                                }
                            }
                        }
                    }
                },
                "response": {
                    "Content-type": "application/json",
                    "data": {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "resp_data": {
                                        "type": "array",
                                        "items": [
                                            {
                                                "type": "object",
                                                "properties": {}
                                            }
                                        ]
                                    }
                                }
                           }
                        }
                    }
                }
            }
        ],
        "dependencies": [
            {
                "installer": "pip",
                "packages": [
                    {
                        "restraint": "EXACT",
                        "package_version": "1.15.0",
                        "package_name": "numpy"
                    },
                    {
                        "restraint": "EXACT",
                        "package_version": "5.2.0",
                        "package_name": "Pillow"
                    }
                ]
            }
        ]
    }
    
support.huaweicloud.com/usermanual-standard-modelarts/inference-modelarts-0056.html