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

Refer to: What is linear regression? A quick cover with a tutorial

Not completed yet.

III. Linear regression with R

Refer to: A quick introduction to machine learning in R with caret

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.

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.