1. 程式人生 > >機器學習(Machine Learning and Data Mining)CS 5751——Lab1作業記錄

機器學習(Machine Learning and Data Mining)CS 5751——Lab1作業記錄

Activity3

繪製散點圖矩陣,顯示屬性之間的相關性: mpg,hp,disp,drat,wt,qsec。 使用散點圖,評論哪些屬性對具有最高的相關性。

plot(mtcars$wt, mtcars$mpg,  main="WT vs. MPG", xlab="Weight (1000 lbs)",  ylab="Miles/(US) gallon ", pch=19)

在這裡插入圖片描述

cor(mtcars$wt, mtcars$mpg)

Another method to do Activity3

pairs(~mpg+disp+drat+wt+qsec,data=mtcars,main="Activity3")

在這裡插入圖片描述

mydata<-mtcars[,c(1,3,4,5,6,7)]
cor(mydata)

在這裡插入圖片描述 (a) From picture WT vs. MPG will be most highest correlation

(b) From the correlation matrix WT vs. MPG will be most highest correlation

Activity4

(3)使用R繪製F(x,y)的圖表您的繪圖必須具有標識所繪製函式的標題。 軸必須正確標記。 您可以使用R的基本圖形,也可以使用ggplot。

x <- seq(-100, 100, 3)
y <- x
f <- function(x, y) { r <- (x^2+y-11)^2+(x+y^2-7)^2}
z <- outer(x, y, f)
persp(x, y, z, theta = 30, phi = 30, main = "plot of f(x,y)",col = "lightblue",ticktype="detailed",
nticks=5)

在這裡插入圖片描述