Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCP Serving - Features required not used in model #24

Open
mshearer0 opened this issue Sep 20, 2020 · 2 comments
Open

GCP Serving - Features required not used in model #24

mshearer0 opened this issue Sep 20, 2020 · 2 comments
Assignees

Comments

@mshearer0
Copy link

After deploying model to GCP i found predictions required features 'company' and 'timely response' although these are not used in model. The other features below were also required but 'state' and 'zipcode' were not.

exampledict = {'product': 'Bank account or service', 'sub_product': 'Savings account', 'timely_response': 'No', 'company_response': 'Closed with monetary relief' ,'issue':'Cash advance','company':'test','consumer_complaint_narrative':'happy with the service' }
featuredict = {}

for key,value in exampledict.items():
featuredict[key]=tf.train.Feature(bytes_list=tf.train.BytesList(value=[value.encode('utf-8')])),

example = tf.train.Example(
features=tf.train.Features(feature=featuredict)
)

input_data_json = {
"signature_name":"serving_default",
"instances":[
{
"examples":{"b64": base64.b64encode(example.SerializeToString()).decode('utf-8')}
}
]
}

request = ml_resource.predict(name=model_path, body=input_data_json)
response = request.execute()
if "error" in response:
raise RuntimeError(response["error"])
for pred in response["predictions"]:
print(pred)

[0.123692594]

@mshearer0
Copy link
Author

In addition to the above the following predicts locally using saved_model_cli (pg 140) - replace model number:

cli_input="examples=" + repr([example.SerializeToString()]).replace("'", "\"")
!saved_model_cli run --dir ../../interactive-pipeline/serving_model_dir/1600007776/ \
--tag_set serve \
--signature_def serving_default \
--input_exprs='{cli_input}'

@mshearer0
Copy link
Author

Certain values, eg 'sub_product': 'Savings account', cause local prediction to fail but GCP works fine.

Difference seems to be those value Serialize to include a " character causing:

SyntaxError: unexpected character after line continuation character

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants