Skip to content

Instantly share code, notes, and snippets.

@darioappsilon
Created December 22, 2020 09:25
Show Gist options
  • Save darioappsilon/210f00c5ec06f53265879d64eb740c3f to your computer and use it in GitHub Desktop.
Save darioappsilon/210f00c5ec06f53265879d64eb740c3f to your computer and use it in GitHub Desktop.
004_linear_regression
library(caTools)
set.seed(42)
# Train/Test split in 70:30 ratio
sample_split <- sample.split(Y = df$Weight, SplitRatio = 0.7)
train_set <- subset(x = df, sample_split == TRUE)
test_set <- subset(x = df, sample_split == FALSE)
# Fit the model and obtain summary
model <- lm(Weight ~ ., data = train_set)
summary(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment