Machine Learning Introduction


Machine Learning Introduction

Corey
Welcome to CS229 Machine Learning. This course has been taught at Stanford for many years, and it has helped generations of students become experts who went on to build products, services, and startups. Today, we are going to cover the course logistics and then build an introductory picture of what machine learning is and what we will study.

Maria
And the timing is important. We constantly hear about artificial intelligence, machine learning, and deep learning in the news. A useful comparison is that AI may be like the new electricity: electricity transformed nearly every major industry about a century ago, and machine learning is now creating similarly broad opportunities.

Corey
Those opportunities extend far beyond traditional technology companies. Manufacturing, healthcare, logistics, law, history, literature, education, robotics, and transportation are all areas where people are applying learning algorithms. The amount of valuable machine learning work has been increasing rapidly, partly because we have much more data and much better tools.

Maria
So the course is not only preparation for a job at a large technology company. The goal is also to give students the ability to identify meaningful problems in other industries, build their own projects or startups, improve existing services, and potentially transform areas such as healthcare or transportation.

Corey
Exactly. Over the next ten weeks, the hope is that students will become well equipped to build meaningful machine learning applications. That includes applying machine learning in academic fields such as mechanical engineering, electrical engineering, English, law, and education, as well as using it in industry after graduation.

Maria
The course also supports students interested in research. By the end, they should be better prepared to read and understand machine learning research papers and to begin contributing to the state of the art.

Corey
Before we go further, there is a practical issue: the class is very large. The room seats only a few hundred students, while enrollment is close to eight hundred. Lectures and discussion sections are recorded and broadcast through SCPD, and videos are generally made available online the same day.

Maria
The teaching team includes a class coordinator, co-head teaching assistants, and a larger group of TAs. Their backgrounds span areas such as computer vision, natural language processing, computational biology, and robotics, so students can receive advice not only about machine learning but also about particular application areas.

Corey
The main lectures are held on Mondays and Wednesdays, while discussion sections take place on Fridays. Discussion attendance is optional, and material will not secretly appear on the midterm only because it was presented there.

Maria
Still, those sections can be useful. During the first few weeks, they review prerequisite material in linear algebra, probability and statistics, and Python with NumPy. Later in the quarter, they may cover advanced optional topics such as convex optimization, hidden Markov models, and time series.

Corey
The course assumes basic computer science knowledge, including concepts such as Big O notation, queues, stacks, and binary trees. Students should also know basic probability: random variables, expected values, and variance.

Maria
They should also be familiar with basic linear algebra: what vectors and matrices are, how to multiply matrices and vectors, and, ideally, what an eigenvector is. If some of that material feels rusty, the Friday review sessions are designed to help.

Corey
A major logistical change is the programming language. Earlier versions of the course used MATLAB or Octave, but this version is shifting the assignments toward Python and NumPy. Octave remains convenient for quickly prototyping simple experiments, but the machine learning world is increasingly moving toward Python and, for production systems, languages such as Java or C++.

Maria
The course includes four planned homework assignments, a project proposal a few weeks into the quarter, and a final project at the end. The exact dates are listed on the course website. Another change is that the midterm is planned as a take-home midterm rather than a timed in-class exam.

Corey
Students are encouraged to form study groups. Technical courses with substantial mathematics can become easier when classmates ask one another questions and work through ideas together.

Maria
But collaboration has a boundary. It is acceptable to discuss homework problems with friends, yet after that discussion, each student must write the solution independently, without consulting jointly created notes. The submitted work should reflect that student's own understanding and work, consistent with Stanford's Honor Code and the written course policy.

Corey
That standard matters because CS229 is recognized by employers. The course has even been associated with job advertisements promising an interview to students who completed it. Maintaining the meaning of that accomplishment requires students to do their own work within the permitted collaboration rules.

Maria
The class project is another central part of the course. Students work in a small group to apply machine learning to an application that interests them, with the aim of building a meaningful system rather than only completing abstract exercises.

Corey
Project groups can contain up to three people, although working alone is allowed. Groups of four may sometimes be approved for projects of exceptional scope, but larger groups are held to a stricter grading standard because they have more people available to do the work.

