Skip to content

Commit

Permalink
Merge pull request #18 from caetano-colin/docs/add-model-validation-step
Browse files Browse the repository at this point in the history
docs: add model validation step
  • Loading branch information
sleighton2022 authored Apr 30, 2024
2 parents e829358 + 86c3810 commit f423ad6
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions 6-ml-pipeline/dev/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,54 @@ The compile_pipeline.py and runpipeline.py files are commented to point out thes
### 4. Merge and deploy
- Once everything is configured, you can commit your changes and push to the dev branch. Then, create a PR to from dev to staging(non-prod) which will result in triggering the pipeline if approved. The vertex pipeline takes about 30 minutes to finish and if there are no errors, a trained model will be deployed to and endpoint in the prod project which you can use to make prediction requests.
### 5. Model Validation
Once you have the model running at an endpoint in the production project, you will be able to test it.
Here are step-by-step instructions to make a request to your model using `gcloud` and `curl`:
1. Initialize variables on your terminal session
```bash
ENDPOINT_ID=<REPLACE_WITH_ENDPOINT_ID>
PROJECT_ID=<REPLACE_WITH_PROJECT_ID>
INPUT_DATA_FILE="body.json"
```
> You can retrieve your ENDPOINT_ID by running `gcloud ai endpoints list --region=us-central1 --project=<PROD_ML_PROJECT>` or by navigating to it on the Google Cloud Console (https://console.cloud.google.com/vertex-ai/online-prediction/endpoints?project=<PROD_ML_PROJECT>`)
2. Create a file named `body.json` and put some sample data into it:
```json
{
"instances": [
{
"features/gender": "Female",
"features/workclass": "Private",
"features/occupation": "Tech-support",
"features/marital_status": "Married-civ-spouse",
"features/race": "White",
"features/capital_gain": 0,
"features/education": "9th",
"features/age": 33,
"features/hours_per_week": 40,
"features/relationship": "Wife",
"features/native_country": "Canada",
"features/capital_loss": 0
}
]
}
```
3. Run a curl request using `body.json` file as the JSON Body.
```bash
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/endpoints/${ENDPOINT_ID}:predict -d "@${INPUT_DATA_FILE}"
```
- You should get an output from 0 to 1, indicating the level of confidence of the binary classification based on the parameters above.
Values closer to 1 means the individual is more likely to be included in the income_bracket greater than 50K.
# Common errors
- ***google.api_core.exceptions.ResourceExhausted: 429 The following quotas are exceeded: ```CustomModelServingCPUsPerProjectPerRegion 8: The following quotas are exceeded: CustomModelServingCPUsPerProjectPerRegion``` or similar error***:
Expand Down

0 comments on commit f423ad6

Please sign in to comment.