Modeling in R is extremely powerful for business analytics...
But many beginners get stuck.
Here's my simple 3-step process to make a linear regression model in R. π§΅
#datascience #business #R #rstats
But many beginners get stuck.
Here's my simple 3-step process to make a linear regression model in R. π§΅
#datascience #business #R #rstats
To give some background, these simple 5 lines of code create a basic business solution...
... I'm modeling my ...
Target = bicycle product prices (regression task)
... I'm modeling my ...
Target = bicycle product prices (regression task)
As a function of my predictors:
Predictors = product categories (mountain or road bikes) and bicycle frame material (aluminum or carbon fiber).
Predictors = product categories (mountain or road bikes) and bicycle frame material (aluminum or carbon fiber).
Here's how I make a linear regression model and make predictions using the Tidymodels system in R...
πStep 1: Make a model specification
Here I'm using linear_reg() to create a regression model.
I use set_engine() to specify "lm" for linear model.
Here I'm using linear_reg() to create a regression model.
I use set_engine() to specify "lm" for linear model.
πStep 2: Fit the model.
I'm using fit() to specify which columns in the data are the target (my product prices) and the predictors (product category and frame material)
Make sure to fit the model on a test data set (called in-sample).
I'm using fit() to specify which columns in the data are the target (my product prices) and the predictors (product category and frame material)
Make sure to fit the model on a test data set (called in-sample).
πStep 3: Make Predictions.
This step is super easy.
Take the fitted model from Step 2, and use the predict() function.
PRO TIP: Make sure that new_data is the unseen data (out-of-sample)
This step is super easy.
Take the fitted model from Step 2, and use the predict() function.
PRO TIP: Make sure that new_data is the unseen data (out-of-sample)
Step 4: Keep Learning
If you want to keep learning, I have a free 40-minute webinar that will help you learn...
... The 10 skills that helped me become a data scientist for business.
If you want to keep learning, I have a free 40-minute webinar that will help you learn...
... The 10 skills that helped me become a data scientist for business.
You will learn which tools I use for:
- Data Wrangling & Visualization
- Machine Learning
- Time Series
- Web Applications
Plus 6 more...
- Data Wrangling & Visualization
- Machine Learning
- Time Series
- Web Applications
Plus 6 more...
Here's a link to my free 40-Minute Masterclass on How to Become A 6-Figure Data Scientist With R.
Enjoy!
learn.business-science.io
Enjoy!
learn.business-science.io
Loading suggestions...