Maria
Past projects have applied machine learning to areas including cancer diagnosis, art, engineering, literature, and earthquake-related problems. Looking at previous projects on the course website can help students understand what is possible and find inspiration for their own proposal.

Corey
For communication, Piazza is the main online discussion forum. Students are encouraged to ask technical and logistical questions there and to help answer questions from classmates, because explaining an idea to someone else can improve your own learning too.

Maria
Private or personal questions can instead be sent to the course email address. Gradescope is used for online grading, and instructions for using it are provided later. Lectures and discussion sections are recorded, but office hours are the main exception and are not recorded or broadcast.

Corey
It is also useful to distinguish this course from related offerings. CS229 is the most mathematical of the three courses discussed here and covers a broad range of machine learning algorithms. CS229a is more applied, less mathematical, and taught in a flipped format involving videos, programming exercises, and weekly discussions.

Maria
CS230 focuses more narrowly on deep learning. It is also more applied and less mathematical than CS229, but concentrates on a smaller and particularly challenging set of algorithms. The courses have relatively little overlap, although some students take more than one to gain different perspectives.

Corey
That broader perspective can be valuable. A strong machine learning background may include machine learning itself, deep learning, probability and statistics, some convex optimization, reinforcement learning, and planning. CS229 forms a core part of that larger set of subjects.

Maria
Now let's define machine learning. Arthur Samuel described it as a field that gives computers the ability to learn without being explicitly programmed. His checkers program learned through self-play and eventually became better at checkers than Samuel himself.

Corey
That was remarkable because the program did something its programmer had not directly specified: it learned which board patterns were associated with winning or losing. Today, computers can exceed human performance on many narrow tasks, such as speech recognition in a particular setting or playing games like Go, but these successes remain task-specific.

Maria
Tom Mitchell gives a more formal definition. A program learns from experience E with respect to a task T and a performance measure P if its performance on T, as measured by P, improves with experience E.

Corey
For the checkers example, experience E is the program playing many games against itself. Task T is playing checkers, and performance measure P could be the probability that the program wins its next game. Learning occurs when performance on that task improves as the program gains experience.

Maria
The first major category is supervised learning. In supervised learning, the algorithm receives inputs X together with labels Y and learns a mapping from X to Y. Once trained, it uses that mapping to predict the appropriate Y for a new input X.

Corey
Consider housing prices. The input X might be the size of a house in square feet, and the label Y is its price. Given a collection of examples, we might fit a straight line and use it to estimate the price of a new house, or we might use a quadratic curve if that better represents the data.

Maria
Predicting a continuous value such as a housing price is called regression. The output is treated as continuous, even though a real price would normally be rounded to dollars and cents.

Corey
Classification is different because the output takes one of a discrete set of values. For example, a medical system might use tumor information to predict whether a breast tumor is benign or malignant, represented as zero or one. If there are several possible cancer types, that is still classification because the output belongs to a finite set.

Maria
The input does not have to be a single number. In the tumor example, features might include tumor size and the patient's age. In a real medical application, there could be many more features, such as clump thickness, uniformity of cell size or shape, and how strongly cells adhere to one another.

Corey
When there are two features, we can plot the examples on a two-dimensional graph and learn a boundary that separates likely benign tumors from likely malignant tumors. Logistic regression is one algorithm that can learn such a boundary.

Maria
With many features, the data becomes difficult or impossible to visualize directly. The course will study algorithms that work with high-dimensional inputs, including support vector machines. Using a technique called kernels, support vector machines can work as though they were using an infinite number of features without literally storing an infinite-length vector.

Corey
A supervised learning example is autonomous driving. During training, the system observes an image from a camera and records the steering direction chosen by a human driver. The image is X, the driver's steering choice is Y, and the learning algorithm trains a neural network to predict steering from the image.

Maria
After training, the human can remove their hands from the wheel, and the system can use the camera image, the trained network, and a motor to choose and execute a steering direction. The historical demonstration used separate models for different road situations and an additional algorithm to decide which model was appropriate.

