Chapter 1 - Introduction to Machine Learning PDF
Document Details
Uploaded by FestiveRuthenium
Dr. Mahmoud Elsabagh
Tags
Summary
This document provides a comprehensive introduction to machine learning. It defines machine learning, outlines its core components, describes supervised and unsupervised learning approaches, and highlights various applications. Examples such as image recognition, and natural language processing are used to illustrate concepts.
Full Transcript
Machine Learning Chapter 1 Introduction to Machine Learning Dr. Mahmoud Elsabagh Course Objectives Understand Machine Learning Fundamentals: Learn the core concepts of machine learning, including key terms, types of l...
Machine Learning Chapter 1 Introduction to Machine Learning Dr. Mahmoud Elsabagh Course Objectives Understand Machine Learning Fundamentals: Learn the core concepts of machine learning, including key terms, types of learning (supervised, unsupervised, reinforcement), and their applications. Apply Supervised Learning Algorithms: Gain proficiency in using algorithms like linear regression, decision trees, and SVM for tasks such as classification and regression. Explore Unsupervised Learning: Learn how to identify patterns in data using clustering techniques (k-Means, hierarchical) and dimensionality reduction (PCA). Master Neural Networks and Deep Learning: Understand and implement neural networks and advanced architectures like CNNs and RNNs for tasks like 2 image recognition and sequence modeling. Course Objectives Evaluate and Tune Model Performance: Learn to assess models using performance metrics (accuracy, precision) and optimize models through cross- validation and hyperparameter tuning. Data Preprocessing and Feature Engineering: Develop skills to clean, preprocess, and engineer features from raw data to enhance model accuracy and performance. Hands-on Experience with ML Tools: Work on real-world projects using popular tools such as Python, Scikit-learn, TensorFlow, and Keras. Ethical and Fair Use of Machine Learning: Understand the ethical implications of machine learning, addressing biases, fairness, and privacy concerns in model development. Introduction to Reinforcement Learning: Learn the basics of reinforcement learning, including Q-learning and policy optimization for decision-making tasks. Deploy ML Models into Production: Gain experience in deploying machine learning models into real-world environments using APIs and cloud platforms. 3 Contents Chapter 1: Introduction to Machine Learning Chapter 2: Supervised Learning Fundamentals Chapter 3: Regression Algorithms Chapter 4: Classification Algorithms Chapter 5: Decision Trees and Ensemble Learning Chapter 6: Unsupervised Learning Basics Chapter 7: Neural Networks and Deep Learning Chapter 8: Natural Language Processing (NLP) and Sequence Models Chapter 9: Reinforcement Learning Chapter 10: Model Evaluation and Tuning Chapter 11: Model Deployment and Applications Chapter 1: Introduction to Machine Learning 5 Contents 1. What is Machine Learning? 2. Types of Machine Learning 3. Why is Machine Learning Important? 4. Key Terminology in Machine Learning 5. ML Workflow and Pipeline 6. Common Applications of Machine Learning 7. Common Algorithms in Machine Learning 8. Limitations and Challenges of Machine Learning 1. What is Machine Learning? Traditional Programming Data Output Program Machine Learning Data Program Output 1. What is Machine Learning? Definition: Machine Learning (ML) is a subset of Artificial Intelligence (AI) that focuses on building systems that can learn from and make decisions based on data, without being explicitly programmed for specific tasks. The goal is to enable computers to learn from experience and adapt their behavior over time. ➜ Key Components: - Data: Raw information, typically structured in the form of features and labels. - Algorithms: Mathematical models used to learn patterns from data. - Experience: Data and feedback used to improve model performance over time. 1. What is Machine Learning? ➜ Formal Definition (Tom M. Mitchell): "A computer program is said to learn from experience E with respect to some task T and some performance measure P, if its performance on T, as measured by P, improves with experience E." ➜ Examples: - Spam email filtering (task: classify emails as spam or not spam) - Recommendation systems (task: predict what a user will like) Problem Setup ➜ One definition of machine learning: A computer program improves its performance on a given task with experience (i.e. examples, data). So we need to separate Task Experience Performance 1- Task ➜ Task : What is the problem that the program is solving? ➜ Machine learning allows us to tackle tasks that are too difficult to solve with fixed programs written and designed by human beings. ➜ Machine learning is interesting because developing our understanding of machine learning entails developing our understanding of the principles that underlie intelligence. 1- Task (Cont.) - Some of the most common machine learning tasks include the following: ➜ Classification : In his type of task, the computer program is asked to specify which of k categories some input belongs to (Discrete values). - Classification Algorithms attempt to map inputs into one of a set of classes (Colors, Good and Bad Credit Risks) ➜ Regression : In this type of task, the computer program is asked to predict a numerical value given some input (Continuous values). - Regression Algorithms attempt to mapinputs into continuous output (Integers, Real Numbers, Vectors, etc.) 1- Task (Cont.) - Some of the most common machine learning tasks include the following: ➜ Transcription: In this type of task, the machine learning system is asked to observe a relatively unstructured representation of some kind of data and transcribe it into discrete, textual form. E.g.: optical character recognition (OCR), where the computer program is shown a photograph containing an image of text and is asked to return this text in the form of a sequence of characters. ➜ Machine translation: In a machine translation task, the input already consists of a sequence of symbols in some language, and the computer program must convert this into a sequence of symbols in another language. 2- Experience ➜ Experience :What is the data (examples) that the program is using to improve its performance? Experience is a dataset. A dataset is a collection of many examples. An example is a collection of features that have been quantitatively measured from some object or event that we want the machine learning system to process. 3- Performance level ➜ Performance measure : How is the performance of the program (when solving the given task) evaluated? - In order to evaluate the abilities of a machine learning algorithm, we must design a quantitative measure of its performance. Usually this performance measure P is specific to the task T being carried out by the system. - Accuracy : Accuracy is just the proportion of examples for which the model produces the correct output. - Error Rate : The proportion of examples for which the model produces an incorrect output. WHEN DO WE USE MACHINE LEARNING? ➜ ML is used when: Human expertise does not exist (navigating on Mars) Humans can’t explain their expertise (speech recognition) Models are based on huge amounts of data (genomics) Some more examples of tasks that are best solved by using a learning algorithm ➜ Recognizing patterns: – Facial identities or facial expressions – Handwritten or spoken words – Medical images ➜ Generating patterns: – Generating images or motion sequences ➜ Recognizing anomalies: – Unusual credit card transactions – Unusual patterns of sensor readings in a nuclear power plant ➜ Prediction: – Future stock prices or currency exchange rates 2. Types of Machine Learning 2. Types of Machine Learning Supervised Unsupervised Discrete Classification Clustering Continuous Dimensionality Regression reduction 2. Types of Machine Learning ➜ Supervised Learning: In supervised learning, the algorithm is trained using labeled data. Each data point has a corresponding label or outcome. - Example: Predicting house prices based on features like size, location, etc. - Algorithms: Linear regression, decision trees, support vector machines (SVM). ➜ Unsupervised Learning: The algorithm is trained on data without explicit labels. The goal is to find hidden patterns or structure in the data. - Example: Grouping customers into segments based on purchasing behavior. - Algorithms: K-means clustering, hierarchical clustering, PCA. More Types of Machine Learning ➜ Semi-supervised learning - mix of Supervised and Unsupervised learning - usually small part of data is labeled ➜ Reinforcement Learning: - In reinforcement learning, an agent learns by interacting with an environment and receiving feedback in the form of rewards or penalties. - Model learns from a series of actions by maximizing a reward function - The reward function can either be maximized by penalizing bad actions and/or rewarding good actions - - Example: - - A robot learning to navigate a maze by receiving rewards for reaching the goal. - - Training of self-driving car using feedback from the environment - Algorithms: Q-learning, Deep Q-Networks (DQN). Supervised Learning Paradigm Learning entries Training usually entries are Text, Images encoded Omic data, Feature as vector (x1,x2,…..,xn) Etc… vectors Human expert labels each learning Machine entries Labels learning algorithm Feature Testing vector Text, Images Expected Predictive Omic data, Label Model Etc… Supervised Learning ➜ In supervised learning, we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output. ➜ Supervised learning problems are categorized into "regression" and "classification" problems. ➜ In a regression problem, we are trying to predict results within a continuous output, meaning that we are trying to map input variables to some continuous function. ➜ In a classification problem, we are instead trying to predict results in a discrete output. In other words, we are trying to map input variables into discrete categories. 250 175 750 Supervised Learning Regression: “right answers” or “Labeled Predict continuous valued data” given output (price) Lung Cancer (Malignant or bengin) Classification Discrete valued output (0 or 1) Unsupervised Learning ➜ Unsupervised learning, on the other hand, allows us to approach problems with little or no idea what our results should look like. ➜ We can derive structure from data where we don't necessarily know the effect of the variables. ➜ We can derive this structure by clustering the data based on relationships among the variables in the data. ➜ With unsupervised learning there is no feedback based on the prediction results, i.e., there is no teacher to correct you. Unsupervised Y X Unsupervised learning is where you only have input data and no corresponding output variables. Unsupervised Learning applications The expression of set of genes for a certain individual Genes Individuals We need to cluster the individuals based of the similarity of their genes. Unsupervised Learning applications Genes Individuals Microarray data Have a group of individuals On each measure expression of a gene Run algorithm to cluster individuals into types of people 3. Why is Machine Learning Important? ➜ Data-Driven Decision Making: ML models can analyze vast amounts of data, finding patterns and making predictions more efficiently than traditional methods. ➜ Automation: ML can automate tasks that are too complex for humans to program manually, such as real-time language translation or facial recognition. ➜ Adaptability: ML systems improve over time as they are exposed to more data, making them adaptable to new situations (e.g., personalized recommendations). ➜ Ubiquity: From virtual assistants (e.g., Siri, Alexa) to self-driving cars, ML is increasingly integrated into everyday life. 4. Key Terminology in Machine Learning ➜ Features (or Attributes): The individual measurable properties or characteristics of a dataset, such as height, weight, or age. Features are typically represented as columns in a dataset. - Example: In a dataset of houses, features could include square footage, number of bedrooms, location, etc. ➜ Labels (or Targets): The output or dependent variable that the model is trying to predict. In supervised learning, labels are provided during training. - Example: In a house price prediction task, the label could be the actual price of the house. 4. Key Terminology in Machine Learning ➜ Training Data: The dataset used to train a machine learning model. It contains both the features and the corresponding labels (for supervised learning). ➜ Test Data: A separate dataset used to evaluate the model’s performance. It contains features, but the model has never seen the corresponding labels. ➜ Validation Data: A third dataset used to tune model parameters (such as hyperparameters) without overfitting to the training data. 5. ML Workflow and Pipeline ➜ Problem Definition: Clearly define the problem and what you are trying to predict or classify. This includes understanding the data and business requirements. ➜ Data Collection: Collect and gather relevant data from various sources. This data can come from databases, APIs, or be scraped from the web. ➜ Data Preprocessing: ○ Clean the data by handling missing values, normalizing features, encoding categorical variables, etc. Feature engineering (creating new features) may also be part of this step. 5. ML Workflow and Pipeline ➜ Model Selection: Choose an appropriate model or algorithm based on the type of problem (classification, regression, clustering, etc.) and the nature of the data. ➜ Model Training: Train the model using the training data. During this process, the model learns to map inputs (features) to outputs (labels). ➜ Model Evaluation: Use evaluation metrics to measure how well the model performs on test data. Common metrics include accuracy, precision, recall, and Mean Squared Error (MSE). ➜ Model Tuning: Fine-tune the model by adjusting hyperparameters and using techniques like cross- validation to improve performance. ➜ Model Deployment: Once the model is trained and evaluated, it can be deployed to production for real-world use. This could involve serving the model via APIs or integrating it into a larger system. 6. Common Applications of Machine Learning ➜ Image and Speech Recognition: ML is used in systems that identify objects, people, handwriting, or speech. Examples include facial recognition software and voice assistants. ➜ Healthcare: Predictive models can assist in diagnosing diseases, personalizing treatments, and predicting patient outcomes. ML is also used in medical imaging analysis. ➜ Natural Language Processing (NLP): ML is the foundation for tasks like sentiment analysis, language translation, and chatbots. It enables machines to understand and generate human language. ➜ Financial Services: ML helps in fraud detection, credit scoring, risk management, and algorithmic trading. ➜ Recommendation Systems: ML models are used to suggest products or content to users based on their preferences and past behavior (e.g., Netflix, Amazon recommendations). Examples Example 1 : face recognition Examples Example 2: Prediction of search queries Examples Example 3: Self-driving cars Examples Example 4: Machine Translation Examples Example 5 7. Common Algorithms in Machine Learning ➜ Linear Regression: Used for predicting continuous outcomes by fitting a linear equation to the data. ➜ Logistic Regression: Used for binary classification tasks, such as predicting whether an email is spam or not. ➜ Decision Trees: A model that splits data into different branches based on feature values, used for both classification and regression tasks. ➜ k-Nearest Neighbors (k-NN): A simple algorithm that classifies a data point based on the majority class of its nearest neighbors. ➜ Support Vector Machines (SVM): A powerful classification algorithm that finds the hyperplane which best separates the data into classes. 8. Limitations and Challenges of Machine Learning ➜ Data Dependency: ML models heavily rely on large amounts of high-quality data. Insufficient or biased data can lead to poor model performance. ➜ Overfitting: When a model learns the noise in the training data rather than the underlying pattern, it performs well on training data but poorly on unseen data. ➜ Interpretability: Many complex models, especially deep learning models, are black boxes. It's difficult to interpret how the model arrives at its predictions. ➜ Ethical Concerns: Bias in data can lead to biased models, resulting in unfair or discriminatory decisions (e.g., in hiring or credit approval). References Peter Flach, Machine Learning. The Art and Science of Algorithms that Make Sense of Data. T. Mitchell, Machine Learning, McGraw-Hill John D. Kelleher, Fundamental of Machine Learning for predictive Data Analytic. Thanks! Any questions? 45