學習筆記
- Statistical Learning 統計學習
2.Statistical Learning
3.Linear
4.Classification
5.Resampling Method
6.Linear Model Selection and Regularization
7.Moving Beyond Linearity
8.Tree-Based Methods
9.Support Vector Machines
10.Unsupervised Learning
1.Basic Conmmands
## [1] 4
## [1] "x" "y"
#創建矩陣
x <- matrix(c(1,2,3,4),nrow = 2,ncol = 2)
y <- matrix(c(1,2,3,4),nrow = 2,ncol = 2,byrow = TRUE)## [1] 0.9957734
## [1] 0.9957734
2.Graphics
## [1] -3.14159265 -3.01336438 -2.88513611 -2.75690784 -2.62867957
## [6] -2.50045130 -2.37222302 -2.24399475 -2.11576648 -1.98753821
## [11] -1.85930994 -1.73108167 -1.60285339 -1.47462512 -1.34639685
## [16] -1.21816858 -1.08994031 -0.96171204 -0.83348377 -0.70525549
## [21] -0.57702722 -0.44879895 -0.32057068 -0.19234241 -0.06411414
## [26] 0.06411414 0.19234241 0.32057068 0.44879895 0.57702722
## [31] 0.70525549 0.83348377 0.96171204 1.08994031 1.21816858
## [36] 1.34639685 1.47462512 1.60285339 1.73108167 1.85930994
## [41] 1.98753821 2.11576648 2.24399475 2.37222302 2.50045130
## [46] 2.62867957 2.75690784 2.88513611 3.01336438 3.14159265
y = x
#outer:外積,f的維度10*10
f <- outer(x,y,function(x,y)cos(y)/(1+x^2))
#contour plot:等高線圖
contour(x,y,f)## [,1] [,2] [,3] [,4]
## [1,] 1 5 9 13
## [2,] 2 6 10 14
## [3,] 3 7 11 15
## [4,] 4 8 12 16
## [,1] [,2] [,3] [,4]
## [1,] 1 5 9 13
## [2,] 2 6 10 14
## [3,] 3 7 11 15
## [,1] [,2] [,3] [,4]
## [1,] 3 7 11 15
## [2,] 4 8 12 16
library(ISLR)
#資料檔路徑
Auto_path <- "C:/Users/User/Desktop/portfolio/DataSet/Auto.data"
Auto <- read.table(Auto_path,header = T)
fix(Auto)#額外跳出資料視窗
View(Auto)
#Auto <- read.csv(Auto_path,header = T)
names(Auto)## [1] "mpg" "cylinders" "displacement" "horsepower"
## [5] "weight" "acceleration" "year" "origin"
## [9] "name"
## [1] 397 9
## [1] "mpg" "cylinders" "displacement" "horsepower"
## [5] "weight" "acceleration" "year" "origin"
## [9] "name"
###Additional Graphical and Numerical Summaries
## cylinders
## 3 4 5 6 8
## 4 203 3 84 103
## integer(0)
## mpg cylinders displacement horsepower
## Min. : 9.00 Min. :3.000 Min. : 68.0 150.0 : 22
## 1st Qu.:17.50 1st Qu.:4.000 1st Qu.:104.0 90.00 : 20
## Median :23.00 Median :4.000 Median :146.0 88.00 : 19
## Mean :23.52 Mean :5.458 Mean :193.5 110.0 : 18
## 3rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:262.0 100.0 : 17
## Max. :46.60 Max. :8.000 Max. :455.0 75.00 : 14
## (Other):287
## weight acceleration year origin
## Min. :1613 Min. : 8.00 Min. :70.00 Min. :1.000
## 1st Qu.:2223 1st Qu.:13.80 1st Qu.:73.00 1st Qu.:1.000
## Median :2800 Median :15.50 Median :76.00 Median :1.000
## Mean :2970 Mean :15.56 Mean :75.99 Mean :1.574
## 3rd Qu.:3609 3rd Qu.:17.10 3rd Qu.:79.00 3rd Qu.:2.000
## Max. :5140 Max. :24.80 Max. :82.00 Max. :3.000
##
## name
## ford pinto : 6
## amc matador : 5
## ford maverick : 5
## toyota corolla: 5
## amc gremlin : 4
## amc hornet : 4
## (Other) :368
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 9.00 17.50 23.00 23.52 29.00 46.60