<?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 Re: How do I invoke a data enrichment function before model.predict while serving the model in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28653#M20430</link>
    <description>&lt;P&gt;Thanks @Werner Stinckens​&amp;nbsp;, while pipeline can condense data prep into an abstraction, the usecase in question was about invocation of a data massaging function within the model's predict function.&lt;/P&gt;&lt;P&gt;Now that I solved it, I like to share with the community. I went about designing the solution by wrapping the model's predict function with a wrapper class's predict method. Since this is non-standard model, I used the pyfunc flavor to log the model in mlflow. By specifying the conda environment, the model hosting cluster can install those libraries and this then runs our custom model.&lt;/P&gt;&lt;P&gt;The main design aspect here is that we replace the model's native predict function with a user defined one. This can do anything like reading, preparing data and then go on to call the model's native predict method.&lt;/P&gt;&lt;P&gt;Databricks has a newish functionality called Feature Store that can handle this kind of usecases. It has APIs that natively invoke a Feature Table lookup and run predict on the values fetched.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2022 11:03:12 GMT</pubDate>
    <dc:creator>bhawik21</dc:creator>
    <dc:date>2022-06-23T11:03:12Z</dc:date>
    <item>
      <title>How do I invoke a data enrichment function before model.predict while serving the model</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28651#M20428</link>
      <description>&lt;P&gt;I have used mlflow and got my model served through REST API. It work fine when all model features are provided. But my use case is that only a single feature (the primary key) will be provided by the consumer application, and my code has to lookup the other features from a database based on that key and then use the model.predict to return the prediction. I tried researching but understood that the REST endpoints will simply invoke the model.predict function. How can I make it invoke a data massaging function before predicting?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 10:51:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28651#M20428</guid>
      <dc:creator>bhawik21</dc:creator>
      <dc:date>2022-02-11T10:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I invoke a data enrichment function before model.predict while serving the model</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28652#M20429</link>
      <description>&lt;P&gt;you  want a machine learning pipeline, part of so called MLOps.&lt;/P&gt;&lt;P&gt;You can find a lot online, like&lt;A href="https://towardsdatascience.com/a-simple-example-of-pipeline-in-machine-learning-with-scikit-learn-e726ffbb6976" alt="https://towardsdatascience.com/a-simple-example-of-pipeline-in-machine-learning-with-scikit-learn-e726ffbb6976" target="_blank"&gt; here &lt;/A&gt;f.e.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 13:27:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28652#M20429</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-02-11T13:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I invoke a data enrichment function before model.predict while serving the model</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28653#M20430</link>
      <description>&lt;P&gt;Thanks @Werner Stinckens​&amp;nbsp;, while pipeline can condense data prep into an abstraction, the usecase in question was about invocation of a data massaging function within the model's predict function.&lt;/P&gt;&lt;P&gt;Now that I solved it, I like to share with the community. I went about designing the solution by wrapping the model's predict function with a wrapper class's predict method. Since this is non-standard model, I used the pyfunc flavor to log the model in mlflow. By specifying the conda environment, the model hosting cluster can install those libraries and this then runs our custom model.&lt;/P&gt;&lt;P&gt;The main design aspect here is that we replace the model's native predict function with a user defined one. This can do anything like reading, preparing data and then go on to call the model's native predict method.&lt;/P&gt;&lt;P&gt;Databricks has a newish functionality called Feature Store that can handle this kind of usecases. It has APIs that natively invoke a Feature Table lookup and run predict on the values fetched.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 11:03:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28653#M20430</guid>
      <dc:creator>bhawik21</dc:creator>
      <dc:date>2022-06-23T11:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I invoke a data enrichment function before model.predict while serving the model</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28654#M20431</link>
      <description>&lt;P&gt;nice!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 06:59:28 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28654#M20431</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-06-27T06:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I invoke a data enrichment function before model.predict while serving the model</title>
      <link>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28655#M20432</link>
      <description>&lt;P&gt;You can create a custom endpoint for your REST API that handles the data massaging before calling the&lt;/P&gt;&lt;P&gt;model.predict function. This endpoint can take in the primary key as an input, retrieve the additional features from the database based on that key, and then pass the complete set of features to the&lt;/P&gt;&lt;P&gt;model.predict function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a web framework like Flask or FastAPI to create the custom endpoint. For example, you can create a function that retrieves the additional features like &lt;A href="https://www.globaldatabase.com/what-is-lead-enrichment" alt="https://www.globaldatabase.com/what-is-lead-enrichment" target="_blank"&gt;lead enrichment&lt;/A&gt; from the database and calls the model.predict&lt;/P&gt;&lt;P&gt;function, and then use this function as a route in your Flask or FastAPI app. The client application can then send a request to this custom endpoint with the primary key, and the endpoint will return the prediction based on the retrieved features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use mlflow's Model.call() method to invoke your custom function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also use Serverless Framework or other similar tools to deploy this function and expose it through an API Gateway&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 14:34:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-do-i-invoke-a-data-enrichment-function-before-model-predict/m-p/28655#M20432</guid>
      <dc:creator>LuisL</dc:creator>
      <dc:date>2023-01-24T14:34:31Z</dc:date>
    </item>
  </channel>
</rss>