Corey
The next major idea is machine learning strategy, also described in the course as learning theory in some materials. Knowing an algorithm is not enough, because the same algorithm can produce very different results depending on how a team applies it.

Maria
When a system is not working, practitioners must decide whether to collect more data, collect a different kind of data, use another algorithm, train for longer, obtain faster GPUs, or change the model architecture. The course aims to make those decisions more systematic instead of treating them as unexplained trial and error.

Corey
A useful analogy is software optimization. An inexperienced engineer might rewrite code immediately, perhaps even in assembly, while a more experienced engineer first uses a profiler to locate the bottleneck. Machine learning strategy similarly asks you to diagnose what is limiting performance before spending months changing the wrong part of the system.

Maria
This matters because learning algorithms almost never work perfectly the first time. The course will provide engineering principles for debugging and improving them efficiently, so students can determine what to do next and avoid wasting long periods on an unpromising direction.

Corey
Deep learning is another major subject. It is a rapidly advancing subset of machine learning based on neural networks, and the course will cover the basics of training neural networks. CS229 still goes beyond deep learning by covering a much broader range of useful machine learning tools.

Maria
The fourth major subject is unsupervised learning. Here, the algorithm receives inputs X but no labels Y and is asked to discover interesting structure in the data.

Corey
If unlabeled data forms two visible groups, a clustering algorithm such as K-means can discover those clusters. The same general idea can group news articles about the same event, organize genetic data, identify communities in a social network, segment customers for marketing, or group related machines and workflows in a computing cluster.

Maria
Unsupervised learning is broader than clustering. One example is the cocktail party problem: place several microphones in a room where multiple people are speaking at once, record overlapping voices, and ask an algorithm to separate the individual speakers without labeled examples. Independent Components Analysis, or ICA, is used for this problem in one of the course exercises.

Corey
Another example uses the large amount of unlabeled text on the Internet. Algorithms can learn relationships and analogies from text, such as the relationship between man and woman resembling the relationship between king and queen, or Tokyo and Japan resembling Washington, D.C. and the United States.

Maria
Much of the recent economic value from machine learning has come through supervised learning, but unsupervised learning remains important in applications and is an active area of research.

Corey
The fifth major subject is reinforcement learning. Instead of receiving the correct output for every input, an agent takes actions and receives feedback in the form of rewards or penalties.

Maria
Imagine trying to teach a program to fly an autonomous helicopter. No one can simply provide the optimal movement of the control sticks for every possible situation. Instead, the helicopter tries actions, receives positive feedback when it flies well and negative feedback when it performs badly, and learns a policy that produces more desirable behavior.

Corey
That is similar to training a dog: reward good behavior and discourage bad behavior. The same principle can help a robot dog learn to climb over obstacles, and it has been used successfully for game-playing, including Atari games and Go.

Maria
Reinforcement learning is also making progress in robotics, logistics, and other systems where an agent must make sequences of decisions. So the five broad areas for the course are supervised learning, machine learning strategy, deep learning, unsupervised learning, and reinforcement learning.

Corey
The larger purpose behind all five is not simply to chase impressive technical results. Machine learning gives people an opportunity to address meaningful problems, such as improving healthcare, providing personalized tutoring, or helping democracy function better.

Maria
That opportunity comes with responsibility. If students learn to use these tools effectively and ethically, they can help other people and improve important parts of the world, whether they work at a major technology company, in another industry, in academia, or on their own project.

Corey
So as the course begins, students should meet classmates, form study groups, look for project partners, review the prerequisites, and use Piazza actively. The technical material will be challenging, but the combination of lectures, reviews, homeworks, projects, and teaching-team support is designed to build both theoretical understanding and practical ability.

Maria
And that brings us back to the central promise of CS229: by the end of the quarter, students should understand the major machine learning ideas, know how to apply a range of algorithms, be more systematic in developing learning systems, and be prepared either to build meaningful applications or begin engaging seriously with research.

Ask anything
We've read this whole study set, so questions about it get the best answers.