0

I'm trying to integrate my machine learning model (Random Forest) I did in Jupyter Notebook inside power BI. Using gridsearch , and after testing multiple algorithms, it turned out that the Random Forest was the most performant one for my dataset.

So I saved my model as a PKL file (rf_ins.PKL) and then I imported the model inside power BI using the Python visual. I used the following code:

from pycaret.regression import *
rf = load_model('C:/Users/hp/Desktop/Sprint PBI/rf_ins')

# Use the trained model to make predictions
predictions = predict_model(rf, data=dataset)

# Get the predicted label and score columns from the predictions
predicted_label = predictions['prediction_label']
predicted_score = predictions['prediction_score']

# Check if any element in predicted_label is equal to 1
if any(predicted_label == 1):
    output_text = "The employee is likely to leave with a probability of {:.2f}".format(predicted_score)
else:
    print(predicted_label)
    output_text = "The employee is not likely to leave"

# Return the output text
output_text

I get this error:

enter image description here

Here's a screenshot of my data:

enter image description here

I'll be actually have filters (slicers) next to the visualisation , which would correspond to my features and by changing the values of the prediction , my dashboard should be as follows

I was wondering why it's not correctly working. Any help is appreciated! enter image description here

userrr
  • 197
  • 7

0 Answers0