CS Comics

Linear Regression & Gradient Descent, Page 9

by cscomics_etvvcs on September 28, 2018 at 8:32 pm
Posted In: Uncategorized

In fact, there’s a faster way to jump to the lowest point of the surface in one step, using something called a Normal Equation.  This approach is described very clearly in Lesson 4 of Andrew Ng’s Coursera course on machine learning.  For the problem posed here, first, stack the horizontal positions of the five people, in meters, next to a column of five ones, into something called a matrix:

[ 1 1 ]
[ 1 2 ]
[ 1 3 ]
[ 1 4 ]
[ 1 5 ]

Second, rotate this matrix sideways into its transpose matrix:

[ 1 1 1 1 1 ]
[ 1 2 3 4 5 ]

Third, multiply this transpose matrix by the original matrix using an operation called matrix multiplication:

             [ 1 1 ]
             [ 1 2 ]
[ 1 1 1 1 1 ][ 1 3 ] = [  5 15 ]
[ 1 2 3 4 5 ][ 1 4 ]   [ 15 55 ]
             [ 1 5 ]

Fourth, calculate the matrix inverse of the resulting matrix:

[  5 15 ]^-1   [  1.1  -0.3 ]
[       ]    = [            ]
[ 15 55 ]      [ -0.3   0.1 ]

Fifth, multiply the resulting matrix again by the transpose matrix above:

[  1.1  -0.3 ][ 1 1 1 1 1 ]   [  0.8  0.5     0.2 -0.1 -0.4 ]
[            ][           ] = [                             ]
[ -0.3   0.1 ][ 1 2 3 4 5 ]   [ -0.2 -0.1 -0.5511  0.1  0.2 ]

Sixth, stack the height each person climbed to, in meters, into another matrix called a column vector:

[ 3 ]
[ 1 ]
[ 9 ]
[ 4 ]
[ 6 ]

Last, multiply last matrix we just calculated, by this column vector:

                               [ 3 ]
[  0.8  0.5     0.2 -0.1 -0.4 ][ 1 ]   [ 1.9 ]
[                             ][ 9 ] = [     ]
[ -0.2 -0.1 -0.5511  0.1  0.2 ][ 4 ]   [ 0.9 ]
                               [ 6 ]

These last two numbers give us the slope (0.9) and base height (1.9 meters) of the pole that would make the pole come as close to all five people as possible.

In terms of machine learning, we would say that the line that best fits the points (1, 3), (2, 1), (3, 9), (4, 4), and (5, 6), is the line that is the graph of the equation y = (0.9)x + 1.9.

Linear Regression & Gradient Descent, Page 8

by cscomics_etvvcs on September 28, 2018 at 8:30 pm
Posted In: Uncategorized

Linear Regression & Gradient Descent, Page 7

by cscomics_etvvcs on September 28, 2018 at 8:28 pm
Posted In: Uncategorized

Linear Regression & Gradient Descent, Page 6

by cscomics_etvvcs on September 28, 2018 at 8:22 pm
Posted In: Uncategorized

Linear Regression & Gradient Descent, Page 5

by cscomics_etvvcs on September 28, 2018 at 8:13 pm
Posted In: Uncategorized

  • Page 4 of 18
  • « First
  • «
  • 2
  • 3
  • 4
  • 5
  • 6
  • »
  • Last »

My TED-Ed Video Lesson: > 3.5 Million Views

  • #11 trending video on YouTube shortly after release
  • Featured by BBC News Brasil (in Portuguese and Spanish)
  • Featured by Quartz, Boing Boing, Digital Trends, LifeHacker, IMDB, and Reddit
  • Teaches computer science topic: sorting algorithms

University of Texas Homepage Highlights My Teaching

  • I was the "homepage hero" of the Computer Science Department
  • UT-Austin Faculty Innovation Center features my teaching

University of Texas Features My Comics on Leading Women in Mathematics

  • One Step Deeper #2: Katherine Johnson
  • One Step Deeper #1: Ada Lovelace

Chief Meteorologist Shares My Weather Comics

  • Ridges & Troughs with Bad Puns [More Info]
  • Compressional Warming [More Info]
  • Why Is It Hot Before a Cold Front? [More Info]
  • What Meteorologists Do [More Info]
  • How Clouds Make Snow [More Info]

