Tutorial 7-Build,Train,Deploy Machine Learning Model AWS SageMaker- Predicting Test Data Endpoints

Krish Naik · Beginner ·📐 ML Fundamentals ·5y ago

Key Takeaways

Builds, trains, and deploys a machine learning model using AWS SageMaker

Full Transcript

hello all my name is krishnan welcome to my youtube channel so guys we are in the seventh tutorial of amazon sage maker now in my previous tutorial you had actually seen we had deployed the machine learning model as endpoints i'd also shown you about the billing management how you should actually check the billing itself so right now it is showing us point zero four since i've been working from past four days and this charge has actually happened in just sage maker so now after the deployment uh of the model as end points we are just going to do the predictions now in predictions first of all and again guys we are going to solve this in two to three steps like first of all we'll do the prediction then we'll create a simple confusion matrix to see what is the output how is the performance and then we'll probably take the further steps now after this in the prediction first of all you need to import a library which is called a csv underscore serializer because when you are giving the data to the endpoints right the endpoint will be accepting some input so the input is usually in the form of an excel data set that is like a tabular data set that should be converted or serialized that whole csv needs to be serialized and it needs to be passed given to the model and the model will actually give you the output so if you go on the top we had already done the split of the train and test data set over here right so i have my touch data set now what i'm going to do is that first i'll be importing uh this library which is called as sagemaker.predict predictor import c csv underscore serializer then from the test data what i'm going to do is that i'm going to drop my depend uh my dependent features that is yes underscore no y underscore yes from access is equal to one and i'm going to convert this into an array and after this i'm going to save it in a variable which is called as test underscore data underscore array after that whenever you are using csv underscore serializer you also need to set up this model content type okay so this model content type should be set as text or csv since our data set is completely in the form of csv format then i also have to set my serializer and this serializer is again cv underscore serializer which we have actually imported and the reason is that my data set is actually a csv file after this i can actually use something called as xgb underscore predictor which is my model dot predict right and then i'm going to give my test data after that i also have to decode it with the help of utf hash dash 8 encoding the reason is that again this encoding will be required this decoding will be required because when we are actually doing the prediction it will be some encoded format uh and that encoded format will be decoded by using this format itself right udf8 now once i gets my predictions this spread from this prediction i will be taking the first you can say that i'll be taking the first okay the first part of that particular data so that we will be getting the highest value with respect to a binary classification based on the probability okay so once we do this and once we try to find out the prediction array.shape now let's see once i execute these guys so you will be seeing that i will be getting some shape this many records i have in my test data set uh and if you really want to see my predictions underscore array you will be able to see this is the output of my test data okay this this is basically the output of all the test data now if i really want to check or the next step obviously everybody knows about it we will be creating some kind of confusion matrix again this whole confusion matrix code is actually taken from the aws documentation what we have done is that they have actually done implemented some cross tab they have taken the prediction array they have assigned some columns and in short what they have done is that uh based on the purchase and no purchase they have actually calculated all the features that is required now you have to tell me what is this particular formula what is this particular formula what is this particular formula and again what is this particular formula because we know false positive true positive true negative and all but what this formula actually specifies you have to tell me okay so just try to execute this and here you'll be getting an amazing um confusion matrix like kind of stuff so here is your predicted you can see no purchase purchase no purchase purchase so with respect to this you're getting 91 percent with respect to this where the predicted value is purchased but the real value was no purchase right it is somewhere around nine percent uh over here here you can see that the accuracy is very very less because probably this kind of problem statements are imbalanced data set uh similarly with respect to this here you are getting somewhere around 66 percent but again this purchase and your observed is no purchase at that time so you can see in the left hand side you can consider this as an observed value in the right hand side you can see this is as a predicted value so in the observed if it is no purchase but it has been predicted as purchase so this value you will be getting somewhere around 34 again which is very very less we should try to increase this and increase this value with the help of hyper parameter tuning right so in short uh the classification accuracy that you are actually getting is somewhere around 89.7 but i will definitely have a look on to the precision recall and all the other values because this is purely an imbalanced data set and this values is very very less this accuracy is very very less now after this guys always make sure that once you do the prediction from the end point don't run it continuously because the charges will be going on because once an endpoint uh endpoint address is actually created you need to delete those right so for deleting you have this specific code okay so for deleting you have this specific code and when you are deleting you basically delete all the end points right so you have to say that sagemaker.session.delete underscore endpoint and in the bracket you give their estimator which is your xgb underscore predictor dot endpoint okay and you also specify your bucket name so that whatever folders has been created with your data set even your model files everything will get deleted so here you are actually getting the information of your bucket name and then bucket to delete dot ops dot all dot delete if you use this function everything will get deleted so two main things that you have to do after your model is deployed in the endpoint address make sure that don't continue it for a longer period of time instead focus on deleting those endpoints as soon as the training is done later on if you want to really practice again for the free trial you can do it you can create there and you can test it but after this step you just try to delete all the end points now right now if i go to my sage maker you'll be able to see that my sage maker have all these particular files right bank application and all so i'll just reload it you can see over here so aws series maker you have this bank application now what will happen if i execute this okay yeah again i'll show you guys inside this all the folders are present right this is my folder this is my folder everything is present right now if i execute this this will go and delete each and every folder right xjboost this test.csv output model train.csv everything so let's see whether it has got deleted or not and you can see over here you have bank applications and here you can see that no other files are actually present only this bank application folder is present which is the root folder so this is how you delete the endpoint address now in short what we have done is that guys we have trained the whole machine learning models with an inbuilt algorithm of xgboost after this what you do is that you just close this files okay or first of all i'll download this file so that i can give you uh this information in the github so i'm going to download this after downloading it guys what i'm going to do i'm going to close this i'm also going to close this i'm going to go over here and see what after this i'm just going to delete all these files so that more charges should not happen and here i'm actually deleting it right i can also delete the notebook instance now the next step right i will try to delete this notebook instance probably we may have some options ah let's see settings okay probably i'll just show you in my next video how to delete this notebook instance again i have to research and try to find out but i think in the action it should be present okay i can also use stop so here it is actually getting stopped right now once we stop it now more actions we can see uh like if we have this delete options also probably in through some other way we have to delete this which i'll be showing in my upcoming videos so i hope you like this particular videos guys uh and please do subscribe the channel if you have not already subscribe i'll see you in the next video have a great day thank you and bye bye

