여러 입력 스트림을 사용하여 모델에 데이터를 제공하는 SPSS Modeler 흐름에 대한 온라인 배포를 만들 수 있습니다.
프로세스 개요
여러 입력 스트림을 사용하여 SPSS Modeler 흐름을 만드는 경우, 모델에 대한 온라인 배포를 만들 수 있습니다.
다음 그래픽은 두 개의 입력 스트림을 사용하는 SPSS Modeler 흐름을 보여줍니다. 이 흐름은 데이터를 처리하고 머신 러닝 모델을 생성합니다. 이 모델을 저장하고 온라인 배포를 만들 수 있습니다. 모델을 배포한 후에는 엔드포인트를 사용하여 애플리케이션에서 채점할 수 있습니다.
다중 소스 SPSS Modeler 흐름 배포를 위한 작업
사용자 인터페이스 또는 watsonx.ai REST API에서 다중 소스 SPSS Modeler 흐름을 생성하고 배포할 수 있습니다.
사용자 인터페이스에서 모델 만들기 및 배포하기
다음 단계에 따라 사용자 인터페이스에서 다중 소스 SPSS Modeler 흐름을 만들고 배포합니다:
- SPSS Modeler 흐름을 만듭니다 : SPSS Modeler 흐름을 생성하여 프로젝트에서 다중 소스 모델을 만들 수 있습니다.
- 모델 에셋 승 격: 모델을 생성한 후 프로젝트에서 배포 공간으로 모델 에셋을 승격합니다.
- 모델을 배포합니다 : 채점에 엔드포인트를 사용할 온라인 배포를 만듭니다.
- 배포된 모델을 테스트합니다 : 배포된 모델에 대해 점수를 매깁니다.
REST API에서 모델 만들기 및 배포하기
다음 단계에 따라 watsonx.ai REST API에서 다중 소스 SPSS Modeler 흐름을 만들고 배포하세요:
- 모델을 만듭니다 : 스키마를 제공하여 멀티소스 모델을 만들 수 있습니다.
- 모델 콘텐츠를 업로드합니다 : 모델을 생성한 후에는 watsonx.ai 런타임의 리포지토리 자산에 모델용 콘텐츠를 업로드해야 합니다.
- 모델을 배포합니다 : 채점에 엔드포인트를 사용할 온라인 배포를 만듭니다.
- 배포된 모델을 테스트합니다 : 배포된 모델에 대해 점수를 매깁니다.
사용자 인터페이스에서 멀티소스 모델 만들기 및 배포하기
다음 단계에 따라 SPSS Modeler 다중 소스 모델을 만들고 사용자 인터페이스에서 모델을 배포합니다.
작업 1: SPSS Modeler 다중 소스 모델 만들기
SPSS Modeler 흐름을 생성하여 다중 소스 모델을 만들 수 있습니다. 자세한 내용은 SPSS Modeler 흐름 만들기를 참조하십시오.
작업 2: 모델 자산 홍보
모드를 배포하려면 SPSS Modeler 사용하여 생성한 모델 자산을 배포 공간으로 승격해야 합니다. 자세한 내용은 배포 공간으로 에셋 승격을 참조하세요.
작업 3: 멀티소스 모델 배포하기
SPSS Modeler 여러 입력 소스를 사용하여 만든 기계 학습 모델의 온라인 배포를 만들려면 다음 단계를 따르세요:
전제조건
AI 서비스를 배포하려면 작업 자격 증명을 설정해야 합니다. 자세한 내용은 작업 자격 증명 관리하기를 참조하세요.
배포 공간에서 자산 탭으로 이동합니다.
머신 러닝 모델의 경우 메뉴 아이콘을 클릭하고 배포를 선택합니다.
배포 유형으로 온라인을 선택합니다.
배포 이름을 입력하고 선택적으로 서비스 이름, 설명 및 태그를 입력합니다.
작성을 클릭하십시오.
작업 4: 배포된 모델 테스트
배포된 모델에 텍스트 또는 JSON 형식의 입력을 제공하여 점수를 매길 수 있습니다.
배포된 모델을 채점하려면 다음 단계를 따르세요:
- 배포 공간 또는 프로젝트에서 배포 탭을 열고 배포 이름을 클릭합니다.
- 테스트 탭을 클릭하여 프롬프트 텍스트를 입력하고 배포된 에셋에서 응답을 받습니다.
- 텍스트 또는 JSON 형식의 테스트 데이터를 입력하여 출력을 생성합니다.
REST API를 사용하여 다중 소스 SPSS Modeler 흐름 생성 및 배포
다음 단계에 따라 SPSS Modeler 다중 소스 모델을 만들고 watsonx.ai REST API에서 모델을 배포합니다.
작업 1: SPSS Modeler 다중 소스 모델 만들기
SPSS Modeler 사용하여 여러 입력 소스가 있는 모델을 만들 수 있습니다.
JSON 형식의 모델 스키마에 대한 요구 사항
JSON 형식의 다중 입력 모델 스키마를 생성하는 경우 스키마는 다음 요구 사항을 충족해야 합니다:
컴포넌트 | 설명 |
---|---|
구조 | 각 객체에는 id , fields , values 이 포함되어야 합니다. |
ID | 문자열이어야 합니다. |
필드 | 문자열 배열이어야 합니다. |
값 | 배열이어야 합니다. |
가치 항목 | values 내의 각 항목은 배열이어야 합니다. |
다음 코드는 스키마가 있는 모델을 만드는 방법을 보여줍니다:
curl -H "Authorization: Bearer <TOKEN>" \
-H "content-type: application/json" \
--request POST '<HOSTURL>/ml/v4/models?version=2020-06-12' \
--data-raw '{
"name": "spss-multi-source-user-input-table-output",
"space_id": "<SPACE ID>",
"description": "This is my first resource.",
"software_spec": {
"id": "687eddc9-028a-4117-b9dd-e57b36f1efa5",
"name": "spss-modeler_18.2"
},
"type": "spss-modeler_18.2",
"schemas": {
"input": [{
"fields": [{
"metadata": {
},
"name": "customerID",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "gender",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "SeniorCitizen",
"nullable": true,
"type": "integer"
}, {
"metadata": {
},
"name": "Partner",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "Dependents",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "tenure",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "PhoneService",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "MultipleLines",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "InternetService",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "OnlineSecurity",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "OnlineBackup",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "DeviceProtection",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "TechSupport",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "StreamingTV",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "StreamingMovies",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "Contract",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "PaperlessBilling",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "PaymentMethod",
"nullable": true,
"type": "string"
}],
"id": "id5B2XR2L3LS6",
"name": "uinode1",
"type": "struct"
}, {
"fields": [{
"metadata": {
},
"name": "MonthlyCharges",
"nullable": true,
"type": "double"
}, {
"metadata": {
},
"name": "TotalCharges",
"nullable": true,
"type": "double"
}, {
"metadata": {
},
"name": "Churn",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "SampleWeight",
"nullable": true,
"type": "double"
}],
"id": "id3YXBN73TTS",
"name": "uinode2",
"type": "struct"
}],
"output": [{
"fields": [{
"metadata": {
},
"name": "Churn",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "customerID",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "Predicted Churn",
"nullable": true,
"type": "string"
}, {
"metadata": {
},
"name": "Probability of Churn",
"nullable": true,
"type": "double"
}],
"id": "id6BPTTYFV44A",
"name": "Output data",
"type": "struct"
}]
}
}'
작업 2: 모델 콘텐츠 업로드
모델 콘텐츠를 업로드해야 watsonx.ai Runtime에서 리포지토리 에셋을 생성할 수 있습니다.
다음 코드는 모델 콘텐츠를 업로드하여 모델 에셋을 생성하는 방법을 보여줍니다:
curl -vk -X PUT "<HOSTURL>/ml/v4/models/<MODELID OBTAINED FROM STEP1 RESPONSE>/content?version=2020-08-08&content_format=native&space_id=<SPACEID>" -H "Authorization: Bearer <TOKEN>" --data-binary @/PATH/WHERE/ZIP/IS/AVAILABLE/exsistingmultipleuserinputtableoutput.zip
작업 3: 모델 배포
/ml/v4/deployments
엔드포인트를 사용하여 SPSS Modeler 흐름으로 만든 다중 입력 모델에 대한 온라인 배포를 만들 수 있습니다.
전제조건
기존 IBM Cloud API 키가 있거나 새 API 키를 생성해야 합니다.
다음 코드 샘플은 watsonx.ai REST API를 사용하여 온라인에서 다중 입력 모델을 만드는 방법을 보여줍니다:
curl --request POST \
--url '<HOST>/ml/v4/deployments?version=2023-03-10' \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"asset": {
"id": "<MODEL ID FROM FIRST STEP>"
},
"description": "Multi Source Online Deployment",
"name": "spss_multi_source_online_deployment",
"space_id": "<SPACE ID>",
"online": {
"parameters": {
"serving_name": "spssmultisource"
}
}
}'
작업 4: 배포된 모델 테스트
모델의 스키마와 일치하는 JSON 형식의 입력 데이터를 입력하여 배포된 모델에 대해 점수를 매길 수 있습니다.
다음 코드 샘플은 입력 데이터를 JSON 형식으로 전달하고 REST API를 사용하여 배포된 모델에 대해 점수를 매기는 방법을 보여줍니다:
curl -H "Authorization: Bearer <TOKEN>" \
-H "content-type: application/json" \
--request POST '<HOST>/ml/v4/deployments/<DEPLOYMENT_ID RECEIVED FROM STEP 3>/predictions?version=2020-06-12' \
--data-raw '{
"input_data": [
{
"id": "uinode1",
"fields": ["customerID","gender","SeniorCitizen","Partner","Dependents","tenure","PhoneService","MultipleLines","InternetService","OnlineSecurity","OnlineBackup","DeviceProtection","TechSupport","StreamingTV","StreamingMovies","Contract","PaperlessBilling","PaymentMethod"],
"values":[["3638-WEABW","Female",0,"Yes","No","58","Yes","Yes","DSL","No","Yes","No","Yes","No","No","Two year","Yes","Credit card (automatic)"]]
},
{
"id": "uinode2",
"fields": ["MonthlyCharges","TotalCharges","Churn","SampleWeight"],
"values":[[59.9,3505.1,"No",2.768]]
}
]
}'
출력
{"predictions": {"fields":["Churn","customerID","Predicted Churn","Probability of Churn"],"values":[["No","3638-WEABW","No",0.0526309571556145]]} ]}