<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic is it possible to change the boilerplate code on a logged/saved pyfunc mlflow model? in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/is-it-possible-to-change-the-boilerplate-code-on-a-logged-saved/m-p/20690#M1127</link>
    <description>&lt;P&gt;When I log a pyfunc mlflow model, it generates a page that has this helpful code for using the model in production. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Make Predictions
Predict on a Spark DataFrame:
import mlflow
from pyspark.sql.functions import struct, col
logged_model = 'runs:/1d.../del121'
&amp;nbsp;
# Load model as a Spark UDF. Override result_type if the model does not return double values.
loaded_model = mlflow.pyfunc.spark_udf(spark, model_uri=logged_model, result_type='double')
&amp;nbsp;
# Predict on a Spark DataFrame.
df.withColumn('predictions', loaded_model(struct(*map(col, df.columns))))
Predict on a Pandas DataFrame:
import mlflow
logged_model = 'runs:/1d.../del121'
&amp;nbsp;
# Load model as a PyFuncModel.
loaded_model = mlflow.pyfunc.load_model(logged_model)
&amp;nbsp;
# Predict on a Pandas DataFrame.
import pandas as pd
loaded_model.predict(pd.DataFrame(data))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is it possible to change this/customize it? Ideally I'd like to include some parameters since the model is used for specific data (data from X table but filtered for a certain site)&lt;/P&gt;</description>
    <pubDate>Thu, 24 Nov 2022 20:24:46 GMT</pubDate>
    <dc:creator>jonathan-dufaul</dc:creator>
    <dc:date>2022-11-24T20:24:46Z</dc:date>
    <item>
      <title>is it possible to change the boilerplate code on a logged/saved pyfunc mlflow model?</title>
      <link>https://community.databricks.com/t5/machine-learning/is-it-possible-to-change-the-boilerplate-code-on-a-logged-saved/m-p/20690#M1127</link>
      <description>&lt;P&gt;When I log a pyfunc mlflow model, it generates a page that has this helpful code for using the model in production. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Make Predictions
Predict on a Spark DataFrame:
import mlflow
from pyspark.sql.functions import struct, col
logged_model = 'runs:/1d.../del121'
&amp;nbsp;
# Load model as a Spark UDF. Override result_type if the model does not return double values.
loaded_model = mlflow.pyfunc.spark_udf(spark, model_uri=logged_model, result_type='double')
&amp;nbsp;
# Predict on a Spark DataFrame.
df.withColumn('predictions', loaded_model(struct(*map(col, df.columns))))
Predict on a Pandas DataFrame:
import mlflow
logged_model = 'runs:/1d.../del121'
&amp;nbsp;
# Load model as a PyFuncModel.
loaded_model = mlflow.pyfunc.load_model(logged_model)
&amp;nbsp;
# Predict on a Pandas DataFrame.
import pandas as pd
loaded_model.predict(pd.DataFrame(data))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is it possible to change this/customize it? Ideally I'd like to include some parameters since the model is used for specific data (data from X table but filtered for a certain site)&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 20:24:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/is-it-possible-to-change-the-boilerplate-code-on-a-logged-saved/m-p/20690#M1127</guid>
      <dc:creator>jonathan-dufaul</dc:creator>
      <dc:date>2022-11-24T20:24:46Z</dc:date>
    </item>
  </channel>
</rss>

