title
Machine Learning Tutorial Python - 8 Logistic Regression (Multiclass Classification)
description
Logistic regression is used for classification problems in machine learning. This tutorial will show you how to use sklearn logisticregression class to solve multiclass classification problem to predict hand written digit. We will use sklearn load_digits to load readily available dataset from sklearn library and train our classifier using that information.
#MachineLearning #PythonMachineLearning #MachineLearningTutorial #Python #PythonTutorial #PythonTraining #MachineLearningCource #LogisticRegression #sklearntutorials #scikitlearntutorials
Code: https://github.com/codebasics/py/blob/master/ML/8_logistic_reg_multiclass/8_logistic_regression_multiclass.ipynb
Exercise: Open above notebook from github and go to the end.
Topics that are covered in this Video:
0:00 - Theory (Binary classification vs multiclass classification)
0:26 - How to identify hand written digits?
1:02 - Coding (Solve a problem of hand written digit recognition)
11:24 - Confusion Matrix (sklearn confusion_matrix)
12:42 - Plot confusion matrix using seaborn library
14:00 - Exercise (Use sklearn iris dataset to predict flower type based on different features using logistic regression)
Do you want to learn technology from me? Check https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description for my affordable video courses.
Next Video:
Machine Learning Tutorial Python - 9 Decision Tree: https://www.youtube.com/watch?v=PHxYNGo8NcI&list=PLeo1K3hjS3uvCeTYTeyfe0-rN5r8zn9rw&index=10
Populor Playlist:
Data Science Full Course: https://www.youtube.com/playlist?list=PLeo1K3hjS3us_ELKYSj_Fth2tIEkdKXvV
Data Science Project: https://www.youtube.com/watch?v=rdfbcdP75KI&list=PLeo1K3hjS3uu7clOTtwsp94PcHbzqpAdg
Machine learning tutorials: https://www.youtube.com/watch?v=gmvvaobm7eQ&list=PLeo1K3hjS3uvCeTYTeyfe0-rN5r8zn9rw
Pandas: https://www.youtube.com/watch?v=CmorAWRsCAw&list=PLeo1K3hjS3uuASpe-1LjfG5f14Bnozjwy
matplotlib: https://www.youtube.com/watch?v=qqwf4Vuj8oM&list=PLeo1K3hjS3uu4Lr8_kro2AqaO6CFYgKOl
Python: https://www.youtube.com/watch?v=eykoKxsYtow&list=PLeo1K3hjS3uv5U-Lmlnucd7gqF-3ehIh0&index=1
Jupyter Notebook: https://www.youtube.com/watch?v=q_BzsPxwLOE&list=PLeo1K3hjS3uuZPwzACannnFSn9qHn8to8
Tools and Libraries:
Scikit learn tutorials
Sklearn tutorials
Machine learning with scikit learn tutorials
Machine learning with sklearn tutorials
To download csv and code for all tutorials: go to https://github.com/codebasics/py, click on a green button to clone or download the entire repository and then go to relevant folder to get access to that specific file.
🌎 My Website For Video Courses: https://codebasics.io/?utm_source=description&utm_medium=yt&utm_campaign=description&utm_id=description
Need help building software or data analytics and AI solutions? My company https://www.atliq.com/ can help. Click on the Contact button on that website.
#️⃣ Social Media #️⃣
🔗 Discord: https://discord.gg/r42Kbuk
📸 Dhaval's Personal Instagram: https://www.instagram.com/dhavalsays/
📸 Instagram: https://www.instagram.com/codebasicshub/
🔊 Facebook: https://www.facebook.com/codebasicshub
📝 Linkedin (Personal): https://www.linkedin.com/in/dhavalsays/
📝 Linkedin (Codebasics): https://www.linkedin.com/company/codebasics/
📱 Twitter: https://twitter.com/codebasicshub
🔗 Patreon: https://www.patreon.com/codebasics?fan_landing=true
detail
{'title': 'Machine Learning Tutorial Python - 8 Logistic Regression (Multiclass Classification)', 'heatmap': [{'end': 813.24, 'start': 773.674, 'weight': 0.953}], 'summary': 'Tutorial covers multi-class classification using logistic regression, training set with 1797 samples of handwritten digits, achieving an accuracy of 96.67% in image data analysis, and visualizing model performance through a confusion matrix.', 'chapters': [{'end': 138.559, 'segs': [{'end': 32.75, 'src': 'embed', 'start': 0.509, 'weight': 0, 'content': [{'end': 3.23, 'text': 'This is part two of logistic regression tutorial.', 'start': 0.509, 'duration': 2.721}, {'end': 6.832, 'text': "If you haven't watched the first part, then you should watch that first.", 'start': 3.351, 'duration': 3.481}, {'end': 15.056, 'text': 'In the previous tutorial, we discussed about binary classification where the output classes are binary in nature.', 'start': 7.552, 'duration': 7.504}, {'end': 16.257, 'text': 'They are either yes or no.', 'start': 15.116, 'duration': 1.141}, {'end': 19.898, 'text': 'In this one, we are going to discuss multi-class classification.', 'start': 16.777, 'duration': 3.121}, {'end': 25.661, 'text': "For example, when you're trying to predict which party a person is going to vote for, the possible outcomes are one of these three.", 'start': 19.958, 'duration': 5.703}, {'end': 32.75, 'text': "the concrete problem that we're going to solve today is to recognize the handwritten digit.", 'start': 26.946, 'duration': 5.804}], 'summary': 'Part two covers multi-class logistic regression for classification, with emphasis on recognizing handwritten digits.', 'duration': 32.241, 'max_score': 0.509, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc509.jpg'}], 'start': 0.509, 'title': 'Logistic regression part 2: multi-class classification', 'summary': 'Covers multi-class classification using logistic regression, employing a training set with 1797 samples of handwritten digits to build a model, and includes an interesting exercise.', 'chapters': [{'end': 138.559, 'start': 0.509, 'title': 'Logistic regression part 2: multi-class classification', 'summary': 'Discusses multi-class classification using logistic regression to recognize handwritten digits, using a training set with 1797 samples of handwritten digits to build a model and includes an interesting exercise.', 'duration': 138.05, 'highlights': ['The chapter discusses multi-class classification using logistic regression to recognize handwritten digits', 'Using a training set with 1797 samples of handwritten digits to build a model', 'Includes an interesting exercise']}], 'duration': 138.05, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc509.jpg', 'highlights': ['Using a training set with 1797 samples of handwritten digits to build a model', 'The chapter discusses multi-class classification using logistic regression to recognize handwritten digits', 'Includes an interesting exercise']}, {'end': 942.302, 'segs': [{'end': 173.161, 'src': 'embed', 'start': 139.079, 'weight': 0, 'content': [{'end': 141.102, 'text': "So I'm just going to print the first one.", 'start': 139.079, 'duration': 2.023}, {'end': 150.656, 'text': "it's an array.", 'start': 148.915, 'duration': 1.741}, {'end': 160.222, 'text': 'okay, as such, it is an 8 by 8 image, but the image is represented as a one-dimensional array.', 'start': 150.656, 'duration': 9.566}, {'end': 173.161, 'text': 'so if you count these elements, it will be 64, which is 8 by 8, and if you want to see this particular element, then you can use Matplotlib.', 'start': 160.222, 'duration': 12.939}], 'summary': 'Printing an 8x8 image represented as a one-dimensional array.', 'duration': 34.082, 'max_score': 139.079, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc139079.jpg'}, {'end': 339.14, 'src': 'embed', 'start': 301.807, 'weight': 1, 'content': [{'end': 314.403, 'text': 'taste split and we try to divide our data set into training and taste samples.', 'start': 301.807, 'duration': 12.596}, {'end': 320.066, 'text': 'So the way you do it is you say X train X taste.', 'start': 315.423, 'duration': 4.643}, {'end': 324.47, 'text': "I don't exactly remember the order of the argument.", 'start': 321.287, 'duration': 3.183}, {'end': 327.372, 'text': "So I'm going to what I'm going to do it.", 'start': 324.55, 'duration': 2.822}, {'end': 328.272, 'text': 'Okay, let me do this.', 'start': 327.472, 'duration': 0.8}, {'end': 334.597, 'text': "So train test split digits dot data because that's your data set.", 'start': 328.913, 'duration': 5.684}, {'end': 339.14, 'text': "Then you have digits dot target because that's your target variable.", 'start': 336.058, 'duration': 3.082}], 'summary': 'Data set divided into training and test samples using train_test_split function.', 'duration': 37.333, 'max_score': 301.807, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc301807.jpg'}, {'end': 452.183, 'src': 'embed', 'start': 417.831, 'weight': 2, 'content': [{'end': 424.495, 'text': 'so I want 20 percent of my samples to be this size and 80 percent to be the training.', 'start': 417.831, 'duration': 6.664}, {'end': 426.377, 'text': 'OK so if I look at.', 'start': 425.116, 'duration': 1.261}, {'end': 436.831, 'text': 'length of x train it is this, and if i look at length of x days, it is this.', 'start': 428.704, 'duration': 8.127}, {'end': 441.114, 'text': 'so this is roughly 80 percent of all available samples.', 'start': 436.831, 'duration': 4.283}, {'end': 445.638, 'text': 'all right, so i have a training and test data set split.', 'start': 441.114, 'duration': 4.524}, {'end': 452.183, 'text': 'now i can create my logistic regression model.', 'start': 445.638, 'duration': 6.545}], 'summary': 'Sample split: 20% test, 80% training, logistic regression model created.', 'duration': 34.352, 'max_score': 417.831, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc417831.jpg'}, {'end': 813.24, 'src': 'heatmap', 'start': 773.674, 'weight': 0.953, 'content': [{'end': 778.875, 'text': "And I'm calling a heat map here with the confusion matrix cm variable that we created here.", 'start': 773.674, 'duration': 5.201}, {'end': 784.296, 'text': 'And when you run that, this is the confusion matrix that you got.', 'start': 779.615, 'duration': 4.681}, {'end': 789.957, 'text': 'Now, the way this works is, see here you see 37 number.', 'start': 785.096, 'duration': 4.861}, {'end': 799.649, 'text': 'What it means is, 37 times the truth was 0 and my model predicted it to be 0.', 'start': 790.217, 'duration': 9.432}, {'end': 813.24, 'text': 'Here this 2 means 2 times my truth was 8, meaning I fed my model the image of 8 but my model said no it is 1.', 'start': 799.649, 'duration': 13.591}], 'summary': 'Using a heat map, the confusion matrix shows 37 correct predictions, and 2 incorrect predictions.', 'duration': 39.566, 'max_score': 773.674, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc773674.jpg'}], 'start': 139.079, 'title': 'Image data analysis with logistic regression', 'summary': "Discusses analyzing image data using a logistic regression model, achieving an accuracy of 96.67% and visualizing the model's performance through a confusion matrix, followed by an exercise using the iris flower dataset to build a logistic regression model and assess its accuracy.", 'chapters': [{'end': 942.302, 'start': 139.079, 'title': 'Image data analysis with logistic regression', 'summary': "Discusses analyzing image data using a logistic regression model, achieving an accuracy of 96.67% and visualizing the model's performance through a confusion matrix, followed by an exercise using the iris flower dataset to build a logistic regression model and assess its accuracy.", 'duration': 803.223, 'highlights': ['The model achieved an accuracy of 96.67% when tested on the X-Taste and Y-Taste datasets.', "The confusion matrix visualization provided a clear indication of the model's performance, highlighting instances where the model's predictions deviated from the actual truth.", 'The tutorial concludes with an exercise using the iris flower dataset to build a logistic regression model and assess its accuracy.']}], 'duration': 803.223, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/J5bXOOmkopc/pics/J5bXOOmkopc139079.jpg', 'highlights': ['The model achieved an accuracy of 96.67% when tested on the X-Taste and Y-Taste datasets.', "The confusion matrix visualization provided a clear indication of the model's performance, highlighting instances where the model's predictions deviated from the actual truth.", 'The tutorial concludes with an exercise using the iris flower dataset to build a logistic regression model and assess its accuracy.']}], 'highlights': ['The model achieved an accuracy of 96.67% when tested on the X-Taste and Y-Taste datasets.', 'Using a training set with 1797 samples of handwritten digits to build a model', 'The chapter discusses multi-class classification using logistic regression to recognize handwritten digits', "The confusion matrix visualization provided a clear indication of the model's performance, highlighting instances where the model's predictions deviated from the actual truth.", 'Includes an interesting exercise', 'The tutorial concludes with an exercise using the iris flower dataset to build a logistic regression model and assess its accuracy.']}