Carlos and Maya review the machine learning process, learning types, linear regression, KNN, logistic regression, and exploratory data analysis in Unit 10.
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Welcome to the COP 4020 course podcast. I am Carlos, your professor and host, and Maya is joining me for Unit 10. Today we are reviewing machine learning, the major learning types, selected supervised algorithms, and exploratory data analysis. Machine learning is mentioned in almost every technology discussion. What should we understand beyond the popular examples? We need to understand the full process. A useful model begins with a defined task and relevant data.
The data must be prepared, an appropriate algorithm must be selected, the model must be trained and evaluated, and only then should it be used for predictions or inferences. So today's goal is not simply to memorize the names of algorithms. Exactly. We will connect each algorithm to the problem it solves, the assumptions it makes, and the evidence needed to judge its performance. We will also explain why exploratory data analysis comes before confident modeling decisions. Artificial intelligence is the study of creating machines that simulate capabilities
associated with human thinking and behavior. The lecture summarizes its question as: how can we make machines smart? Where does machine learning fit within artificial intelligence? Machine learning is a subfield of AI. It studies how a machine can learn from data and improve through experience without a programmer explicitly writing every rule for every case. Does that mean an ML system has no programming? No. People still design the software, choose the data, select features and algorithms,
define the objective, and evaluate the result. What changes is that some behavior is learned from examples rather than being expressed entirely as fixed if-then rules. The slide shows AI, machine learning, and deep learning as nested areas, with data science overlapping them. That diagram gives us a useful hierarchy. Deep learning is a family of machine-learning methods based on multilayer neural networks. Data science is broader and overlaps AI because it includes collecting, cleaning, analyzing, visualizing, and communicating data, whether or not an AI model
is involved. the machine-learning process can be organized into six stages: collect raw data, prepare the data, select a model, train the model, validate and improve it, and finally make predictions or inferences. Where can a student find data for a project? Suggested data sets include Google Dataset Search, Kaggle, the UCI Machine Learning Repository, and government websites. A dataset should not be chosen only because it is available. It must also be relevant, documented, lawful to use, and suitable for the question.
Why does data preparation receive so much attention? Raw data commonly contains missing values, duplicates, inconsistent formats, outliers, errors, or categories that need clarification. Preparation includes cleaning, wrangling, exploration, and visualization. The lecture notes that this work can consume a large portion of a data scientist's time. How do we select a model after preparing the data? The choice depends on the preliminary analysis, the types of variables,
and the objective. Predicting a continuous value suggests regression. Assigning a category suggests classification. Searching for unlabeled groups suggests an unsupervised method. Then we divide the data into training and testing sets? Yes. The most common is an eighty-twenty split for training. Training data is used to fit the model. Testing data should remain separate so it can provide a more honest estimate of performance on unseen examples.
Where does validation fit? Validation data supports choices such as hyperparameter tuning while the model is being improved. The test set should not become a repeated tuning target. After the model and its settings are finalized, the untouched test set is used for the final evaluation. Only after that evaluation should the system make operational predictions or support an inference. Correct. Even then, performance should be monitored because real-world data and conditions
can change. An algorithm is a general procedure used to learn from data. When that procedure is applied to a particular training dataset, the result is a model. The algorithm is the learning recipe; the model is the learned artifact. The lecture divides machine learning into supervised, unsupervised, and reinforcement learning. What distinguishes them? Supervised learning receives inputs paired with known outputs, usually called labels or targets. It learns a relationship and then predicts labels for new inputs.
Its two main categories are regression and classification. Regression predicts a quantity, while classification predicts a category. Exactly. Predicting a salary or home price is regression. Identifying an email as spam or not spam is classification. What happens when there are no labels? That is the setting for unsupervised learning. The algorithm searches for structure without being told the correct output. Clustering is a common example: the system groups observations that appear similar.
And reinforcement learning uses rewards and penalties? Yes. An agent chooses among allowed actions, observes the result, and learns a strategy that accumulates greater reward over time. The slides mention games, robotics, and natural-language applications. So these approaches differ mainly in the feedback available during learning. That is a useful way to remember them: labeled examples for supervised learning, hidden structure for unsupervised learning, and consequences of actions for reinforcement learning.
Linear regression estimates a linear relationship between one or more features and a numerical target. In simple terms, it finds the line that best describes the observed data. The lecture separates prediction from inference. How are they different? Prediction focuses on estimating the target for an unseen observation. The home example provides the square footage and sale prices of nearby houses. A fitted model can estimate a price for a sixteen-hundred-square-foot home. Inference asks what the model tells us about the relationship between variables.
Correct. The country example examines GDP, income inequality, unemployment, and life expectancy. An analyst may ask how each feature is associated with life expectancy, including the direction, magnitude, and uncertainty of that relationship. Can a strong prediction prove that a feature causes the target to change? No. Regression can identify associations, but causal claims require an appropriate research design and assumptions. Confounding variables, measurement choices, and sampling decisions can influence the
observed relationship. What assumptions should make us cautious about a linear model? The relationship should be reasonably approximated by a line, the observations and errors need appropriate behavior for the intended analysis, and influential outliers or highly correlated features can cause problems. A plot of the data and residuals helps reveal whether the model is missing important structure. The lecture introduces three regression metrics. R-squared describes how much of the target's variability is accounted for by the
model. A value closer to one generally indicates a better fit to the evaluated data. What do root mean squared error and mean absolute error measure? Both summarize prediction errors. Root mean squared error gives greater weight to large errors because the residuals are squared. Mean absolute error averages the absolute size of the residuals and is less sensitive to extreme errors. For both, values closer to zero are better, but they must be interpreted in the target's units and context.
Could a nearly perfect training score be a warning? Yes. It may indicate overfitting: the model has learned the training data too specifically and may fail on new examples. Underfitting occurs when the model is too simple to capture the important pattern. We compare training, validation, and test performance to distinguish these cases. What are the main advantages of linear regression? It is efficient, easy to implement, interpretable, and widely studied.
Its disadvantages are equally important: it struggles with complex nonlinear patterns, can be affected by outliers and correlated features, and can produce misleading results when its assumptions are ignored. K nearest neighbors, or KNN, is a supervised algorithm that predicts a new point from the training points closest to it. For classification, the nearby labels vote on the new point's class. What steps does the algorithm follow? First, it calculates the distance from the new point to the stored training points.
Second, it selects the k nearest points. Third, it uses their labels, often through majority voting, to make the prediction. What exactly is k? K is a hyperparameter that specifies how many neighbors are considered. It is chosen by the developer rather than learned directly as a model coefficient. Why not always use the closest single neighbor? A very small k can react too strongly to noise or unusual training examples, leading to high variance and overfitting.
A very large k can smooth away real local patterns and underfit. The lecture suggests the square root of the training-set size as a starting point, followed by validation. Why are odd values of k often preferred? With two classes, an odd k reduces the chance of a tie. More generally, the tie-breaking rule should be defined explicitly. The slides say KNN has no model-training stage. Does that make it fast? It makes fitting simple because the method largely stores the training data.
Prediction can be slow, however, because distances may be computed against many observations. KNN also suffers from the curse of dimensionality: as the number of features grows, distance becomes less informative unless features are carefully selected and scaled. Then KNN is easy to explain and can capture nonlinear boundaries, but it is not ideal for very large datasets or applications that require instant predictions. Precisely. Feature scaling, the distance metric, the value of k, and validation all matter.
Despite its name, logistic regression is primarily a classification algorithm. It estimates the probability that an observation belongs to a class. The slide uses time on a webpage to predict whether a visitor will buy a product. Yes. A logistic function maps the model's score to a value between zero and one. That value can be interpreted as the estimated probability of class one. A threshold, often one-half, converts the probability into a class prediction.
How is the model trained? The training process searches for coefficients that make the observed labels likely under the model. In other words, it adjusts the logistic curve to maximize the likelihood of the training data. Why might probabilities be more useful than receiving only a class label? They communicate uncertainty and allow the threshold to match the cost of different errors. A medical screening system may use a lower threshold when missing a possible case is especially costly.
A different application may require stronger evidence before assigning the positive class. What are logistic regression's strengths and limitations? It trains and predicts efficiently, supports interpretation, and produces class probabilities. A basic logistic model creates a linear decision boundary in feature space, so it may miss complex relationships. It can also overfit when there are too many features for the amount of data, and it may require feature engineering, selection, regularization, and outlier analysis.
How should I choose among linear regression, KNN, and logistic regression? Start with the task. Use linear regression for a numerical target. Use logistic regression or KNN for classification. Then compare assumptions, interpretability, speed, dataset size, nonlinear structure, and validated performance. Exploratory data analysis, or EDA, is the initial investigation of a dataset. Its purpose is to understand the data's structure and characteristics before making
strong modeling claims. What questions should we ask during EDA? The lecture highlights five areas. First, data type: are variables numerical, categorical, or text? Second, completeness: are values missing? Third, diversity: is the dataset varied or repetitive? Fourth, distribution: what averages, extremes, clusters, or anomalies appear? Fifth, representativeness: does the sample reflect the broader population and
context? The data-quality slide shows bad data going into a perfect model and still producing a bad result. That is one of the most important lessons in the unit. A sophisticated algorithm cannot repair an irrelevant, biased, mislabeled, or poorly measured dataset by itself. How does visualization support EDA? Data visualization represents information graphically so patterns become more accessible and understandable. It can provide quick insight, reveal trends and anomalies, support feature
selection, help evaluate models, and communicate results to stakeholders. A graph is not automatically truthful, though. Correct. The chart type, scale, labels, aggregation, omitted data, and visual emphasis can change the message. A responsible analyst pairs a clear visual with context, definitions, and the limitations of the data. Let us close with five review questions. Maya, question one: what is the difference between an ML algorithm and an ML model? The algorithm is the general learning procedure.
The model is the learned result produced when that algorithm is applied to specific training data. Question two: how do supervised, unsupervised, and reinforcement learning differ? Supervised learning uses labeled examples, unsupervised learning searches for structure without labels, and reinforcement learning improves through actions, rewards, and penalties. Question three: when is linear regression appropriate? When the target is numerical and the relationship can be modeled reasonably with a
linear form, while its assumptions and residuals are checked. Question four: what role does k play in KNN? It determines how many nearby training points participate in the prediction. Small and large values create different overfitting and underfitting risks. Final question: why should EDA occur before modeling? EDA reveals data types, missing values, distributions, anomalies, diversity, and representativeness. Those findings influence preparation, features, model choice,
and whether the project is credible at all. Excellent. Unit 10 gives us a complete way to think about machine learning: begin with a meaningful question, understand and prepare the data, select an algorithm that fits the task, train and tune without contaminating the final test, and evaluate the result in context. And a more complicated model is not automatically a better one. Exactly. The best model is one that performs reliably for the intended use, can be evaluated honestly, and has limitations its users understand.
Thank you for joining us. We will see you in the next COP 4020 lecture.