introduction to machine learning with R
data<-read.csv("data1.csv")
x<-data[,names(data)=='pelvic_incidence'] y<-data[,names(data)=='sacral_slope']
df<- data.frame(x,y)
linear <- lm(y ~ x, data = df)
summary(linear)
## ## Call: ## lm(formula = y ~ x, data = df) ## ## Residuals: ## Min 1Q Median 3Q Max ## -28.884 -4.480 0.838 4.781 34.470 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 4.55916 1.61742 2.819 0.00513 ** ## x 0.63466 0.02572 24.680 < 2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 7.792 on 308 degrees of freedom ## Multiple R-squared: 0.6642, Adjusted R-squared: 0.6631 ## F-statistic: 609.1 on 1 and 308 DF, p-value: < 2.2e-16
predicted= predict(linear, newdate =df$x)
plot(x,y,pch = 16, cex = 1.3,col=rainbow(5)) abline(linear,lw=3)
