Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Training Sets, Test Sets, R, and ggplot
Rating: 4.7 out of 5(783 ratings)
20,277 students

Training Sets, Test Sets, R, and ggplot

How to evaluate regression model performance in R
Created byCharles Redmond
Last updated 6/2015
English

What you'll learn

  • randomly divide a data set into a training set and a test set
  • calculate the test MSE (mean squared error)
  • calculate quickly the MSE for a number of models
  • visualize the variability of the MSE with ggplot
  • row-slice data frames
  • use R's predict function
  • write for loops in R
  • write functions of two variables in R
  • combine functions and for loops
  • add titles and labels to plots in ggplot

Course content

2 sections15 lectures1h 30m total length
  • Introduction1:28

    In this video, I introduce the course.

  • Row-slicing Data Frames8:01

    After this lecture, you will be able to extract specific rows from a data frame. You will also be able to sample from a given set of integers. Putting all of this together, you will be able to randomly divide a data frame into two distinct data frames, each of the same size.

  • Plotting the Training and Test Sets7:37

    In this lecture, I generate plots of both the training set and the test set. I also show you how to add a title to your plots in ggplot.

  • Plotting the Least-Squares Line9:43

    After viewing this lecture, you will be able to use R's predict function and ggplot to obtain a plot of the least-squares line. You will also begin thinking about applying the least-squares line, generated from the training data, to the test data.

  • Calculating the Test MSE5:58

    After viewing this video, you will be able to use R's predict function to calculate the test mean squared error.

  • Generating a Quadratic Model6:59

    After viewing this video, you will be able to use R's predict function to plot the quadratic polynomial that fits the training data set the best. We will have to do this by writing our own function and using the stat_function in ggplot.

  • Calculating the Test MSE for the Quadratic Model2:42
    After viewing this video, you will be able to use R's predict function to calculate the test MSE

    for the Quadratic Model.

    .

Requirements

  • It is necessary that the students have the background one would get by viewing my two Udemy courses on linear and polynomial regression.
  • Students will need to have R and RStudio installed on their own computers.

Description

In this course, I show you how to evaluate the performance of a regression model using training sets and test sets. We will use R and ggplot as our tools. Along the way, we will learn how to row-slice data frames, use the predict function in R, and add titles and labels to our plots. We will also work on our programming skills by learning how to write for loops and functions of two variables.

Students should have the background in R, ggplot, and regression equivalent to what one would have after viewing my two Udemy courses on linear and polynomial regression. At a relaxed pace, it should take about two weeks to complete the course.

Who this course is for:

  • This course is for those looking to improve their R programming skills.
  • This course is for those with the background equivalent to what one would have after viewing my first two Udemy courses in linear and polynomial regression.