Google Vertex AI provides a managed Google Cloud environment for serving a trained machine-learning model through an endpoint. A Kuala Lumpur real-estate price model moves from local Flask deployment to a cloud URL that applications can invoke. section 10.0 section 10.4.3
A practical deployment workflow is:
- Create a Google Cloud project and Cloud Storage bucket, then upload the trained model artifact. section 10.3 section 10.4
- Import the artifact into the Vertex AI Model Registry, selecting the training framework and matching framework version. section 10.4.2
- Deploy a model version to an endpoint and choose resources proportionate to the workload; a minimal machine type suits a test deployment. section 10.4.3
- Test the endpoint with valid JSON, then connect a Flask application through the Vertex AI Python SDK. section 10.4.4 section 10.5 section 10.5.1
Testing a property prediction endpoint
A request for a three-room condominium in Sentul uses feature values as single-element arrays and double-quoted JSON. The endpoint returns the model output; applying the sigmoid function converts it into a 17.9 percent probability that the property exceeds the median price. section 10.4.4
Listing 10.9 show-prediction.html view function for endpoints
def show_prediction():
scoring_dict = {}
for col in config['scoring_columns_cat']:
print("value for "+col+" is: "+str(request.args.get(col)))
scoring_dict[col] = str(request.args.get(col))
for col in config['scoring_columns_cont']:
scoring_dict[col] = float(request.args.get(col))
scoring_dict['size_type_bin'] = str(request.args.get('size_type'))+' 1'
scoring_dict.pop('size_type') #1
input_dict = {name: [value] for name, \
value in scoring_dict.items()} #2
print("input_dict: ",input_dict)
predictions = predict_custom_trained_model_sample(
project = config['endpoint']['project'],
endpoint_id = config['endpoint']['endpoint_id'],
location = config['endpoint']['location'],
instances = input_dict) #3
prob = tf.nn.sigmoid(predictions[0])
The Flask view shows the integration boundary: remove unused features, wrap each value in a one-item list, and call the endpoint with project and endpoint identifiers. section 10.5.2