Learn to Physically Simulate a Fluid

  • From first principles and C++, using only free, widely available software, create and visualize a physics-based simulation of a fluid

Learn to Code by Character Animation

  • I modified a Blender plug-in to enable writing Python code that directs 3D animated characters to dance, throw a basketball, and climb.

ACM Inroads Back Page Features My Comic

  • Learn how computers store letters in their memory
  • Learn about abstraction

Math Comics

  • What Is A Cauchy Sequence?

Weather Comic: How High and Low Pressure Centers Form

  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Page 5
  • Page 6
  • Page 7
  • Page 8
  • Page 9
  • Many more pages in progress...!

Comics on Computer Programming Concepts

  • Programs are recipes telling computers how to "cook" data.
  • Programs have ingredients & instructions.
  • Ingredients in a program are like boxes.
  • Each box has a unique name.
  • Each box has a data type.
  • Boolean data type
  • Character data type
  • Integer data type
  • Float data type
  • Box = Variable
  • Value of a Variable
  • Primitive data types
  • Data structures
  • Arrays
  • Array of integers
  • Array of characters
  • Strings
  • Declaring a variable
  • Assigning a value to a variable
  • Assigning a new value to a variable
  • Ingredients of a program are variables.  What are instructions?
  • An assignment is one kind of instruction.
  • A print statement is another kind of instruction.
  • A simple program: Just a print statement
  • Another simple program: An assignment and a print statement

Comics on How Computers Store Data

  • Computers Can Cook Data, but We Have to Write the Recipes
  • Computers Remember and Do Things Kind of Like Us
  • Computers Use Secret Codes Called Data Types to Store Data Using 0s and 1s
  • Boolean -- Yes and No
  • Boolean -- Housing the Truth
  • Houses of Character
  • Computers Use Blocks of Memory to Represent Larger Pieces of Data
  • Liar Paradox or a Joke for Computers

Comics on How Computers Run Programs

  • The Life of a Computer Program, Part 1: Fetching the Recipe
  • The Life of a Computer Program, Part 2: Virtual Memory
  • The Life of a Computer Program, Part 3: Program Segments
  • The Life of a Computer Program, Part 4: How Computers Store Programs
  • The Life of a Computer Program, Part 5: How a Computer Adds Two Numbers
  • The Life of a Computer Program, Part 6: How a Computer Runs a Program
  • How an Array of Integers Gets Stored in Memory
  • Computers Don't Know Anything, but They Compute Quickly

Comics on How to Computers Search Data

  • Linear Search, Part 1: A Simple Algorithm
  • Linear Search, Part 2: Program Walk-through and For Loop
  • Linear Search, Part 3: How the Program Works
  • Linear Search, Part 4: How to Understand a Program
  • Binary Search, Part 1: The Algorithm
  • Binary Search, Part 2: A Play & Poem
  • Binary Search, Part 3: How to Implement It
  • Binary Search, Part 4: How It Runs

Comics on How Computers Sort Numbers

  • Algorithms, Page 1
  • Algorithms, Page 2
  • Insertion Sort, Page 1
  • Insertion Sort, Page 2
  • Insertion Sort, Page 3
  • How to implement Insertion Sort
  • Quicksort, Page 1
  • Quicksort, Page 2
  • Quicksort, Page 3
  • Quicksort, Page 4
  • Quicksort, Page 5
  • How to implement Quicksort

Data Science / Machine Learning Comics

  • Linear Regression & Gradient Descent, Page 1
  • Linear Regression & Gradient Descent, Page 2
  • Linear Regression & Gradient Descent, Page 3
  • Linear Regression & Gradient Descent, Page 4
  • Linear Regression & Gradient Descent, Page 5
  • Linear Regression & Gradient Descent, Page 6
  • Linear Regression & Gradient Descent, Page 7
  • Linear Regression & Gradient Descent, Page 8
  • Linear Regression & Gradient Descent, Page 9

Physics Comics

  • A Rock Goes 0 to 60 in 3 Seconds

Older Comics

  • A Comic for All of Us, Especially Girls and Women, to Learn and Enjoy Computer Science

©2017-2023 CS Comics | Powered by WordPress with ComicPress | Subscribe: RSS | Back to Top ↑