Python Machine Learning Projects Learn how to build Machine Learning projects from scratch (Deepali R. Vora, Gresha S. Bhatia) (Z-Library)
Science
No Description
272
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
(This page has no text content)
Page
3
Python Machine Learning Projects Learn how to build Machine Learning projects from scratch Dr. Deepali R Vora Dr. Gresha S Bhatia www.bpbonline.com
Page
4
Copyright © 2023 BPB Online All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor BPB Online or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. BPB Online has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, BPB Online cannot guarantee the accuracy of this information. First published: 2023 Published by BPB Online WeWork 119 Marylebone Road London NW1 5PU UK | UAE | INDIA | SINGAPORE ISBN 978-93-89898-27-9 www.bpbonline.com
Page
5
Dedicated to To my parents, in-laws, daughter, husband Mr. Rahul Vora, and family members — Dr. Deepali R Vora To my parents, in-laws, husband Mr. Sachin S Bhatia, and family members — Dr. Gresha S Bhatia
Page
6
About the Authors Dr. Deepali R Vora is a Professor and Head of Computer Science & Engineering at Symbiosis Institute of Technology, Pune, and has completed her Ph.D. in Computer Science and Engineering from Amity University, Mumbai. She has more than 22 years of teaching, research as well as Industrial experience. She has more than 60 research papers published in Journals and Conferences of International and national repute. She has co- authored three books and delivered various talks in Data Science and Machine learning. She has conducted hands-on sessions in Data Science using Python for students and faculty. She was appointed as a Syllabus Revision Committee member with Mumbai University and developed the course content for B.E. (Information Technology) course. She has received grants for conducting research and organizing training courses for faculties. She acts as a technical advisor and reviewer for many International Conferences and Journals. Her blogs on KnowledgeHut have received wide acknowledgment. She has developed a course on “Deep Learning” on the Unschool platform. Dr. Gresha S Bhatia is the Deputy Head of the Computer Engineering Department at Vivekanand Education Society’s Institute of Technology (VESIT), Mumbai, and has completed her Ph.D. Technology from the University of Mumbai. She has more than 25 years of industry and teaching experience. She has published more than 50 research papers in International Journals, conferences, and national conferences of repute. She has been awarded Microsoft AI for Earth Grant in the year 2019 as well as Minor Research Grant from the University of Mumbai. She has authored a book and has delivered sessions on Machine learning and Social Computing. She has also been a member of the Syllabus Revision Committee of Mumbai University for the undergraduate and postgraduate programs in Engineering. She has also been a technical advisor and reviewer for the number of International Conferences and Journals.
Page
7
About the Reviewer Ravi Choudhary is a Data Scientist from New Delhi, India. He has several years of experience working for the Government of India and Top Global companies. Ravi holds a Master’s degree in Artificial Intelligence from IIT and applies his expertise in this field to his work in data science. He is an expert in machine learning and has extensive experience developing and implementing advanced algorithms and models to extract insights from large and complex datasets. He has a deep understanding of various machine learning techniques, such as supervised and unsupervised learning, deep learning, and natural language processing. Ravi has applied his expertise in machine learning to a wide range of industries, including finance, healthcare, and transportation. His work has led to significant improvements in efficiency, accuracy, and performance. He is also known for his ability to communicate complex technical concepts to non-technical stakeholders and effectively collaborate with cross-functional teams.
Page
8
Acknowledgements We would like to take this opportunity to thank a few people for their continued support while writing this book. First and foremost, we would like to thank our parents and parents-in-law for encouraging us to author the book. This journey was possible due to the constant support of our life partner, who has been our pillar of strength. We are grateful to the BPB publishing house, which showed us the path and initiated our learning process. Our sincere gratitude to all our family members and well-wishers for always standing by us. We sincerely thank all those who have directly or indirectly supported us while authoring this book.
Page
9
Preface This book covers different aspects of machine learning, and the importance of developing machine learning algorithms that can be applied to real-life projects. The book elaborates on the need and different types of machine learning algorithms. It shows how the right amount of data, and the correct amount of training can help build optimized systems. These optimized systems can help reduce the cost as well as training errors. This book further provides a number of questions to be solved that gives a practical approach. It further gives importance for understanding the python code, its basic concepts as well as the implementation code for machine learning projects. This book is divided into five chapters. The book elaborates on the need for machine learning, its challenges and limitations. It further explores the development of machine learning algorithms through use of Python code. The working of the machine learning algorithms is emphasized through real- life case studies. The best algorithm that can be applied to a case study is elaborated through the various optimization and meta-heuristic approaches. The details of the chapters are specified below. Chapter 1: Introduction to ML – introduces the terms artificial intelligence, data science and machine learning and the differences between them. The various models, the types of machine learning algorithms, and the challenges and limitations faced are further explored. The chapter will further dwell on the working and the application areas of machine learning. Chapter 2: Python Basics for ML – will cover the concepts behind the Python programming language. The syntax and the need for python programming is further emphasized. It will elaborate on python tools and libraries. It further handles the concepts of file and exception handling, which form the crux of the machine learning domain. Chapter 3: An Overview of ML Algorithms – will introduce the various Machine learning algorithms. The major focus is to provide familiarity with the machine learning programs that can learn from the data provided and improve from experience, without any human intervention. These learning tasks may include learning the function that maps the input to the outputs or
Page
10
learning through the hidden structure in unlabeled data using algorithms coined under supervised and unsupervised learning. To further understand the core concepts, this chapter will explore the working process of any given machine learning algorithm through a number of examples. As Python forms a handy tool to get started with supervised and unsupervised learning, this chapter will explore its various functionalities. The chapter will further elaborate on the performance measures to be considered for evaluating the machine learning system that would have been developed. Chapter 4: Case Studies and Projects in Machine Learning – will provide an insight into the various case studies that use the concepts and algorithms of machine learning. This chapter will further introduce recommendation systems, its needs, the process of generating the recommendation systems as well as the current systems incorporating recommendation systems. Another case study will be focused on the application of machine learning algorithms on text mining applications, opinion mining and sentiment analysis. This chapter will further elaborate on applying various machine learning algorithms to image processing applications. More case studies incorporating predictive analysis, Social Media Analytics, Customer churning analytics, and Analytics in Education Systems will be explored in detail. Chapter 5: Optimization in ML Algorithm – will focus on the improvements in training the algorithms for the most accurate outputs. The chapter will thus focus on determining the best element or path, or techniques to improve the efficiency of algorithms by decreasing the training time as well as the cost incurred for the same. The concept of optimization and the hybrid algorithms that can be utilized will then be explained. The need for optimization techniques in Machine Learning based projects will then be highlighted. This will lead to applying techniques for optimization. The basic optimization techniques will then be explored, and the current research area on meta-heuristic approach will be further elaborated. To conclude the chapter, the various python libraries that could be available for optimization in Machine Learning projects will be explained.
Page
11
Code Bundle and Coloured Images Please follow the link to download the Code Bundle and the Coloured Images of the book: https://rebrand.ly/sn6fi4n The code bundle for the book is also hosted on GitHub at https://github.com/bpbpublications/Python-Machine-Learning-Projects. In case there's an update to the code, it will be updated on the existing GitHub repository. We have code bundles from our rich catalogue of books and videos available at https://github.com/bpbpublications. Check them out! Errata We take immense pride in our work at BPB Publications and follow best practices to ensure the accuracy of our content to provide with an indulging reading experience to our subscribers. Our readers are our mirrors, and we use their inputs to reflect and improve upon human errors, if any, that may have occurred during the publishing processes involved. To let us maintain the quality and help us reach out to any readers who might be having difficulties due to any unforeseen errors, please write to us at : errata@bpbonline.com Your support, suggestions and feedbacks are highly appreciated by the BPB Publications’ Family. Did you know that BPB offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the
Page
12
eBook version at www.bpbonline.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at: business@bpbonline.com for more details. At www.bpbonline.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on BPB books and eBooks.
Page
13
Piracy If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at business@bpbonline.com with a link to the material. If you are interested in becoming an author If there is a topic that you have expertise in, and you are interested in either writing or contributing to a book, please visit www.bpbonline.com. We have worked with thousands of developers and tech professionals, just like you, to help them share their insights with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Reviews Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions. We at BPB can understand what you think about our products, and our authors can see your feedback on their book. Thank you! For more information about BPB, please visit www.bpbonline.com. Join our book's Discord space Join the book's Discord Workspace for Latest updates, Offers, Tech happenings around the world, New Release and Sessions with the Authors: https://discord.bpbonline.com
Page
14
(This page has no text content)
Page
15
Table of Contents 1. Introduction to ML Introduction Structure Objectives Introduction to Machine Learning (ML) Models in Machine Learning Supervised machine learning model through training Unsupervised machine learning model: Self-sufficient learning Semi-supervised machine learning model Reinforcement machine learning model: Hit and Trial Types of Machine Learning Algorithms Working of Machine Learning algorithm Challenges for Machine Learning Projects Limitations of machine learning Application areas of ML Difference between the terms data science, data mining, machine learning and deep learning Conclusion Questions and Answers 2. Python Basics for ML Introduction Structure Objectives Spyder IDE Jupyter Notebook Python: Input and Output Commands Logical Statements Loop and Control Statements Functions and Modules Class Handling Exception Handling
Page
16
File Handling String functions Conclusion Questions and Answers 3. An Overview of ML Algorithms Introduction Structure Objectives Machine learning modeling flow Terms used in preprocessing Raw data (or just data) Prepared data Need for Data Preprocessing Preprocessing in ML Researching the best model for the data Training and testing the model on data Evaluation Hyperparameter tuning Prediction Metrics Used Regression algorithms Types of regression techniques Linear Regression Logistic Regression Polynomial Regression Stepwise Regression Ridge Regression Lasso Regression ElasticNet Regression Classification Terminology used in Classification Algorithms Types of classification algorithms Performance measures for classification Clustering Clustering algorithms K-Means Clustering
Page
17
Mean-Shift Clustering Agglomerative Hierarchical Clustering Clustering Validation Neural Network and SVM Building Blocks: Neurons Combining Neurons into a Neural Network Training the neural network Neural Network Architectures Support vector machine (SVM) Machine Learning Libraries in Python Numpy Pandas Populating the Dataframe Displaying the Data Using Dataframe Accessing the Data Selectively in Dataframe Basic Descriptive Statistics using Pandas Data transformation Data Preprocessing – Handling missing values MatplotLib Line Graph Scatter Plot Bar plot Histogram Pie Chart Evaluation of ML Systems Test and Train Datasets Performance Measure Model Evaluation Techniques Model evaluation metrics Classification Metrics Regression Metrics Conclusion Questions 4. Case Studies and Projects in Machine Learning Introduction Structure
Page
18
Objectives Recommendation Generation Importance of recommendation systems Key terms used Items/Documents Query/Context Approaches for building recommendation systems Basic recommendation systems Candidate Generation Recommendation generation Information collection phase Learning phase Prediction/recommendation phase Evaluation metrics for recommendation algorithms Statistical accuracy metric Case study on Recommendation system: E-learning system domain Recommender systems Problem definition Objective of the case study Considerations for the case study System development Constraints / limitations while developing the recommendation system Text Analysis and Mining Importance of text mining Basic blocks of text mining system using ML Steps involved in preparing an unstructured text document for deeper analysis Text mining techniques Information Retrieval (IR) Natural language processing (NLP) Sentiment analysis Naive Bayes Linear regression Support Vector Machines (SVM) Deep learning Case study on product recommendation system based on sentiment
Page
19
analysis Product recommendation Problem definition System development Considerations for the case study Opinion mining Image processing Importance of image processing Purpose of image processing Basic Image Processing System Image Processing using popular ML algorithms Real Time case studies of Image Processing using ML Problem definition Objective of the case study Considerations for the case study System development Algorithms that can be employed Tool Utilization Constraints/Limitations while developing the system Evaluation Measures Predictive analytics Importance of predictive analytics Need for predictive analysis Machine Learning vs Predictive Modeling Building a predictive model Types of predictive algorithms Types of Predictive Analytical Models Comparison of Predictive Modeling and Predictive Analytics Predictive modeling vs data analytics Comparison between and Predictive Analytics and Data Analytics Uses or applications of Predictive Analytics Benefits of predictive analytics Challenges of predictive modeling Limitations of predictive modeling Case studies Social media analytics Case study of Instagram
Page
20
Case study on Customer churning analytics Building the hypothesis Case study on learning analytics in education systems Challenges faced Approach Other case studies Conclusion 5. Optimization in ML Algorithm Introduction Structure Objectives Optimization – Need of ML projects Types of optimization techniques Conventional Approach Metaheuristic Approach Basic Optimization Techniques Backpropagation optimization Gradient descent optimization Metaheuristic approaches to optimization Types of metaheuristic algorithms Single solution-based algorithms Population-based algorithms Improvisation of ML algorithms by optimizing the learning parameters Case study 1: Metaheuristic Optimization Techniques in Healthcare Case Study 2: Genetic Algorithm (GA) in Batch Production Optimization using Python Conclusion Questions Index
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
# Python Machine Learning Projects: Learn How to Build Machine Learning Projects from Scratch
## 【One-Line Pitch】
A practical, project-oriented introduction to machine learning with Python, covering everything from Python fundamentals and data preprocessing to core ML algorithms and model evaluation—ideal for beginners and students who want to build real ML projects from the ground up.
## 【Book Arc】
- **Opening (~0%–10%)**: Introduces the authors' credentials and sets the stage with foundational concepts—what machine learning is, how it differs from data science, data mining, and deep learning, and the key challenges organizations face when implementing ML projects.
- **Early (~10%–19%)**: Covers the essential Python programming skills needed for ML, including data structures (primitive and non-primitive), functions, modules, file handling, and string manipulation—the building blocks for any ML project.
- **Early (~19%–29%)**: Continues Python fundamentals with control flow (if/elif/else), advanced string functions, and an overview of the ML modeling flow, including how training and testing data are used in the model development process.
- **Early (~29%–42%)**: Dives into the ML algorithm landscape—supervised vs. unsupervised learning, clustering and association methods, regression techniques (linear, polynomial, stepwise, ridge, lasso, ElasticNet), and an introduction to neural networks and SVM with their key differences.
- **Middle (~42%–48%)**: Focuses on the essential Python libraries for ML—NumPy for array operations and Pandas for data preprocessing—along with descriptive statistics functions that help you understand and prepare your data before feeding it to algorithms.
- **Middle (~48%+)**: Covers model evaluation metrics, including classification accuracy, confusion matrices, and logarithmic loss, explaining how to measure whether your ML model actually performs well on unseen data.
## 【Key Takeaways】
- **Machine learning vs. related fields** (Early): ML uses automated algorithms to learn from data iteratively, while deep learning requires millions of data points and uses neural networks for complex pattern recognition—knowing these distinctions helps you choose the right approach for your problem.
- **The black box problem is real** (Early): As ML models have evolved from simple algorithms to deep neural networks, understanding *why* a model makes a prediction has become difficult—this is a critical consideration when deploying ML in production environments.
- **Python's data structures are ML-ready** (Early): Python offers both primitive data structures (common across languages) and non-primitive ones (native to Python, designed for data analysis), making it particularly well-suited for machine learning applications.
- **String handling is a core ML skill** (Early): Since most collected data is categorical rather than numeric, mastering string functions like `split()`, `strip()`, and `lower()` is essential for data manipulation and preprocessing.
- **The ML modeling flow is systematic** (Early): A machine learning model is code trained on data—you split data into training and testing sets, train the algorithm, evaluate performance metrics, and then use the model for prediction on new data.
- **Regression has many flavors** (Early): Beyond simple linear regression (y=mx+b), techniques like polynomial, stepwise, ridge, lasso, and ElasticNet regression each solve specific problems—from handling multiple independent variables to reducing error when variables are highly correlated.
- **SVM and neural networks serve different purposes** (Middle): SVMs are conceptually simpler, theoretically founded, and maximize margins between hyperplanes, while neural networks are more complex with hidden layers and are heuristic in nature—your choice depends on your data and problem complexity.
- **Pandas is the preprocessing workhorse** (Middle): With its Series and DataFrame structures, Pandas makes reading data from CSV and Excel files and preparing it for ML algorithms straightforward—this is where most of your preprocessing time will be spent.
## 【Reading Tips】
- **Skim the Python fundamentals if you're experienced** (Early): Chapters on data structures, functions, and control flow are essential for beginners but can be skimmed quickly if you already know Python—focus instead on the ML-specific applications and examples.
- **Deep-read the algorithm overview chapter** (Early–Middle): The comparisons between ML and deep learning, the regression technique breakdown, and the SVM vs. neural network table are high-value reference material you'll want to return to when selecting algorithms for your own projects.
- **Pay special attention to the evaluation metrics section** (Middle): Understanding accuracy, confusion matrices, and logloss is critical—these are the tools you'll use to judge whether your models actually work, and they're often where beginners struggle.
- **Practice the library functions hands-on** (Middle): The NumPy and Pandas function tables are meant to be used, not just read—open a Python interpreter and experiment with array operations and DataFrame manipulation to make these stick.
- **Use the code bundle and GitHub repository** (Opening): The book provides downloadable code and colored images—download these before you start reading so you can follow along with the examples and see the expected outputs.
## 【Coverage Limits】
This guide covers the foundational and conceptual portions of the book (approximately the first half). The excerpts do not cover the specific project walkthroughs that likely appear in later chapters, nor do they include detailed code implementations of complete ML projects.
##
Passage locations
Page 6
been a member of the Syllabus Revision Committee of Mumbai University for the undergraduate and postgraduate programs in Engineering. She has also been a tec...
View in text
Excerpt 2
w centroids, repeat step 2 and 3. Find the closest distance for each data point from new centroids and get associated with new k- clusters. Repeat this proce...
View in text
Excerpt 3
thm tries to learn without the availability of labeled data. It aids in discovering interesting relations between variables in large databases. The methods u...
View in text
Excerpt 4
e use of one of the statistical functions: Example 9: >>>df.describe() Gender count 8.000000 mean 0.375000 std 0.517549 min 0.000000 25% 0.000000 50%...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay