Attaching package: 'yardstick'
The following objects are masked from 'package:caret':
precision, recall, sensitivity, specificity
The following object is masked from 'package:readr':
spec
# THIS IS NOT A GREAT IDEA options(warn=-1)# I have this on, there is an expected warning ## "prediction from a rank-deficient fit may be misleading"## without this option on the output is very difficult to read
17.2caret Train glm Function
Train_Glm_Iteration<-function(data){TrainInd<-createDataPartition(data$bmxbmi, p =.7, list=FALSE)TRAIN<-data[TrainInd, ]gml_control<-trainControl( method ='cv', number =22, preProcOptions =c("zv","corr",'center','scale',"conditionalX"))gml.model<-train(as.formula(formula_1) , method='glm', data =TRAIN, trControl=gml_control, family ="gaussian")CoEff<-as_tibble(gml.model$finalModel$coefficients, rownames="feature")%>%rename(coeff =value)TEST<-data[-TrainInd,]estimate<-as_tibble(predict(gml.model, TEST,'raw'))%>%rename(estimate=value)TEST.scored<-cbind(TEST, estimate)RMSE<-TEST.scored%>%rmse(truth=bmxbmi , estimate)return(list(Training_Data =TRAIN, gml.model =gml.model, CoEff =CoEff, TEST.scored =TEST.scored, RMSE_TEST =RMSE))}
Compare Object
Function Call:
arsenal::comparedf(x = X1$Training_Data, y = X1$TEST.scored,
by = c("seqn"))
Shared: 9 non-by variables and 0 observations.
Not shared: 1 variables and 562 observations.
Differences found in 0/9 variables compared.
0 variables compared have non-identical attributes.
statistic value
1 Number of by-variables 1
2 Number of non-by variables in common 9
3 Number of variables compared 9
4 Number of variables in x but not y 0
5 Number of variables in y but not x 1
6 Number of variables compared with some values unequal 0
7 Number of variables compared with all values equal 9
8 Number of observations in common 0
9 Number of observations in x but not y 395
10 Number of observations in y but not x 167
11 Number of observations with some compared variables unequal 0
12 Number of observations with all compared variables equal 0
13 Number of values unequal 0
seqn riagendr ridageyr ridreth1
Min. :84511 Male : 0 Min. :22.0 MexicanAmerican : 0
1st Qu.:86172 Female:29 1st Qu.:35.0 Other Hispanic : 0
Median :88903 Median :47.0 Non-Hispanic White:29
Mean :88572 Mean :51.1 Non-Hispanic Black: 0
3rd Qu.:90745 3rd Qu.:64.0 Other : 0
Max. :93258 Max. :80.0
dmdeduc2 dmdmartl
Less than 9th grade : 2 Married :19
Grades 9-11th : 1 Widowed : 3
High school graduate/GED : 2 Divorced : 2
Some college or AA degrees:13 Separated : 0
College grad or above :11 Never married : 2
Living with partner: 3
indhhin2 bmxbmi diq010 lbxglu
$75,000-$99,999 :29 Min. :16.7 Diabetes : 3 Min. : 83.0
$0-$4,999 : 0 1st Qu.:25.3 No Diabetes:26 1st Qu.: 93.0
$5,000-$9,999 : 0 Median :28.9 Median :100.0
$10,000-$14,999 : 0 Mean :32.0 Mean :105.3
$15,000-$19,999 : 0 3rd Qu.:39.3 3rd Qu.:107.0
less than $20,000: 0 Max. :63.6 Max. :207.0
(Other) : 0
Compare Object
Function Call:
arsenal::comparedf(x = X3$Training_Data, y = X5$Training_Data)
Shared: 10 non-by variables and 22 observations.
Not shared: 0 variables and 626 observations.
Differences found in 10/10 variables compared.
0 variables compared have non-identical attributes.
Compare Object
Function Call:
arsenal::comparedf(x = t2, y = f2, by = "seqn")
Shared: 9 non-by variables and 0 observations.
Not shared: 0 variables and 1876 observations.
Differences found in 0/9 variables compared.
0 variables compared have non-identical attributes.
Compare Object
Function Call:
arsenal::comparedf(x = t5, y = f5, by = "seqn")
Shared: 9 non-by variables and 0 observations.
Not shared: 0 variables and 1876 observations.
Differences found in 0/9 variables compared.
0 variables compared have non-identical attributes.
Compare Object
Function Call:
arsenal::comparedf(x = t2, y = f5, by = "seqn")
Shared: 9 non-by variables and 938 observations.
Not shared: 0 variables and 15 observations.
Differences found in 0/9 variables compared.
0 variables compared have non-identical attributes.