`pgml.predict` does not work with specific models that are not the deployed model
gaspardc-met opened this issue · 3 comments
gaspardc-met commented
montanalow commented
Are you passing a TEXT rather than INTEGER as the model_id? This function is overloaded and TEXT is interpreted as a project.name. We have a test for this functionality in the examples that currently passes:
https://github.com/postgresml/postgresml/blob/master/pgml-extension/examples/regression.sql#L30
gaspardc-met commented
I'm running this in python with psycopg2, so I'm passing the int in a string and not really forcing the type
here is a sample code ran with pd.read_sql_query :
# Prepare the SQL command for inference
FEATURES_SQL = ", ".join(FEATURES)
sql_command = f"""
SELECT
{TARGET} AS actual,
pgml.predict(
'{model_id}',
ARRAY[{FEATURES_SQL}]
) AS prediction
FROM
{relation_name};
"""
# Execute the SQL command
predictions = pd.read_sql_query(sql_command, engine)
montanalow commented
You should be using bind parameters, per the psycopg documentation. String interpolation is fraught with bugs and security risks.