Original Description

Create Free Tier Account: https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc github :https://github.com/krishnaik06/AWS-SageMaker Please donate if you want to support the channel through GPay UPID, Gpay: krishnaik06@okicici Discord Server Link: https://discord.gg/tvAJuuy Telegram link: https://t.me/joinchat/N77M7xRvYUd403DgfE4TWw Please join as a member in my channel to get additional benefits like materials in Data Science, live streaming for Members and many more https://www.youtube.com/channel/UCNU_lfiiWBdtULKOw6X0Dig/join Please do subscribe my other channel too https://www.youtube.com/channel/UCjWY5hREA6FFYrthD0rZNIw Connect with me here: Twitter: https://twitter.com/Krishnaik06 Facebook: https://www.facebook.com/krishnaik06 instagram: https://www.instagram.com/krishnaik06
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Krish Naik · Krish Naik · 0 of 60

← Previous Next →
1 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
50 Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related Reads

📰
AI Training Data Services: The Complete Enterprise Guide to Building Accurate AI Models (2026)
Learn how to build accurate AI models with the right training data services for your enterprise, and why it matters for AI success
Medium · Machine Learning
📰
Machine Learning Concepts Explained #4: Features and Labels
Learn the difference between features and labels in machine learning and their role in supervised models
Medium · AI
📰
Machine Learning Concepts Explained #4: Features and Labels
Learn the difference between features and labels in machine learning and their role in supervised learning
Medium · Machine Learning
📰
Machine Learning Concepts Explained #4: Features and Labels
Learn the difference between features and labels in machine learning and their role in training supervised models
Medium · Data Science
Up next
Dropout in Deep Learning
AnuTech-CH
Watch →