Machine Learning for NLP
All Episodes
Unit 10: Machine Learning, Supervised Algorithms, and EDA

Unit 10: Machine Learning, Supervised Algorithms, and EDA

0:00|0:00
Carlos and Maya review the machine learning process, learning types, linear regression, KNN, logistic regression, and exploratory data analysis in Unit 10.

This show was created with Jellypod, the AI Podcast Studio. Create your own podcast with Jellypod today.


Chapter 1

Imported Transcript

Carlos

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.

Claire Brooks

Machine learning is mentioned in almost every technology discussion. What should we understand beyond the popular examples?

Carlos

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.

Claire Brooks

So today's goal is not simply to memorize the names of algorithms.

Carlos

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.

Carlos

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?

Claire Brooks

Where does machine learning fit within artificial intelligence?

Carlos

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.

Claire Brooks

Does that mean an ML system has no programming?

Carlos

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.

Claire Brooks

The slide shows AI, machine learning, and deep learning as nested areas, with data science overlapping them.

Carlos

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.

Carlos

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.

Claire Brooks

Where can a student find data for a project?

Carlos

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.

Claire Brooks

Why does data preparation receive so much attention?

Carlos

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.

Claire Brooks

How do we select a model after preparing the data?

Carlos

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.

Claire Brooks

Then we divide the data into training and testing sets?

Carlos

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.

Claire Brooks

Where does validation fit?

Carlos

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.

Claire Brooks

Only after that evaluation should the system make operational predictions or support an inference.

Carlos

Correct. Even then, performance should be monitored because real-world data and conditions can change.

Carlos

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.

Claire Brooks

The lecture divides machine learning into supervised, unsupervised, and reinforcement learning. What distinguishes them?

Carlos

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.

Claire Brooks

Regression predicts a quantity, while classification predicts a category.

Carlos

Exactly. Predicting a salary or home price is regression. Identifying an email as spam or not spam is classification.

Claire Brooks

What happens when there are no labels?

Carlos

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.

Claire Brooks

And reinforcement learning uses rewards and penalties?

Carlos

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.

Claire Brooks

So these approaches differ mainly in the feedback available during learning.

Carlos

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.

Carlos

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.

Claire Brooks

The lecture separates prediction from inference. How are they different?

Carlos

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.

Claire Brooks

Inference asks what the model tells us about the relationship between variables.

Carlos

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.

Claire Brooks

Can a strong prediction prove that a feature causes the target to change?

Carlos

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.

Claire Brooks

What assumptions should make us cautious about a linear model?

Carlos

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.

Carlos

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.

Claire Brooks

What do root mean squared error and mean absolute error measure?

Carlos

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.

Claire Brooks

Could a nearly perfect training score be a warning?

Carlos

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.

Claire Brooks

What are the main advantages of linear regression?

Carlos

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.

Carlos

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.

Claire Brooks

What steps does the algorithm follow?

Carlos

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.

Claire Brooks

What exactly is k?

Carlos

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.

Claire Brooks

Why not always use the closest single neighbor?

Carlos

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.

Claire Brooks

Why are odd values of k often preferred?

Carlos

With two classes, an odd k reduces the chance of a tie. More generally, the tie-breaking rule should be defined explicitly.

Claire Brooks

The slides say KNN has no model-training stage. Does that make it fast?

Carlos

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.

Claire Brooks

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.

Carlos

Precisely. Feature scaling, the distance metric, the value of k, and validation all matter.

Carlos

Despite its name, logistic regression is primarily a classification algorithm. It estimates the probability that an observation belongs to a class.

Claire Brooks

The slide uses time on a webpage to predict whether a visitor will buy a product.

Carlos

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.

Claire Brooks

How is the model trained?

Carlos

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.

Claire Brooks

Why might probabilities be more useful than receiving only a class label?

Carlos

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.

Claire Brooks

What are logistic regression's strengths and limitations?

Carlos

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.

Claire Brooks

How should I choose among linear regression, KNN, and logistic regression?

Carlos

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.

Carlos

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.

Claire Brooks

What questions should we ask during EDA?

Carlos

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?

Claire Brooks

The data-quality slide shows bad data going into a perfect model and still producing a bad result.

Carlos

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.

Claire Brooks

How does visualization support EDA?

Carlos

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.

Claire Brooks

A graph is not automatically truthful, though.

Carlos

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.

Carlos

Let us close with five review questions. Maya, question one: what is the difference between an ML algorithm and an ML model?

Claire Brooks

The algorithm is the general learning procedure. The model is the learned result produced when that algorithm is applied to specific training data.

Carlos

Question two: how do supervised, unsupervised, and reinforcement learning differ?

Claire Brooks

Supervised learning uses labeled examples, unsupervised learning searches for structure without labels, and reinforcement learning improves through actions, rewards, and penalties.

Carlos

Question three: when is linear regression appropriate?

Claire Brooks

When the target is numerical and the relationship can be modeled reasonably with a linear form, while its assumptions and residuals are checked.

Carlos

Question four: what role does k play in KNN?

Claire Brooks

It determines how many nearby training points participate in the prediction. Small and large values create different overfitting and underfitting risks.

Carlos

Final question: why should EDA occur before modeling?

Claire Brooks

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.

Carlos

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.

Claire Brooks

And a more complicated model is not automatically a better one.

Carlos

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.