How to Deploy Machine Learning Models using Power BI

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up you data friends is janice here and welcome to my channel in this video i am going to show you how to deploy your machine learning model results from python into power bi and more specifically i'm going to show you how to build this power bi dashboard from scratch in this dashboard we have our predictions which is the potential churns the most important variables affecting customer churn and then a customer details breakdown table where the business can actually see which customers are going to churn and the probability of those customers becoming germs and just to explain you how all this process works in the previous two videos we have explained how to run three different machine learning models in python so we've run a decision tree then we've run a random forest machine learning model and then we've run an extreme gradient boost machine learning model then we've adjusted their hybrid parameters in order to improve our models and when we were happy with our final model we tested it on completely unseen data we've made predictions whether they're going to be customer terms or not and the probability of them becoming a customer churn and at the end we've outputted our results in both an sql server and a csv file these results now which is going to be this csv file over here is going to be the input that we are going to use to build this power bi dashboard where we can display our results to the wider business right and before we jump into building this power bi dashboard let me just say that if you're new to my channel and you're passionate about data science then please consider liking this video or subscribing to my channel and enabling notifications for my future videos right so the first thing we want to do is to open a new blank power bi file and import our raw data for this video i'm going to show two ways of importing raw data the first one is going to be via an sql server and the second one is going to be via an excel csv file but both raw data are going to be the same right to get the data from an sql server we need to click on get data and then click on sql server over here then under server we need to go back into our sql and click somewhere uh over here get our sql server name which is this one over here commit go back into power bi paste it and then click ok as input now we need to select the database and then the table name so my table name is this one chain predictions output so if i click it over here we get a small display of what our table is going to look like and you can see we have our predictions over here and then we click on load data and this is going to load our data over here there we go we have our raw data over here under chain predictions output actually i'm going to rename this into dot sql so now this comes from sql in another way there are some pending changes we can click on apply changes and the way to import your raw data from excel you click on home click on excel over here then you're gonna need to select the raw data so mine is saved over here so it's this one over here i click on it i click open here we get a display of our data you can see is exactly the same as this one over here and then if we click on load it's going to load it over here there we go and then i'm going to rename this one as the excel one and both of these raw data tables if we go over here to visualize them both of them have exactly the same column names and the same data in them right next i'm going to click over here under the connections and i want to make sure that these two tables are not connected because power bi identified itself that we can link these two tables based on customer id but because these tables are the same i don't really need this connection i am only going to use one of these tables so i've deleted the connection right if i go on the home page now here the first thing i always do is i change the page size so i can make it longer and fit more things in it so if we click here where we have format and then under page size we want to make this custom and i want to make the width 1500 and i want to make the height 1300 then i want to go under view and then i want to change these into fit to width so we can use all the space and also i want to change the page background to this color over here so if i click under colors custom color you can copy and paste exactly this color i have over here and then set the transparency to zero so we have this light color on our background the next thing i want to change is our theme so i always like to use the classic theme because this gives me different colors than this one if i go under colors now you can see we have a different palette versus this one over here because if i click on this one then check the colors you can see it's different if i click on this one check the colors you can see it's different right so the first thing i want to add now is our title so we go under insert and we click on a text box then we want to resize our text box so it takes almost all the page so here is final thing then we need to add the name of our title so i'm just gonna copy it and paste it quickly from over here copy paste now i want to resize my title into size 28 maybe then i want to click over here so we put it in the middle and on the right hand side i want to add a background and our background is going to be white and also i want to add a border so let's add a light gray maybe this one and also add a radius of 10 so we have these small curves at the edge of our text box now we can make this a bit smaller maybe and then drag it a bit further down over here next we want to add our logos so i'm gonna add two random logos i have but you cannot any logo you want so if i go over here one of them is this one which is the bang and the other logo i want to add is the data this is the yp logo so this one over here now i can resize them and then put them here at the top right moving on we need to add our slices now which is these slices over here and we're going to start with h to add a slicer now we need to go under visuals and click over here where it says slicer and then in the field of this slicer we need to drag the h which is the h over here then we can resize this one put it here at the top in order to copy and paste the same formats from our text box for example the white background and the edgy corners what we can do is that we can click on this text box click under home the format painter and then touch on our new visual and as you can see now we have the white background and the edgy corners and also the color of our border the same color so now when we click on our visual we want to go under here where it says format we want to remove the slicer header and we want to add a title the title is going to be h the phone is going to be black and also the alignment in the middle and maybe the text size we can make it 11 or 12. yeah let's leave it 12. now we need to move on to our second slicer which is the country and then the number of products so very quickly i can copy this and then paste it put it next to it and then change the field from age into country which is geography over here so if i add it on top if i remove this one then if i click over here change the title from age to country then i want to go into general because i don't like this format and i want to change the orientation into horizontal there we go next i want to change the background of these items into the same background as we have for our report so very quickly i'm gonna click out of the visual go here go under the page background and then copy this color so custom then i'm gonna copy this to this same background then click on our slicer go here click under items the background and then change it into the one we have just copied there you go you can see and also change the font color into black there we go next i want to move on into our next slicer which is going to be the number of products and the predictions actually we have a different color for font here let's do the same color so very quickly if we click back we go over here under the items change the font i think is this one over here there we go next i want to copy this and paste it twice so one of them is going to be the number of products and the other one is going to be the predictions of the england very quickly yeah predictions so very quickly i'm gonna change these to the number of items which is this one over here then i need to change the title into the unknown of items this one is going to be the predictions description but i'm going to change the title quickly so predictions then over here i need to change this into the predictions turn or not description there we go you can see chain or retention and the last one we have is the prediction probability so i can copy this visual now copy paste it and then change the age to the prediction probability page then prediction probability this one over here as you can see it created it in a different format so very quickly i'm going to delete this one because i don't want to lose time click on the slicer over here and then in this new slicer drag the prediction probability there you go we have the bar straight away that's the slider that's what it's called then i'm going to click over here click on format painter touch this one so we have the same formats then i'm going to resize it here at the top leave some space and then i'm going to add a title and the title is going to be prediction probabilities right next i want to change the size of all of them just to make sure they are the same size and also the equality distance between each other so to do that i need to select all of them by pressing ctrl down and selecting all of my slices then under here and under general i want to make the width of all of them into two maybe two eight seven click enter you can see they're all smaller now then i need to move this one to be exactly under my title and then i need to select all of them again go under format and under align align them at the top and at the same time distribute horizontally so they are equally distanced from each other right so the next thing we need to do now is to create these two cards which is the new customers and the potential chance to do this now we need to go back in our dashboard and we need to click over here where it says car then i need to resize this on but i want to make it exactly as this one over here so i'm just going to copy the sizes so under general i can see is two six nine two two five so under general is going to be two six who is locked because i don't have any fields in them so if i drag the field which is going to be the customer id and i want to count distinct there we go count this thing and then over here it was 2 6 9 2 6 9 and then 2 2 5 i think let me check again 269 325 that's correct and if i click enter there we go next i want to change my format so i'm going to do the format painter that i have shown you before so just touch on it now we have the same background the same border and the same colors next i want to click on it go over here and then remove the category label because i don't want that count over there and i also want to add a title and the title is going to be new customers there we go size 12 i think is fine next i want to change the color of the data label and maybe this dark green over here and then make it a bit larger so maybe i don't know 36 yeah 37. now i need to repeat the same process for the potential chance but i'm just gonna copy this paste it next to it like this add it over here change the name of it into potential chance potential chance then i need to in filters now because i only want to see charms i need to add a filter on this visual and the filter is going to be the churn or not and under here i want to have a basic filter and i only want to display the customers that are predicted to be charts so this one over here so as you can see now this is slides to only the chance and now i need to change the data label color to be a red so i'm just going to click random red also i'm going to change the size of it to 40 and i'm gonna do the same for this sort of thing i'm going to change the size of this one to be 40. so slightly bigger right next we need to add these four graphs over here these scatter plots which are the most important variables affecting our genes and the way we have identified these variables is that if you watch the previous two videos in python when we've run the most important features so these features over here we found out that age number of products and is active member one are the most important figures contributing to churn also when we've added the max depth to b3 so another level of breakdown we found out that balance is also contributing in our model if you go back and watch those videos so for these four graphs now i am going to use the age the number of products the is active and also the balance so if i go back into our dashboard now to create a scatter plot we need to click over here under visualizations then we need to put it over here maybe resize it a bit now i need to drag into my x-axis the age so let me hide this one so i'm going to use age and then as a y i'm going to use the credit score let's say so where is the credit score so this one over here then under the legend i want this to be splitted into chance and retention so i'm gonna use this churn or not under the legend and under the details i'm just gonna drag all our customers so this is how it's going to look like now i need to make it look more readable so under the formats over here i'm gonna go under the shapes and i'm gonna make them much smaller so maybe mine was i don't know 11 for now then i want to customize my series which means that i can set the zeros which are the people who are retaining so not churning us these bubbles over here and then we can set the ones that are changed into this shape over here so we have two different shapes next what we can do is that we can change the colors so zeros i want them to be the greens as we have them and once i want them to be these reds over here there we go we can see them also maybe we can make it a bit smaller because they are still too much to read let me check which which size we have over here so for this one we have it under -22 so let's do minus 22 over here too so there we go click enter there we go so you can see now that the chance we can we need to add the legend actually let's add the legend into the bottom center and then let's rename this one as the predictions there we go predictions so what this is telling us if i make it a bit bigger so if we hide this is that most of our chains are concentrated between the age of 30 and 60. so you can see them over here now i am going to resize these to exactly the same size as these ones so we can fit four of them so i'm going to copy the sizes so under general this one is 456 and 306. so it's going to be four five six and then this one is 306 click enter now i need to fix my titles so my title phone is going to be black then in the middle then the text size is going to be 12 and the title of this one is going to be age versus credit score by prediction there we go the next step now is to copy the formats of this one so the white background in the edge corners and then touch on this graph over here so now it's wide and is more readable next i need to replicate this graph now three more times to include the other important variables i can call it i can paste it one then two then three times and now i need to change the variables in those scatter plots right so we're going to start with this one and this one is going to be age versus balance so we can switch the credit score with the balance which is this one over here however what you can see is that balance is not numeric is as text so it's not gonna work if i try to drag it the way to understand if it's numeric or not is the sum next to the column so you can see that s doesn't exist in balance and it's the same with the is active member and number of products which we need to do over here to change those now from text into numeric we need to right click on here and go in edit so edit this query then in this editor we need to select those columns so the first one is the balance then we click control the next one is the number of products and the other one is the is active member and then under home under the data type we can change these to decimal numbers before it was text as you've seen that's why it was not going to work then we can click close and apply and this is going to switch them from text into numbers so now we will be able to drag balance into this graph over here so now you can see we have the s and then if we drag it into our y-axis you can see we have loads of zeros now and i i'm going to exclude them and the way to do that is under filters for this visual under balance we can change these to be is greater than so this over here and then says greater than one and click on apply filter and this should exclude all the zeros there you go you can see it excluded all the zeros and again what this is telling us is that from ages between 40 and 60 and then anyone that has more than 0.2 million is almost always a churn and most of the channels are concentrated between these balances and these ages over here we also need to change the title of this zone so this is going to be age versus uh balance yeah now we need to move on into age versus number of products so we can remove the credit score and we can add the number of products into the y-axis so again what this is telling us is that anyone that has number of products three or four is almost always a churn that's why this is an important variable and from the people who are between 40 and 60 and they have one product again they are more likely to churn there you go so now i need to change the title of this one into age versus number of products so this is products and then the last one over here is the age versus the is active member if i go over here i can remove the credit score and i cannot there is active member over here this is not very visually appealing but it is an important variable because what it's telling us is that anyone who is active and is more than 62 will almost never share but before 62 and up until here they are more likely to churn it also tells us that anyone who is less than 20 and is not active we almost never churn and at the same time anyone who is not active and between 40 to 60 is more likely to check however because it's not visually appealing we can change it or we can leave it it's up to you now something important to add here is that what we could have done is to have a table with the most important features or variables and their feature importance however it was going to be very difficult for the business to understand what is feature importance and what it means hence a better way of displaying this feature importance and the important variable is a visual way as we've done it over here now anyone can look at these graphs from the business without knowledge of machine learning and understand that these variables are important which is why i'm suggesting doing it this way versus having a physical table displaying the future importance right let's just change the name of this one now which is age versus is active there we go zero and one the next thing we need to do now is to add this map over here so the business can visualize from where the predictions are coming so we go back over here we click on this map then we want to resize this map to take all the space available down here then under location we want to drag the geography under the size we want to track the number of people so the number of customer ids so i'm going to count this thing over here uh now this is the sum count this thing and then under the legend we want to know if it's a customer chair or not so zeros and ones now i need to make this more visually appealing so the first thing is that i am going to copy the formats and then paste them in this visual so the white background in the same border color next i want to click over here and change the map style to be the dark one so it's much easier to view it and read it now and also i want to change the data colors i'm going to leave this one as green and the ones i'm going to put them as these red over here which is the same red as before next i want to change the legend position so i'm going to move it into bottom center down here and i'm going to rename this as just the predictions without the chair or not next i want to change my title into the same title as the one above here so i'm just going to copy it and paste it very quickly and the title is the number of customers per country and pair prediction and also i want to change the bubble sizes so they're a bit bigger so maybe i don't know yeah i think this is fine right the last thing we need to do in our dashboard now is these customer details table where the business can actually come and see which customers specific customers their name and their details are going to be changed so the ones we are predicting them to be churns and by what probability because we also have the probability to do this table now we need to head back into our dashboard and we need to click over here which is the table we need to resize this table to take all the space and we also need to copy the formats from here and touch it on this table so we have the edges and the white background next we need to add the values now and it's almost all the values so i'm going to start with the customer id and make sure this is not sum because it's not a value so don't summarize then we have surname geography and gender so where is the surname then geography then gender then we have age has credit card and then credit score so age then has credit card this one and then the credit score then we have the estimated salary balance and is active member so estimate salary balance is active member you can see everything slowly appearing over here then we have the number of products ten year and then the predictions so uh where is the number of products their tenure and then we need this prediction this prediction and then this prediction so let's see that's the probability maybe we can move this one first so first we have it in text and we'll have it zero and zero and one we don't really need because we do have this prediction in the description whether it's a churn or not so i'm just gonna remove this one over here and i'm gonna leave just distance right now i wanna go into the general over here and i want to change no it's actually under style and i want to change the style into minimal i find this much clearer and i want to make sure i'm using all the space so i'm just going to make some of these columns a bit bigger just to make sure we're using all the space because it looks nicer right next we need to add a title and the title is going to be the customer's details so if i go under title and i'm just going to say customer details next what we can do for this to look nicer is to rename all these values names to have cabinets so it's much nicer but we're going to waste a bit of time so you can do this yourself all you have to do is double click on distance and then change the first letter to be capital so it looks nicer next we need to make the column names sorry the column headers are in a bit bigger so they're easier to read so i'm going to make them 11 and as you've seen now i have used a lot more space so i'm just going to make this smaller and this one smaller actually i'm going to rename this last two so we have more space so this is our predictions and this is our probability there we go you can see we have more space now and also i'm going to align the column names to be the column headers to be in the middle so here i'm going to put it in the center right the last thing we have to do now is to add some conditional formatting rules like we have over here in the last two columns which are our prediction which is basically going to say if it's a churn then mark it as red so you can visually see it straight away and if it's not a churn then mark it as green so to do this we need to head over back here click on our table go into conditional formatting then select our column which is the predictions and then add a background color here is where we need to say format by color scale actually i'm going to say format by rules and the rules is only going to be based on a different field and that field is going to be the custom chain or not the numbers so this one so if the sum of this one is zero and i'm going to make this a number then i want to have this as green and also i want to have a new rule that is saying that if the value is one so a churn and this is a number then make it as this light thread over here so if i click ok now you can see that retentions are green and the churns are red and for the probability to churn now i need to select the column then i need to add background but this background i'm going to click on advanced and i'm going to change the coloring so the lower the value the better it is because it's a low probability to churn and the higher the value the worse it is because there is a higher probability to churn so as you can see now the ones that have higher probability to churn are a bit more red also for this one for example i think i'm going to make it a bit more distinct so i'm going to select this red over here so it's a bit more distinct to the eye because this customer over here we are not predicting him to be or here to be a churn however is very close to the threshold because it's 0.74 if it was 0.51 then this was going to be a churn and this is why we need the probability so a good way for the business now for them to understand the ones that are close to the threshold what they can do is that they can monitor the threshold from here so if they change the prediction probability to be anything more than 40 percent then despite the fact that not everyone here is marked as a chair these people have more than 40 percent probability to be changed in the future this is why we need the chain probability and this is why we have this slicer at the top and you as a data scientist or a data analyst should explain to the business what this prediction probability means and how to use it and the next step if this was a real business scenario it was going to be us clicking over here publish report and this is going to publish our report in an online workspace where you can generate a link where you can send it into the while the business so the business was not going to see the desktop version of power bi so nothing like visualization or fields they will only be able to click on that link and see a web application of your results so this dashboard you see over here and this is why i keep saying that data scientists need to know how to use data visualization tools because this is a way of deploying your machine learning model results write it a friend so this is it for this tutorial and i hope you've enjoyed this tutorial and i hope you've gained enough value out of all the videos within this series if you feel like you did please click that like button subscribe to my channel and enable notifications for my future videos if you want to contribute to my channel i have just created a patreon account it's going to be in the link below if you have any questions then please let me know in the comments below otherwise thank you very much for watching this video and i'm gonna see you in the next video
Info
Channel: Data 360 YP
Views: 6,780
Rating: undefined out of 5
Keywords: How to Deploy Machine Learning Models using Power BI, how to deploy machine learning model, how to deploy machine learning model in production, machine learning model deployment, machine learning model example, machine learning model production, deploy machine learning model to production, machine learning models in Power BI, Python to Power BI machine learning, How to build a power BI dashboard from scratch, How to deploy my machine learning results in power BI, deploy ML, ML depl
Id: X4IRceUvh_E
Channel Id: undefined
Length: 33min 12sec (1992 seconds)
Published: Thu Jan 28 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.