# MachineLearning: Getting started 1/3, python, r ver. 4

Last Updated on November 18, 2021 by shibatau

I’m rewriting an old post now.

Getting started 1/3

Getting started 2/3

Getting started 3/3

## I. What do we learn?

We will learn Linear Regression using Python and R. It should make it clear for us to understand the difference between Machine Learning and traditional Statistics.

## II. Linear regression with Python

Not completed yet.

## III. Linear regression with R

Click on Run

   library(ggplot2) ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_point()     

Training the data.

   library(ggplot2) ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_point() # build model using train() library(caret) model.mtcars_lm <- train(mpg ~ wt ,data = mtcars ,method = "lm" ) # Retrieve coefficients for - slope and - intercept coef.icept <- coef(model.mtcars_lm$finalModel)[1] coef.slope <- coef(model.mtcars_lm$finalModel)[2] # Plot scatterplot and regression line using ggplot() ggplot(data = mtcars, aes(x = wt, y = mpg)) + geom_point() + geom_abline(slope = coef.slope, intercept = coef.icept, color = "red")     

Creating a linear regression line without carot using ggplot2.

   library(ggplot2) ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point(shape=1) + geom_smooth(method = lm)     

データの分布を直線で表現するのは、統計学では線形回帰分析と呼ばれます。

Linear Regression for Machine Learning

## IV. Machine Learning and Statistics

Refer to: Machine Learning vs. Statistics

Not completed yet.