Python in Power Query

Опубликовано: 06 Октябрь 2024
на канале: RADACAD
20,403
157

In this short video, I have explained how to run a Python code inside the Power BI for the aim of Prediction. The last Vide was on    • Azure Notebook with Python  
the dataset is titanic.csv
and the code is
import pandas as pd
from sklearn.model_selection import train_test_split
y=dataset.Survived
x=dataset.drop('Survived',axis=1)
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2)
from sklearn.tree import DecisionTreeClassifier # Import Decision Tree Classifier
from sklearn import metrics
clf = DecisionTreeClassifier()
clf = clf.fit(x_train,y_train)
y_pred = clf.predict(x_test)
dfoutput = pd.DataFrame({'prediction':y_pred})