2026-02-07

Introduction

  • Linear Regression can be seen in many forms of topics
  • The most popular place where Linear Regression is seen is in Computer Science. I though this was the perfect topic to explore as Machine Learnining is a huge part of technology these days and I am a computer science student.
    • It has been seen in machine learning as it is an algorithm that can have the machine lean from datasets and predict the behavior based off of the data points.
    • Examples:
      1. Prediction of student test scores based off of study hours and methods
      2. Checking the error between predicted and actual score
      (From GeeksforGeeks ML and linear regression website)

Math Equation for predicting score

So what I looked into was how we can come up with a simple equation when it comes to predicting a score.

From Videos:

  • A Basic equation for finding a test score is:

    \(\text{Test Score} = \beta_0 + \beta_1 \cdot \text{Study Hours} + \varepsilon, \; \varepsilon \sim \mathcal{N}(0, 8^2)\)

Where:

\(\beta_0 = \text{starting score}\)


\(\beta_1 = \text{the number the score increases per the hour studied}\)

  • A Specific equation for finding a test score if the score increase would be 5 points for every hour:

\(\text{if (}\beta_1 = \text{5), then}\)

\(\text{Test Score} = \beta_0 + 5 \cdot \text{Study Hours} + \varepsilon \;\)

Plotly Version Linear Regression with Predicting Test Scores

  • For predicting student score using Linear Regression

Code for the Plotly Version Linear Regression with Predicting Test Scores

  • This is the code that produce the plot from the previous slide:
#From Notes:
fig <- plot_ly(x=x, y=y, type="scatter", mode="markers", name="Test Scores",
        width=800, height=430) %>%add_lines(x = x, y = fitted(mod), name="fitted") %>%
        layout(xaxis = xax, yaxis = yax) %>% layout(margin=list(l=80,r=50,b=40,
            t=40))

ggplot version of Linear Regression with Predicting Test Scores

Math Equation for checking if the predicted score was accurate or not

From GeeksforGeeks website and videos:

\(\text{Error} = b0 - \hat{b0}\;\)

Where:

\(\text{b0} = \text{actual score}\)


\(\hat{b0} = \text{score that was predicted}\)

  • The smaller the error, the more accurate the prediction was

ggplot version of Linear Regression checking if the predicted score was accurate or not

References

-These are the websites that helped me with the code for the math equations and plots: