Member-only story
Interacting with sklearn machine learning models in Power BI
In some cases we want to have a supervised learning model to play around with. While any data scientist can quite easily build an SKLearn model and play around with it in a Jupyter notebook, when you want to have other stakeholders interact with your model you will have to create a bit of a front-end. This can be done in a simple Flask webapp, providing a web interface for people to feed data into an sklearn model or pipeline to see the predicted output. This post however will focus on how to use Python visuals in Power BI to interact with a model.
The post will consist of two main parts:
- Building the SKLearn Model / Building a Pipeline
- Building the Power BI Interface
The code is really straightforward and you can copypaste whatever you need from this post, but it is also available on my Github. To use it, you have to do two things. Run the code in the Python Notebook to serialize the pipeline and alter the path to that pipeline in the Power BI file.
1. Building the Model
For this example we’ll use the Titanic dataset and build a simple predictive model. The model will be a classification model, using one categorical (‘sex’) and one numeric feature (‘age’) as predictors. To demonstrate the approach we…