rm(list=ls())
ls()
## character(0)
getwd()
## [1] "/Users/mac/bigdata"
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
data(iris)
library(caret)
## Loading required package: ggplot2
## Loading required package: lattice
idx<-createDataPartition(iris$Species, p=0.8)
table(iris[idx$Resample1, "Species"])
## 
##     setosa versicolor  virginica 
##         40         40         40
table(iris[-idx$Resample1, "Species"])
## 
##     setosa versicolor  virginica 
##         10         10         10
idx<-createDataPartition(iris$Species, p=0.8, list=FALSE)
train<-iris[idx,]
test<-iris[-idx,]
nrow(train)
## [1] 120
nrow(test)
## [1] 30
library(caret)
set.seed(2)
data("iris")
idx<-createDataPartition(iris$Species,p=0.6,list=FALSE)
train<-iris[idx,]
valid_test<-iris[-idx,]
idx2<-createDataPartition(valid_test$Species,p=0.5,list=FALSE)
valid<-valid_test[idx2,]
test<-valid_test[-idx2,]
nrow(train)/nrow(iris)
## [1] 0.6
nrow(valid)/nrow(iris)
## [1] 0.2
nrow(test)/nrow(iris)
## [1] 0.2
library(caret)
data(iris)
zs_iris<-preProcess(iris,method = c("center","scale"))
zs_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - centered (4)
##   - ignored (1)
##   - scaled (4)
zs_iris_p<-predict(zs_iris,iris)

library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
describe(zs_iris_p[,1:4])
##              vars   n mean sd median trimmed  mad   min  max range  skew
## Sepal.Length    1 150    0  1  -0.05   -0.04 1.25 -1.86 2.48  4.35  0.31
## Sepal.Width     2 150    0  1  -0.13   -0.03 1.02 -2.43 3.08  5.51  0.31
## Petal.Length    3 150    0  1   0.34    0.00 1.05 -1.56 1.78  3.34 -0.27
## Petal.Width     4 150    0  1   0.13   -0.02 1.36 -1.44 1.71  3.15 -0.10
##              kurtosis   se
## Sepal.Length    -0.61 0.08
## Sepal.Width      0.14 0.08
## Petal.Length    -1.42 0.08
## Petal.Width     -1.36 0.08
library(caret)
data(iris)
sca_iris<-preProcess(iris,method="range")
sca_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - ignored (1)
##   - re-scaling to [0, 1] (4)
sca_iris_p<-predict(sca_iris,iris)
head(sca_iris_p)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1   0.22222222   0.6250000   0.06779661  0.04166667  setosa
## 2   0.16666667   0.4166667   0.06779661  0.04166667  setosa
## 3   0.11111111   0.5000000   0.05084746  0.04166667  setosa
## 4   0.08333333   0.4583333   0.08474576  0.04166667  setosa
## 5   0.19444444   0.6666667   0.06779661  0.04166667  setosa
## 6   0.30555556   0.7916667   0.11864407  0.12500000  setosa
library(psych)
describe(sca_iris_p)
##              vars   n mean   sd median trimmed  mad min max range  skew
## Sepal.Length    1 150 0.43 0.23   0.42    0.42 0.29   0   1     1  0.31
## Sepal.Width     2 150 0.44 0.18   0.42    0.43 0.19   0   1     1  0.31
## Petal.Length    3 150 0.47 0.30   0.57    0.47 0.31   0   1     1 -0.27
## Petal.Width     4 150 0.46 0.32   0.50    0.45 0.43   0   1     1 -0.10
## Species*        5 150 2.00 0.82   2.00    2.00 1.48   1   3     2  0.00
##              kurtosis   se
## Sepal.Length    -0.61 0.02
## Sepal.Width      0.14 0.01
## Petal.Length    -1.42 0.02
## Petal.Width     -1.36 0.03
## Species*        -1.52 0.07
library(caret)
data(iris)
bc_iris=preProcess(iris,method="BoxCox")
bc_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - Box-Cox transformation (4)
##   - ignored (1)
## 
## Lambda estimates for Box-Cox transformation:
## -0.1, 0.3, 0.9, 0.6
bc_iris_t=predict(bc_iris,iris)
head(bc_iris_t)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1     1.629241    1.520660          1.4  -1.0321154  setosa
## 2     1.589235    1.301297          1.4  -1.0321154  setosa
## 3     1.547563    1.391905          1.3  -1.0321154  setosa
## 4     1.526056    1.347113          1.5  -1.0321154  setosa
## 5     1.609438    1.561856          1.4  -1.0321154  setosa
## 6     1.686399    1.680826          1.7  -0.7048667  setosa
par(mfrow=c(1,2))
plot(density(x=iris$Sepal.Width))
plot(density(x=bc_iris_t$Sepal.Width))

library(caret)
data(iris)
pca_iris<-preProcess(iris,method="pca")
pca_iris
## Created from 150 samples and 5 variables
## 
## Pre-processing:
##   - centered (4)
##   - ignored (1)
##   - principal component signal extraction (4)
##   - scaled (4)
## 
## PCA needed 2 components to capture 95 percent of the variance
pca_iris_p<-predict(pca_iris,iris)
head(pca_iris_p)
##   Species       PC1        PC2
## 1  setosa -2.257141 -0.4784238
## 2  setosa -2.074013  0.6718827
## 3  setosa -2.356335  0.3407664
## 4  setosa -2.291707  0.5953999
## 5  setosa -2.381863 -0.6446757
## 6  setosa -2.068701 -1.4842053
library(earth)
## Loading required package: Formula
## Loading required package: plotmo
## Loading required package: plotrix
## 
## Attaching package: 'plotrix'
## The following object is masked from 'package:psych':
## 
##     rescale
## Loading required package: TeachingDemos
data("etitanic")
library(dplyr)
glimpse(etitanic)
## Rows: 1,046
## Columns: 6
## $ pclass   <fct> 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1st, 1…
## $ survived <int> 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1…
## $ sex      <fct> female, male, female, male, female, male, female, male, femal…
## $ age      <dbl> 29.0000, 0.9167, 2.0000, 30.0000, 25.0000, 48.0000, 63.0000, …
## $ sibsp    <int> 0, 1, 1, 1, 1, 0, 1, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1…
## $ parch    <int> 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1…
dummies<-dummyVars(survived~.,data = etitanic)
dummies
## Dummy Variable Object
## 
## Formula: survived ~ .
## 6 variables, 2 factors
## Variables and levels will be separated by '.'
## A less than full rank encoding is used
head(predict(dummies,newdata = etitanic))
##   pclass.1st pclass.2nd pclass.3rd sex.female sex.male     age sibsp parch
## 1          1          0          0          1        0 29.0000     0     0
## 2          1          0          0          0        1  0.9167     1     2
## 3          1          0          0          1        0  2.0000     1     2
## 4          1          0          0          0        1 30.0000     1     2
## 5          1          0          0          1        0 25.0000     1     2
## 6          1          0          0          0        1 48.0000     0     0
data("airquality")
colSums(is.na(airquality))
##   Ozone Solar.R    Wind    Temp   Month     Day 
##      37       7       0       0       0       0
library(RANN)
head(airquality)
##   Ozone Solar.R Wind Temp Month Day
## 1    41     190  7.4   67     5   1
## 2    36     118  8.0   72     5   2
## 3    12     149 12.6   74     5   3
## 4    18     313 11.5   62     5   4
## 5    NA      NA 14.3   56     5   5
## 6    28      NA 14.9   66     5   6
knn_im<-preProcess(airquality[1:4],method = "knnImpute")
head(predict(knn_im,airquality))
##         Ozone     Solar.R       Wind       Temp Month Day
## 1 -0.03423409  0.04517615 -0.7259482 -1.1497140     5   1
## 2 -0.18580489 -0.75430487 -0.5556388 -0.6214670     5   2
## 3 -0.91334473 -0.41008388  0.7500660 -0.4101682     5   3
## 4 -0.73145977  1.41095624  0.4378323 -1.6779609     5   4
## 5 -0.69508278 -0.92308420  1.2326091 -2.3118573     5   5
## 6 -0.42831817 -0.28349938  1.4029185 -1.2553634     5   6
knn_im_p<-predict(knn_im,airquality)
colSums(is.na(knn_im_p))
##   Ozone Solar.R    Wind    Temp   Month     Day 
##       0       0       0       0       0       0
describe(knn_im_p)
##         vars   n  mean   sd median trimmed   mad   min   max range  skew
## Ozone      1 153 -0.04 0.92  -0.31   -0.16  0.72 -1.25  3.82  5.06  1.30
## Solar.R    2 153 -0.01 0.99   0.17    0.03  1.05 -1.99  1.64  3.63 -0.39
## Wind       3 153  0.00 1.00  -0.07   -0.02  0.97 -2.34  3.05  5.39  0.34
## Temp       4 153  0.00 1.00   0.12    0.04  0.94 -2.31  2.02  4.33 -0.37
## Month      5 153  6.99 1.42   7.00    6.99  1.48  5.00  9.00  4.00  0.00
## Day        6 153 15.80 8.86  16.00   15.80 11.86  1.00 31.00 30.00  0.00
##         kurtosis   se
## Ozone       1.62 0.07
## Solar.R    -0.99 0.08
## Wind        0.03 0.08
## Temp       -0.46 0.08
## Month      -1.32 0.11
## Day        -1.22 0.72
median_im<-preProcess(airquality[1:4],method = "medianImpute")
head(predict(median_im,airquality))
##   Ozone Solar.R Wind Temp Month Day
## 1  41.0     190  7.4   67     5   1
## 2  36.0     118  8.0   72     5   2
## 3  12.0     149 12.6   74     5   3
## 4  18.0     313 11.5   62     5   4
## 5  31.5     205 14.3   56     5   5
## 6  28.0     205 14.9   66     5   6
library(mlbench)
data("BostonHousing")
x=BostonHousing[,c("age","lstat","tax")]
y=BostonHousing$medv
featurePlot(x,
            y=BostonHousing$medv,
            plot="scatter",
            layout=c(3,1))

library(mlbench)
library(caret)
library(dplyr)
data("PimaIndiansDiabetes")
PimaIndiansDiabetes %>% count(diabetes)
##   diabetes   n
## 1      neg 500
## 2      pos 268
glimpse(PimaIndiansDiabetes)
## Rows: 768
## Columns: 9
## $ pregnant <dbl> 6, 1, 8, 1, 0, 5, 3, 10, 2, 8, 4, 10, 10, 1, 5, 7, 0, 7, 1, 1…
## $ glucose  <dbl> 148, 85, 183, 89, 137, 116, 78, 115, 197, 125, 110, 168, 139,…
## $ pressure <dbl> 72, 66, 64, 66, 40, 74, 50, 0, 70, 96, 92, 74, 80, 60, 72, 0,…
## $ triceps  <dbl> 35, 29, 0, 23, 35, 0, 32, 0, 45, 0, 0, 0, 0, 23, 19, 0, 47, 0…
## $ insulin  <dbl> 0, 0, 0, 94, 168, 0, 88, 0, 543, 0, 0, 0, 0, 846, 175, 0, 230…
## $ mass     <dbl> 33.6, 26.6, 23.3, 28.1, 43.1, 25.6, 31.0, 35.3, 30.5, 0.0, 37…
## $ pedigree <dbl> 0.627, 0.351, 0.672, 0.167, 2.288, 0.201, 0.248, 0.134, 0.158…
## $ age      <dbl> 50, 31, 32, 21, 33, 30, 26, 29, 53, 54, 30, 34, 57, 59, 51, 3…
## $ diabetes <fct> pos, neg, pos, neg, pos, neg, pos, neg, pos, pos, neg, pos, n…
control<-trainControl(method = "repeatedcv",number = 5,repeats = 3)
model<-train(diabetes~.,data=PimaIndiansDiabetes, method="rf",
             preProcess=c("center","scale"),trControl=control)
importance<-varImp(model,scale=FALSE)
print(importance)
## rf variable importance
## 
##          Overall
## glucose    89.13
## mass       57.97
## age        47.66
## pedigree   42.77
## pressure   30.95
## pregnant   28.55
## insulin    25.55
## triceps    24.00
plot(importance)

library(caret)
library(mlbench)
data(Sonar)
Sonar<-na.omit(Sonar)
set.seed(998)
inTraining<-createDataPartition(y=Sonar$Class, p=.75, list=FALSE)
training<-Sonar[inTraining]
testing<-Sonar[-inTraining,]

set.seed(825)

fitControl<-trainControl(method="repeatedcv",
                         number = 10,
                         repeats = 10,
                         classProbs = TRUE,
                         summaryFunction = twoClassSummary)



library(dplyr)
library(caret)
library(caTools)
df<-read.csv("diagnosis.csv")
glimpse(df)
## Rows: 569
## Columns: 32
## $ id                      <int> 842302, 842517, 84300903, 84348301, 84358402, …
## $ diagnosis               <chr> "M", "M", "M", "M", "M", "M", "M", "M", "M", "…
## $ radius_mean             <dbl> 17.990, 20.570, 19.690, 11.420, 20.290, 12.450…
## $ texture_mean            <dbl> 10.38, 17.77, 21.25, 20.38, 14.34, 15.70, 19.9…
## $ perimeter_mean          <dbl> 122.80, 132.90, 130.00, 77.58, 135.10, 82.57, …
## $ area_mean               <dbl> 1001.0, 1326.0, 1203.0, 386.1, 1297.0, 477.1, …
## $ smoothness_mean         <dbl> 0.11840, 0.08474, 0.10960, 0.14250, 0.10030, 0…
## $ compactness_mean        <dbl> 0.27760, 0.07864, 0.15990, 0.28390, 0.13280, 0…
## $ concavity_mean          <dbl> 0.30010, 0.08690, 0.19740, 0.24140, 0.19800, 0…
## $ concave.points_mean     <dbl> 0.14710, 0.07017, 0.12790, 0.10520, 0.10430, 0…
## $ symmetry_mean           <dbl> 0.2419, 0.1812, 0.2069, 0.2597, 0.1809, 0.2087…
## $ fractal_dimension_mean  <dbl> 0.07871, 0.05667, 0.05999, 0.09744, 0.05883, 0…
## $ radius_se               <dbl> 1.0950, 0.5435, 0.7456, 0.4956, 0.7572, 0.3345…
## $ texture_se              <dbl> 0.9053, 0.7339, 0.7869, 1.1560, 0.7813, 0.8902…
## $ perimeter_se            <dbl> 8.589, 3.398, 4.585, 3.445, 5.438, 2.217, 3.18…
## $ area_se                 <dbl> 153.40, 74.08, 94.03, 27.23, 94.44, 27.19, 53.…
## $ smoothness_se           <dbl> 0.006399, 0.005225, 0.006150, 0.009110, 0.0114…
## $ compactness_se          <dbl> 0.049040, 0.013080, 0.040060, 0.074580, 0.0246…
## $ concavity_se            <dbl> 0.05373, 0.01860, 0.03832, 0.05661, 0.05688, 0…
## $ concave.points_se       <dbl> 0.015870, 0.013400, 0.020580, 0.018670, 0.0188…
## $ symmetry_se             <dbl> 0.03003, 0.01389, 0.02250, 0.05963, 0.01756, 0…
## $ fractal_dimension_se    <dbl> 0.006193, 0.003532, 0.004571, 0.009208, 0.0051…
## $ radius_worst            <dbl> 25.38, 24.99, 23.57, 14.91, 22.54, 15.47, 22.8…
## $ texture_worst           <dbl> 17.33, 23.41, 25.53, 26.50, 16.67, 23.75, 27.6…
## $ perimeter_worst         <dbl> 184.60, 158.80, 152.50, 98.87, 152.20, 103.40,…
## $ area_worst              <dbl> 2019.0, 1956.0, 1709.0, 567.7, 1575.0, 741.6, …
## $ smoothness_worst        <dbl> 0.1622, 0.1238, 0.1444, 0.2098, 0.1374, 0.1791…
## $ compactness_worst       <dbl> 0.6656, 0.1866, 0.4245, 0.8663, 0.2050, 0.5249…
## $ concavity_worst         <dbl> 0.71190, 0.24160, 0.45040, 0.68690, 0.40000, 0…
## $ concave.points_worst    <dbl> 0.26540, 0.18600, 0.24300, 0.25750, 0.16250, 0…
## $ symmetry_worst          <dbl> 0.4601, 0.2750, 0.3613, 0.6638, 0.2364, 0.3985…
## $ fractal_dimension_worst <dbl> 0.11890, 0.08902, 0.08758, 0.17300, 0.07678, 0…
df<-df %>%
select(-id)
df$diagnosis<-as.factor(df$diagnosis)
prop.table(table(df$diagnosis))
## 
##         B         M 
## 0.6274165 0.3725835
any(is.na(df))
## [1] FALSE
set.seed(3)
inTraining<-createDataPartition(y=df$diagnosis,p=.75,list=FALSE)
training<-df[inTraining,]
testing<-df[-inTraining,]

my_trainControl<-trainControl(method = "repeatedcv",
                              number = 10,
                              repeats = 10,
                              classProbs = TRUE,
                              summaryFunction = twoClassSummary)

glmnetfit<-train(diagnosis~., data=training,
                 method="glmnet",
                 tuneLength=20,
                 trControl=fitControl,
                 verbose=FALSE,
                 metric="ROC")
glmnetfit
## glmnet 
## 
## 427 samples
##  30 predictor
##   2 classes: 'B', 'M' 
## 
## No pre-processing
## Resampling: Cross-Validated (10 fold, repeated 10 times) 
## Summary of sample sizes: 386, 384, 384, 384, 384, 384, ... 
## Resampling results across tuning parameters:
## 
##   alpha      lambda        ROC        Sens       Spec     
##   0.1000000  0.0001199795  0.9924250  0.9817521  0.9529167
##   0.1000000  0.0001860300  0.9924250  0.9817521  0.9529167
##   0.1000000  0.0002884425  0.9924250  0.9817521  0.9529167
##   0.1000000  0.0004472347  0.9925432  0.9821225  0.9529167
##   0.1000000  0.0006934444  0.9932239  0.9839744  0.9541250
##   0.1000000  0.0010751965  0.9935754  0.9873219  0.9529167
##   0.1000000  0.0016671092  0.9938571  0.9925356  0.9529583
##   0.1000000  0.0025848791  0.9941358  0.9954986  0.9498333
##   0.1000000  0.0040078959  0.9944206  0.9969943  0.9504167
##   0.1000000  0.0062143058  0.9944436  0.9984900  0.9466667
##   0.1000000  0.0096353793  0.9943732  0.9992450  0.9453750
##   0.1000000  0.0149398076  0.9942559  0.9992450  0.9447500
##   0.1000000  0.0231644074  0.9942085  0.9996296  0.9397500
##   0.1000000  0.0359167792  0.9941391  0.9996296  0.9328333
##   0.1000000  0.0556895330  0.9939249  0.9996296  0.9240417
##   0.1000000  0.0863474996  0.9932652  0.9988604  0.9090000
##   0.1000000  0.1338831607  0.9923208  0.9977493  0.8882500
##   0.1000000  0.2075879534  0.9913428  0.9962393  0.8813750
##   0.1000000  0.3218683974  0.9908304  0.9962393  0.8569167
##   0.1000000  0.4990620292  0.9901276  0.9962393  0.8278333
##   0.1473684  0.0001199795  0.9923291  0.9806268  0.9516250
##   0.1473684  0.0001860300  0.9923291  0.9806268  0.9516250
##   0.1473684  0.0002884425  0.9924019  0.9809972  0.9522500
##   0.1473684  0.0004472347  0.9925432  0.9821225  0.9529167
##   0.1473684  0.0006934444  0.9931999  0.9839744  0.9541250
##   0.1473684  0.0010751965  0.9935994  0.9873219  0.9522917
##   0.1473684  0.0016671092  0.9939275  0.9932764  0.9529583
##   0.1473684  0.0025848791  0.9941373  0.9954986  0.9498333
##   0.1473684  0.0040078959  0.9943975  0.9973789  0.9504167
##   0.1473684  0.0062143058  0.9943964  0.9984900  0.9460417
##   0.1473684  0.0096353793  0.9943510  0.9992450  0.9460000
##   0.1473684  0.0149398076  0.9942087  0.9996296  0.9460000
##   0.1473684  0.0231644074  0.9941640  0.9996296  0.9391250
##   0.1473684  0.0359167792  0.9941631  0.9996296  0.9309583
##   0.1473684  0.0556895330  0.9936416  0.9992450  0.9184167
##   0.1473684  0.0863474996  0.9932179  0.9984900  0.9052500
##   0.1473684  0.1338831607  0.9922001  0.9962393  0.8857500
##   0.1473684  0.2075879534  0.9914834  0.9962393  0.8775833
##   0.1473684  0.3218683974  0.9905740  0.9962393  0.8473750
##   0.1473684  0.4990620292  0.9896537  0.9962393  0.7944167
##   0.1947368  0.0001199795  0.9920726  0.9795014  0.9503750
##   0.1947368  0.0001860300  0.9920726  0.9795014  0.9503750
##   0.1947368  0.0002884425  0.9923994  0.9809972  0.9522500
##   0.1947368  0.0004472347  0.9925201  0.9821225  0.9529167
##   0.1947368  0.0006934444  0.9932239  0.9839744  0.9547500
##   0.1947368  0.0010751965  0.9936010  0.9877066  0.9522917
##   0.1947368  0.0016671092  0.9939043  0.9929060  0.9529167
##   0.1947368  0.0025848791  0.9941389  0.9943875  0.9498333
##   0.1947368  0.0040078959  0.9943726  0.9973789  0.9504167
##   0.1947368  0.0062143058  0.9943260  0.9984900  0.9453750
##   0.1947368  0.0096353793  0.9942070  0.9992450  0.9466250
##   0.1947368  0.0149398076  0.9940912  0.9996296  0.9447500
##   0.1947368  0.0231644074  0.9940681  0.9996296  0.9353750
##   0.1947368  0.0359167792  0.9940465  0.9996296  0.9278333
##   0.1947368  0.0556895330  0.9935000  0.9988746  0.9177917
##   0.1947368  0.0863474996  0.9930081  0.9977493  0.8995833
##   0.1947368  0.1338831607  0.9923444  0.9962393  0.8826250
##   0.1947368  0.2075879534  0.9914389  0.9962393  0.8725833
##   0.1947368  0.3218683974  0.9901741  0.9962393  0.8367083
##   0.1947368  0.4990620292  0.9885821  0.9962393  0.7498750
##   0.2421053  0.0001199795  0.9918610  0.9787607  0.9485000
##   0.2421053  0.0001860300  0.9919560  0.9791311  0.9497500
##   0.2421053  0.0002884425  0.9923762  0.9802422  0.9522500
##   0.2421053  0.0004472347  0.9925432  0.9821225  0.9529167
##   0.2421053  0.0006934444  0.9931776  0.9843447  0.9547500
##   0.2421053  0.0010751965  0.9936010  0.9877066  0.9516250
##   0.2421053  0.0016671092  0.9939043  0.9925356  0.9510417
##   0.2421053  0.0025848791  0.9941157  0.9947721  0.9498333
##   0.2421053  0.0040078959  0.9943973  0.9981197  0.9497917
##   0.2421053  0.0062143058  0.9943260  0.9988746  0.9466250
##   0.2421053  0.0096353793  0.9941607  0.9992450  0.9472500
##   0.2421053  0.0149398076  0.9940449  0.9996296  0.9447500
##   0.2421053  0.0231644074  0.9940440  0.9996296  0.9366250
##   0.2421053  0.0359167792  0.9939022  0.9992450  0.9278333
##   0.2421053  0.0556895330  0.9933139  0.9984900  0.9177917
##   0.2421053  0.0863474996  0.9928890  0.9977493  0.8958333
##   0.2421053  0.1338831607  0.9922527  0.9962393  0.8795000
##   0.2421053  0.2075879534  0.9912057  0.9962393  0.8630000
##   0.2421053  0.3218683974  0.9895884  0.9962393  0.8095833
##   0.2421053  0.4990620292  0.9875280  0.9966097  0.7216250
##   0.2894737  0.0001199795  0.9915533  0.9776496  0.9459583
##   0.2894737  0.0001860300  0.9919560  0.9787464  0.9497500
##   0.2894737  0.0002884425  0.9923762  0.9798860  0.9522500
##   0.2894737  0.0004472347  0.9925672  0.9821225  0.9529167
##   0.2894737  0.0006934444  0.9931536  0.9847151  0.9547500
##   0.2894737  0.0010751965  0.9936257  0.9880769  0.9516250
##   0.2894737  0.0016671092  0.9939275  0.9914245  0.9504167
##   0.2894737  0.0025848791  0.9941645  0.9951425  0.9498333
##   0.2894737  0.0040078959  0.9943501  0.9981197  0.9497917
##   0.2894737  0.0062143058  0.9942319  0.9988746  0.9472500
##   0.2894737  0.0096353793  0.9941838  0.9992450  0.9479167
##   0.2894737  0.0149398076  0.9940681  0.9996296  0.9447917
##   0.2894737  0.0231644074  0.9939969  0.9996296  0.9360000
##   0.2894737  0.0359167792  0.9937342  0.9992450  0.9240417
##   0.2894737  0.0556895330  0.9932429  0.9981054  0.9152917
##   0.2894737  0.0863474996  0.9927474  0.9977493  0.8889167
##   0.2894737  0.1338831607  0.9920212  0.9962393  0.8775833
##   0.2894737  0.2075879534  0.9908545  0.9962393  0.8561250
##   0.2894737  0.3218683974  0.9885128  0.9962393  0.7932083
##   0.2894737  0.4990620292  0.9872676  0.9988604  0.6989583
##   0.3368421  0.0001199795  0.9913672  0.9776496  0.9447083
##   0.3368421  0.0001860300  0.9919792  0.9787464  0.9491250
##   0.3368421  0.0002884425  0.9923291  0.9798860  0.9522500
##   0.3368421  0.0004472347  0.9925672  0.9825071  0.9529167
##   0.3368421  0.0006934444  0.9931305  0.9847293  0.9547917
##   0.3368421  0.0010751965  0.9936951  0.9877066  0.9522500
##   0.3368421  0.0016671092  0.9939506  0.9906838  0.9510417
##   0.3368421  0.0025848791  0.9940926  0.9955128  0.9504583
##   0.3368421  0.0040078959  0.9942797  0.9981197  0.9497917
##   0.3368421  0.0062143058  0.9942782  0.9988746  0.9466250
##   0.3368421  0.0096353793  0.9941375  0.9992450  0.9472917
##   0.3368421  0.0149398076  0.9941384  0.9992593  0.9454167
##   0.3368421  0.0231644074  0.9939488  0.9992593  0.9341250
##   0.3368421  0.0359167792  0.9936175  0.9988604  0.9227917
##   0.3368421  0.0556895330  0.9931726  0.9981054  0.9146667
##   0.3368421  0.0863474996  0.9926308  0.9977493  0.8851667
##   0.3368421  0.1338831607  0.9917185  0.9962393  0.8744167
##   0.3368421  0.2075879534  0.9900821  0.9962393  0.8423750
##   0.3368421  0.3218683974  0.9876909  0.9962393  0.7674583
##   0.3368421  0.4990620292  0.9875538  1.0000000  0.6592917
##   0.3842105  0.0001199795  0.9913441  0.9772792  0.9447083
##   0.3842105  0.0001860300  0.9920023  0.9783761  0.9491250
##   0.3842105  0.0002884425  0.9922596  0.9798860  0.9522500
##   0.3842105  0.0004472347  0.9925672  0.9821225  0.9529167
##   0.3842105  0.0006934444  0.9931305  0.9851140  0.9547917
##   0.3842105  0.0010751965  0.9936232  0.9877066  0.9510000
##   0.3842105  0.0016671092  0.9939506  0.9906838  0.9510417
##   0.3842105  0.0025848791  0.9940917  0.9958974  0.9504583
##   0.3842105  0.0040078959  0.9941841  0.9977493  0.9497917
##   0.3842105  0.0062143058  0.9942782  0.9988746  0.9472917
##   0.3842105  0.0096353793  0.9941607  0.9992450  0.9485417
##   0.3842105  0.0149398076  0.9940921  0.9992593  0.9447917
##   0.3842105  0.0231644074  0.9939506  0.9992593  0.9334583
##   0.3842105  0.0359167792  0.9934297  0.9984900  0.9215417
##   0.3842105  0.0556895330  0.9931726  0.9981054  0.9127917
##   0.3842105  0.0863474996  0.9924430  0.9977493  0.8813750
##   0.3842105  0.1338831607  0.9914639  0.9962393  0.8655833
##   0.3842105  0.2075879534  0.9894688  0.9962393  0.8305000
##   0.3842105  0.3218683974  0.9875721  0.9973647  0.7555000
##   0.3842105  0.4990620292  0.9882447  1.0000000  0.5995833
##   0.4315789  0.0001199795  0.9913432  0.9772792  0.9447083
##   0.4315789  0.0001860300  0.9919551  0.9783761  0.9478333
##   0.4315789  0.0002884425  0.9922356  0.9798860  0.9510000
##   0.4315789  0.0004472347  0.9925672  0.9821225  0.9522500
##   0.4315789  0.0006934444  0.9930833  0.9851140  0.9541667
##   0.4315789  0.0010751965  0.9936214  0.9877066  0.9510000
##   0.4315789  0.0016671092  0.9939025  0.9910684  0.9516667
##   0.4315789  0.0025848791  0.9940677  0.9962678  0.9504583
##   0.4315789  0.0040078959  0.9940906  0.9977493  0.9497917
##   0.4315789  0.0062143058  0.9943022  0.9988746  0.9466667
##   0.4315789  0.0096353793  0.9942301  0.9988746  0.9472917
##   0.4315789  0.0149398076  0.9941162  0.9992593  0.9454583
##   0.4315789  0.0231644074  0.9938313  0.9988746  0.9315833
##   0.4315789  0.0359167792  0.9933346  0.9984900  0.9202917
##   0.4315789  0.0556895330  0.9930791  0.9981054  0.9083750
##   0.4315789  0.0863474996  0.9923014  0.9973789  0.8782083
##   0.4315789  0.1338831607  0.9912299  0.9962393  0.8617500
##   0.4315789  0.2075879534  0.9887004  0.9962393  0.8235417
##   0.4315789  0.3218683974  0.9878830  0.9988604  0.7316667
##   0.4315789  0.4990620292  0.9889977  1.0000000  0.5262083
##   0.4789474  0.0001199795  0.9912720  0.9769088  0.9447083
##   0.4789474  0.0001860300  0.9917691  0.9776353  0.9478333
##   0.4789474  0.0002884425  0.9921884  0.9795157  0.9510000
##   0.4789474  0.0004472347  0.9925432  0.9821225  0.9522500
##   0.4789474  0.0006934444  0.9930601  0.9851140  0.9547917
##   0.4789474  0.0010751965  0.9935033  0.9877208  0.9522500
##   0.4789474  0.0016671092  0.9938313  0.9910684  0.9516667
##   0.4789474  0.0025848791  0.9940436  0.9962678  0.9510833
##   0.4789474  0.0040078959  0.9940196  0.9981197  0.9491667
##   0.4789474  0.0062143058  0.9942559  0.9985043  0.9466667
##   0.4789474  0.0096353793  0.9942533  0.9988889  0.9479167
##   0.4789474  0.0149398076  0.9941384  0.9992593  0.9435000
##   0.4789474  0.0231644074  0.9938544  0.9988746  0.9310000
##   0.4789474  0.0359167792  0.9934735  0.9988746  0.9202917
##   0.4789474  0.0556895330  0.9930800  0.9981054  0.9026667
##   0.4789474  0.0863474996  0.9923014  0.9973789  0.8762917
##   0.4789474  0.1338831607  0.9907828  0.9962393  0.8517500
##   0.4789474  0.2075879534  0.9882523  0.9962393  0.8122083
##   0.4789474  0.3218683974  0.9884982  0.9996154  0.7077917
##   0.4789474  0.4990620292  0.9900808  1.0000000  0.4545833
##   0.5263158  0.0001199795  0.9912007  0.9765385  0.9447083
##   0.5263158  0.0001860300  0.9917228  0.9768946  0.9478333
##   0.5263158  0.0002884425  0.9921644  0.9791453  0.9503750
##   0.5263158  0.0004472347  0.9925201  0.9821225  0.9522500
##   0.5263158  0.0006934444  0.9930370  0.9847436  0.9541667
##   0.5263158  0.0010751965  0.9934338  0.9877208  0.9528750
##   0.5263158  0.0016671092  0.9938051  0.9910684  0.9516667
##   0.5263158  0.0025848791  0.9940205  0.9955128  0.9510833
##   0.5263158  0.0040078959  0.9940899  0.9977493  0.9491667
##   0.5263158  0.0062143058  0.9942791  0.9981339  0.9472917
##   0.5263158  0.0096353793  0.9942764  0.9985185  0.9454167
##   0.5263158  0.0149398076  0.9941616  0.9988889  0.9422500
##   0.5263158  0.0231644074  0.9938767  0.9988746  0.9297500
##   0.5263158  0.0359167792  0.9935448  0.9985043  0.9177917
##   0.5263158  0.0556895330  0.9930560  0.9984900  0.8970000
##   0.5263158  0.0863474996  0.9920922  0.9969943  0.8731667
##   0.5263158  0.1338831607  0.9902929  0.9962393  0.8442500
##   0.5263158  0.2075879534  0.9881862  0.9966097  0.7969583
##   0.5263158  0.3218683974  0.9888074  1.0000000  0.6820000
##   0.5263158  0.4990620292  0.9902673  1.0000000  0.3318750
##   0.5736842  0.0001199795  0.9910156  0.9761681  0.9447083
##   0.5736842  0.0001860300  0.9916268  0.9765242  0.9459583
##   0.5736842  0.0002884425  0.9920940  0.9780199  0.9491250
##   0.5736842  0.0004472347  0.9924259  0.9821225  0.9516250
##   0.5736842  0.0006934444  0.9929898  0.9843732  0.9541667
##   0.5736842  0.0010751965  0.9933635  0.9877208  0.9528750
##   0.5736842  0.0016671092  0.9937347  0.9910684  0.9522917
##   0.5736842  0.0025848791  0.9939239  0.9951425  0.9504167
##   0.5736842  0.0040078959  0.9940899  0.9970085  0.9497917
##   0.5736842  0.0062143058  0.9943247  0.9981339  0.9466667
##   0.5736842  0.0096353793  0.9942533  0.9985185  0.9454167
##   0.5736842  0.0149398076  0.9940663  0.9988889  0.9416250
##   0.5736842  0.0231644074  0.9939238  0.9988746  0.9285000
##   0.5736842  0.0359167792  0.9935465  0.9985043  0.9115000
##   0.5736842  0.0556895330  0.9931005  0.9984900  0.8944583
##   0.5736842  0.0863474996  0.9920459  0.9973789  0.8662083
##   0.5736842  0.1338831607  0.9898475  0.9962393  0.8405000
##   0.5736842  0.2075879534  0.9884037  0.9984900  0.7868750
##   0.5736842  0.3218683974  0.9895355  1.0000000  0.6687500
##   0.5736842  0.4990620292  0.9900557  1.0000000  0.2154583
##   0.6210526  0.0001199795  0.9908767  0.9754274  0.9447083
##   0.6210526  0.0001860300  0.9915077  0.9757835  0.9459583
##   0.6210526  0.0002884425  0.9920477  0.9780199  0.9478333
##   0.6210526  0.0004472347  0.9924250  0.9810114  0.9503750
##   0.6210526  0.0006934444  0.9929179  0.9836182  0.9535417
##   0.6210526  0.0010751965  0.9933394  0.9873504  0.9528750
##   0.6210526  0.0016671092  0.9936395  0.9914387  0.9522917
##   0.6210526  0.0025848791  0.9939230  0.9947721  0.9504167
##   0.6210526  0.0040078959  0.9941578  0.9970085  0.9510833
##   0.6210526  0.0062143058  0.9943007  0.9977635  0.9454167
##   0.6210526  0.0096353793  0.9942764  0.9985185  0.9453750
##   0.6210526  0.0149398076  0.9940654  0.9988889  0.9403750
##   0.6210526  0.0231644074  0.9939247  0.9985043  0.9266250
##   0.6210526  0.0359167792  0.9936641  0.9985043  0.9095833
##   0.6210526  0.0556895330  0.9931219  0.9984900  0.8919583
##   0.6210526  0.0863474996  0.9918120  0.9977493  0.8630833
##   0.6210526  0.1338831607  0.9895455  0.9962393  0.8380000
##   0.6210526  0.2075879534  0.9889396  0.9988604  0.7793750
##   0.6210526  0.3218683974  0.9898658  1.0000000  0.6423750
##   0.6210526  0.4990620292  0.9895595  1.0000000  0.1121667
##   0.6684211  0.0001199795  0.9907823  0.9750570  0.9447083
##   0.6684211  0.0001860300  0.9914598  0.9761681  0.9453333
##   0.6684211  0.0002884425  0.9920014  0.9776496  0.9472083
##   0.6684211  0.0004472347  0.9923547  0.9806410  0.9503750
##   0.6684211  0.0006934444  0.9928003  0.9836182  0.9528750
##   0.6684211  0.0010751965  0.9932932  0.9865954  0.9528750
##   0.6684211  0.0016671092  0.9935685  0.9910684  0.9522917
##   0.6684211  0.0025848791  0.9938278  0.9936610  0.9516667
##   0.6684211  0.0040078959  0.9940610  0.9962678  0.9517083
##   0.6684211  0.0062143058  0.9942773  0.9977778  0.9441667
##   0.6684211  0.0096353793  0.9942292  0.9985185  0.9447500
##   0.6684211  0.0149398076  0.9940191  0.9988889  0.9372500
##   0.6684211  0.0231644074  0.9939247  0.9985043  0.9253750
##   0.6684211  0.0359167792  0.9937139  0.9985043  0.9070833
##   0.6684211  0.0556895330  0.9930740  0.9984900  0.8894583
##   0.6684211  0.0863474996  0.9916572  0.9977493  0.8587083
##   0.6684211  0.1338831607  0.9895001  0.9981197  0.8355000
##   0.6684211  0.2075879534  0.9892931  1.0000000  0.7737500
##   0.6684211  0.3218683974  0.9901492  1.0000000  0.6103750
##   0.6684211  0.4990620292  0.9882585  1.0000000  0.0213750
##   0.7157895  0.0001199795  0.9906425  0.9739316  0.9440833
##   0.7157895  0.0001860300  0.9913200  0.9750570  0.9447083
##   0.7157895  0.0002884425  0.9918601  0.9776496  0.9465833
##   0.7157895  0.0004472347  0.9922374  0.9798860  0.9497500
##   0.7157895  0.0006934444  0.9926614  0.9836182  0.9522500
##   0.7157895  0.0010751965  0.9932451  0.9862393  0.9541250
##   0.7157895  0.0016671092  0.9935213  0.9907123  0.9522917
##   0.7157895  0.0025848791  0.9938262  0.9932906  0.9522917
##   0.7157895  0.0040078959  0.9940138  0.9966382  0.9492083
##   0.7157895  0.0062143058  0.9943005  0.9973932  0.9447500
##   0.7157895  0.0096353793  0.9941598  0.9985185  0.9428750
##   0.7157895  0.0149398076  0.9940191  0.9985043  0.9366250
##   0.7157895  0.0231644074  0.9939710  0.9985043  0.9234167
##   0.7157895  0.0359167792  0.9937355  0.9985043  0.9051667
##   0.7157895  0.0556895330  0.9928187  0.9984900  0.8807083
##   0.7157895  0.0863474996  0.9917064  0.9977493  0.8549583
##   0.7157895  0.1338831607  0.9892170  0.9988604  0.8329583
##   0.7157895  0.2075879534  0.9897416  1.0000000  0.7731667
##   0.7157895  0.3218683974  0.9898448  1.0000000  0.5671250
##   0.7157895  0.4990620292  0.9846020  1.0000000  0.0000000
##   0.7631579  0.0001199795  0.9905036  0.9731766  0.9440833
##   0.7631579  0.0001860300  0.9911349  0.9743162  0.9440833
##   0.7631579  0.0002884425  0.9917428  0.9761681  0.9459583
##   0.7631579  0.0004472347  0.9921911  0.9787749  0.9503750
##   0.7631579  0.0006934444  0.9925920  0.9821225  0.9522500
##   0.7631579  0.0010751965  0.9931500  0.9851282  0.9528750
##   0.7631579  0.0016671092  0.9934741  0.9896011  0.9522917
##   0.7631579  0.0025848791  0.9936855  0.9925356  0.9535417
##   0.7631579  0.0040078959  0.9940138  0.9966239  0.9473333
##   0.7631579  0.0062143058  0.9943708  0.9970228  0.9441250
##   0.7631579  0.0096353793  0.9942533  0.9985185  0.9410000
##   0.7631579  0.0149398076  0.9941357  0.9988889  0.9353750
##   0.7631579  0.0231644074  0.9940648  0.9985043  0.9209167
##   0.7631579  0.0359167792  0.9938299  0.9985043  0.9013750
##   0.7631579  0.0556895330  0.9928245  0.9984900  0.8757083
##   0.7631579  0.0863474996  0.9915173  0.9977493  0.8512083
##   0.7631579  0.1338831607  0.9895273  0.9988604  0.8310833
##   0.7631579  0.2075879534  0.9898166  1.0000000  0.7694167
##   0.7631579  0.3218683974  0.9895340  1.0000000  0.5130417
##   0.7631579  0.4990620292  0.9835697  1.0000000  0.0000000
##   0.8105263  0.0001199795  0.9904095  0.9728205  0.9447083
##   0.8105263  0.0001860300  0.9909951  0.9735755  0.9440833
##   0.8105263  0.0002884425  0.9915336  0.9754274  0.9459583
##   0.8105263  0.0004472347  0.9920738  0.9773077  0.9490833
##   0.8105263  0.0006934444  0.9924738  0.9802707  0.9510000
##   0.8105263  0.0010751965  0.9930791  0.9832621  0.9522500
##   0.8105263  0.0016671092  0.9933806  0.9881054  0.9529167
##   0.8105263  0.0025848791  0.9936615  0.9921652  0.9529583
##   0.8105263  0.0040078959  0.9940379  0.9966239  0.9473333
##   0.8105263  0.0062143058  0.9943236  0.9970085  0.9441250
##   0.8105263  0.0096353793  0.9943699  0.9981339  0.9397500
##   0.8105263  0.0149398076  0.9941582  0.9988889  0.9347500
##   0.8105263  0.0231644074  0.9941582  0.9981339  0.9190417
##   0.8105263  0.0359167792  0.9938521  0.9985043  0.8944583
##   0.8105263  0.0556895330  0.9927139  0.9981197  0.8719583
##   0.8105263  0.0863474996  0.9915432  0.9984900  0.8505833
##   0.8105263  0.1338831607  0.9898329  1.0000000  0.8291667
##   0.8105263  0.2075879534  0.9898382  1.0000000  0.7625417
##   0.8105263  0.3218683974  0.9892488  1.0000000  0.4746250
##   0.8105263  0.4990620292  0.5000000  1.0000000  0.0000000
##   0.8578947  0.0001199795  0.9901061  0.9720798  0.9440833
##   0.8578947  0.0001860300  0.9908538  0.9724644  0.9440833
##   0.8578947  0.0002884425  0.9913929  0.9732051  0.9459583
##   0.8578947  0.0004472347  0.9918637  0.9765670  0.9490833
##   0.8578947  0.0006934444  0.9924275  0.9791453  0.9503750
##   0.8578947  0.0010751965  0.9930078  0.9836325  0.9516250
##   0.8578947  0.0016671092  0.9932880  0.9884758  0.9529167
##   0.8578947  0.0025848791  0.9936615  0.9917806  0.9517083
##   0.8578947  0.0040078959  0.9940619  0.9958689  0.9460417
##   0.8578947  0.0062143058  0.9942061  0.9970085  0.9447500
##   0.8578947  0.0096353793  0.9942971  0.9973789  0.9397500
##   0.8578947  0.0149398076  0.9941119  0.9977635  0.9341250
##   0.8578947  0.0231644074  0.9942045  0.9977493  0.9171667
##   0.8578947  0.0359167792  0.9935512  0.9977635  0.8944583
##   0.8578947  0.0556895330  0.9925737  0.9981197  0.8693750
##   0.8578947  0.0863474996  0.9912346  0.9984900  0.8493333
##   0.8578947  0.1338831607  0.9898578  1.0000000  0.8259167
##   0.8578947  0.2075879534  0.9895050  1.0000000  0.7555833
##   0.8578947  0.3218683974  0.9882327  1.0000000  0.3805000
##   0.8578947  0.4990620292  0.5000000  1.0000000  0.0000000
##   0.9052632  0.0001199795  0.9897571  0.9705840  0.9434583
##   0.9052632  0.0001860300  0.9906412  0.9702279  0.9434583
##   0.9052632  0.0002884425  0.9910646  0.9728348  0.9459583
##   0.9052632  0.0004472347  0.9917455  0.9750712  0.9478333
##   0.9052632  0.0006934444  0.9922381  0.9784046  0.9497500
##   0.9052632  0.0010751965  0.9928921  0.9828775  0.9516250
##   0.9052632  0.0016671092  0.9931921  0.9877066  0.9516667
##   0.9052632  0.0025848791  0.9935680  0.9917806  0.9530000
##   0.9052632  0.0040078959  0.9939444  0.9951425  0.9454167
##   0.9052632  0.0062143058  0.9941582  0.9958832  0.9435000
##   0.9052632  0.0096353793  0.9942740  0.9962678  0.9385000
##   0.9052632  0.0149398076  0.9941823  0.9966382  0.9277917
##   0.9052632  0.0231644074  0.9940176  0.9962536  0.9127917
##   0.9052632  0.0359167792  0.9933881  0.9966239  0.8938333
##   0.9052632  0.0556895330  0.9925303  0.9981197  0.8681667
##   0.9052632  0.0863474996  0.9906048  0.9984900  0.8493333
##   0.9052632  0.1338831607  0.9897216  1.0000000  0.8227500
##   0.9052632  0.2075879534  0.9890837  1.0000000  0.7418333
##   0.9052632  0.3218683974  0.9867765  1.0000000  0.2872917
##   0.9052632  0.4990620292  0.5000000  1.0000000  0.0000000
##   0.9526316  0.0001199795  0.9894529  0.9687322  0.9434583
##   0.9526316  0.0001860300  0.9903848  0.9690883  0.9428333
##   0.9526316  0.0002884425  0.9909696  0.9713248  0.9447083
##   0.9526316  0.0004472347  0.9916049  0.9735755  0.9478333
##   0.9526316  0.0006934444  0.9921206  0.9780199  0.9491250
##   0.9526316  0.0010751965  0.9926588  0.9810114  0.9509583
##   0.9526316  0.0016671092  0.9930770  0.9869516  0.9516667
##   0.9526316  0.0025848791  0.9934282  0.9895442  0.9530000
##   0.9526316  0.0040078959  0.9938278  0.9947436  0.9460417
##   0.9526316  0.0062143058  0.9939944  0.9951140  0.9428750
##   0.9526316  0.0096353793  0.9942045  0.9951140  0.9360000
##   0.9526316  0.0149398076  0.9942286  0.9951140  0.9271667
##   0.9526316  0.0231644074  0.9940191  0.9958689  0.9115417
##   0.9526316  0.0359167792  0.9933422  0.9958832  0.8944583
##   0.9526316  0.0556895330  0.9923433  0.9962536  0.8706667
##   0.9526316  0.0863474996  0.9898787  0.9973932  0.8518750
##   0.9526316  0.1338831607  0.9893381  0.9996296  0.8233750
##   0.9526316  0.2075879534  0.9884410  1.0000000  0.7205417
##   0.9526316  0.3218683974  0.9846057  1.0000000  0.2029583
##   0.9526316  0.4990620292  0.5000000  1.0000000  0.0000000
##   1.0000000  0.0001199795  0.9892668  0.9672222  0.9434583
##   1.0000000  0.0001860300  0.9900340  0.9687179  0.9428333
##   1.0000000  0.0002884425  0.9907362  0.9709687  0.9434583
##   1.0000000  0.0004472347  0.9913500  0.9713248  0.9465833
##   1.0000000  0.0006934444  0.9919824  0.9769231  0.9485000
##   1.0000000  0.0010751965  0.9924460  0.9799003  0.9509583
##   1.0000000  0.0016671092  0.9927726  0.9858405  0.9510000
##   1.0000000  0.0025848791  0.9932397  0.9888034  0.9511250
##   1.0000000  0.0040078959  0.9937861  0.9936182  0.9460417
##   1.0000000  0.0062143058  0.9940674  0.9951140  0.9397500
##   1.0000000  0.0096353793  0.9942989  0.9951140  0.9341250
##   1.0000000  0.0149398076  0.9943942  0.9951140  0.9246667
##   1.0000000  0.0231644074  0.9941841  0.9951140  0.9159167
##   1.0000000  0.0359167792  0.9934367  0.9951140  0.8945417
##   1.0000000  0.0556895330  0.9921541  0.9958832  0.8731250
##   1.0000000  0.0863474996  0.9901894  0.9951425  0.8600000
##   1.0000000  0.1338831607  0.9890839  0.9996296  0.8233750
##   1.0000000  0.2075879534  0.9871237  1.0000000  0.7162083
##   1.0000000  0.3218683974  0.9798371  1.0000000  0.1179583
##   1.0000000  0.4990620292  0.5000000  1.0000000  0.0000000
## 
## ROC was used to select the optimal model using the largest value.
## The final values used for the model were alpha = 0.1 and lambda = 0.006214306.
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(dplyr)
library(nycflights13)

data("flights")
glimpse(flights)
## Rows: 336,776
## Columns: 19
## $ year           <int> 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2…
## $ month          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ day            <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ dep_time       <int> 517, 533, 542, 544, 554, 554, 555, 557, 557, 558, 558, …
## $ sched_dep_time <int> 515, 529, 540, 545, 600, 558, 600, 600, 600, 600, 600, …
## $ dep_delay      <dbl> 2, 4, 2, -1, -6, -4, -5, -3, -3, -2, -2, -2, -2, -2, -1…
## $ arr_time       <int> 830, 850, 923, 1004, 812, 740, 913, 709, 838, 753, 849,…
## $ sched_arr_time <int> 819, 830, 850, 1022, 837, 728, 854, 723, 846, 745, 851,…
## $ arr_delay      <dbl> 11, 20, 33, -18, -25, 12, 19, -14, -8, 8, -2, -3, 7, -1…
## $ carrier        <chr> "UA", "UA", "AA", "B6", "DL", "UA", "B6", "EV", "B6", "…
## $ flight         <int> 1545, 1714, 1141, 725, 461, 1696, 507, 5708, 79, 301, 4…
## $ tailnum        <chr> "N14228", "N24211", "N619AA", "N804JB", "N668DN", "N394…
## $ origin         <chr> "EWR", "LGA", "JFK", "JFK", "LGA", "EWR", "EWR", "LGA",…
## $ dest           <chr> "IAH", "IAH", "MIA", "BQN", "ATL", "ORD", "FLL", "IAD",…
## $ air_time       <dbl> 227, 227, 160, 183, 116, 150, 158, 53, 140, 138, 149, 1…
## $ distance       <dbl> 1400, 1416, 1089, 1576, 762, 719, 1065, 229, 944, 733, …
## $ hour           <dbl> 5, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6…
## $ minute         <dbl> 15, 29, 40, 45, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0…
## $ time_hour      <dttm> 2013-01-01 05:00:00, 2013-01-01 05:00:00, 2013-01-01 0…
today()
## [1] "2024-01-31"
now()
## [1] "2024-01-31 15:59:45 KST"
ymd("2023-01-31")
## [1] "2023-01-31"
mdy("january 1st, 2023")
## [1] "2023-01-01"
dmy("31-jan-2023")
## [1] "2023-01-31"
ymd(20230131)
## [1] "2023-01-31"
ymd_hms("2017-01-31 20:11:59")
## [1] "2017-01-31 20:11:59 UTC"
mdy_hm("01/31/2017 08:01")
## [1] "2017-01-31 08:01:00 UTC"
library(dplyr)
library(nycflights13)
data("flights")
glimpse(flights)
## Rows: 336,776
## Columns: 19
## $ year           <int> 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2…
## $ month          <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ day            <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ dep_time       <int> 517, 533, 542, 544, 554, 554, 555, 557, 557, 558, 558, …
## $ sched_dep_time <int> 515, 529, 540, 545, 600, 558, 600, 600, 600, 600, 600, …
## $ dep_delay      <dbl> 2, 4, 2, -1, -6, -4, -5, -3, -3, -2, -2, -2, -2, -2, -1…
## $ arr_time       <int> 830, 850, 923, 1004, 812, 740, 913, 709, 838, 753, 849,…
## $ sched_arr_time <int> 819, 830, 850, 1022, 837, 728, 854, 723, 846, 745, 851,…
## $ arr_delay      <dbl> 11, 20, 33, -18, -25, 12, 19, -14, -8, 8, -2, -3, 7, -1…
## $ carrier        <chr> "UA", "UA", "AA", "B6", "DL", "UA", "B6", "EV", "B6", "…
## $ flight         <int> 1545, 1714, 1141, 725, 461, 1696, 507, 5708, 79, 301, 4…
## $ tailnum        <chr> "N14228", "N24211", "N619AA", "N804JB", "N668DN", "N394…
## $ origin         <chr> "EWR", "LGA", "JFK", "JFK", "LGA", "EWR", "EWR", "LGA",…
## $ dest           <chr> "IAH", "IAH", "MIA", "BQN", "ATL", "ORD", "FLL", "IAD",…
## $ air_time       <dbl> 227, 227, 160, 183, 116, 150, 158, 53, 140, 138, 149, 1…
## $ distance       <dbl> 1400, 1416, 1089, 1576, 762, 719, 1065, 229, 944, 733, …
## $ hour           <dbl> 5, 5, 5, 5, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6…
## $ minute         <dbl> 15, 29, 40, 45, 0, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 0…
## $ time_hour      <dttm> 2013-01-01 05:00:00, 2013-01-01 05:00:00, 2013-01-01 0…
flights %>% select(year,month,day,hour,minute)  
## # A tibble: 336,776 × 5
##     year month   day  hour minute
##    <int> <int> <int> <dbl>  <dbl>
##  1  2013     1     1     5     15
##  2  2013     1     1     5     29
##  3  2013     1     1     5     40
##  4  2013     1     1     5     45
##  5  2013     1     1     6      0
##  6  2013     1     1     5     58
##  7  2013     1     1     6      0
##  8  2013     1     1     6      0
##  9  2013     1     1     6      0
## 10  2013     1     1     6      0
## # ℹ 336,766 more rows
flights %>%
  select(year,month,day,hour,minute) %>%
  mutate(departure=make_datetime(year,month,day,hour,minute))
## # A tibble: 336,776 × 6
##     year month   day  hour minute departure          
##    <int> <int> <int> <dbl>  <dbl> <dttm>             
##  1  2013     1     1     5     15 2013-01-01 05:15:00
##  2  2013     1     1     5     29 2013-01-01 05:29:00
##  3  2013     1     1     5     40 2013-01-01 05:40:00
##  4  2013     1     1     5     45 2013-01-01 05:45:00
##  5  2013     1     1     6      0 2013-01-01 06:00:00
##  6  2013     1     1     5     58 2013-01-01 05:58:00
##  7  2013     1     1     6      0 2013-01-01 06:00:00
##  8  2013     1     1     6      0 2013-01-01 06:00:00
##  9  2013     1     1     6      0 2013-01-01 06:00:00
## 10  2013     1     1     6      0 2013-01-01 06:00:00
## # ℹ 336,766 more rows
library(ggplot2)
data("economics")
glimpse(economics)
## Rows: 574
## Columns: 6
## $ date     <date> 1967-07-01, 1967-08-01, 1967-09-01, 1967-10-01, 1967-11-01, …
## $ pce      <dbl> 506.7, 509.8, 515.6, 512.2, 517.4, 525.1, 530.9, 533.6, 544.3…
## $ pop      <dbl> 198712, 198911, 199113, 199311, 199498, 199657, 199808, 19992…
## $ psavert  <dbl> 12.6, 12.6, 11.9, 12.9, 12.8, 11.8, 11.7, 12.3, 11.7, 12.3, 1…
## $ uempmed  <dbl> 4.5, 4.7, 4.6, 4.9, 4.7, 4.8, 5.1, 4.5, 4.1, 4.6, 4.4, 4.4, 4…
## $ unemploy <dbl> 2944, 2945, 2958, 3143, 3066, 3018, 2878, 3001, 2877, 2709, 2…
library(lubridate)

df<-read.csv("netflix.csv")
glimpse(df)
## Rows: 8,807
## Columns: 11
## $ show_id      <chr> "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s1…
## $ type         <chr> "Movie", "TV Show", "TV Show", "TV Show", "TV Show", "TV …
## $ title        <chr> "Dick Johnson Is Dead", "Blood & Water", "Ganglands", "Ja…
## $ director     <chr> "Kirsten Johnson", "", "Julien Leclercq", "", "", "Mike F…
## $ cast         <chr> "", "Ama Qamata, Khosi Ngema, Gail Mabalane, Thabang Mola…
## $ country      <chr> "United States", "South Africa", "", "", "India", "", "",…
## $ date_added   <chr> "25-Sep-21", "24-Sep-21", "24-Sep-21", "24-Sep-21", "24-S…
## $ release_year <int> 2020, 2021, 2021, 2021, 2021, 2021, 2021, 1993, 2021, 202…
## $ rating       <chr> "PG-13", "TV-MA", "TV-MA", "TV-MA", "TV-MA", "TV-MA", "PG…
## $ duration     <chr> "90 min", "2 Seasons", "1 Season", "1 Season", "2 Seasons…
## $ listed_in    <chr> "Documentaries", "International TV Shows, TV Dramas, TV M…
df$y2<-parse_date_time(df$date_added,orders=c("mdy","dmy"),train=F)
df %>% filter(country=="United Kingdom") %>%
  filter(y2>='2018-01-01'&y2<='2018-01-31')
##   show_id    type                                        title        director
## 1   s5058 TV Show                                  Retribution                
## 2   s5075   Movie                          Bad Day for the Cut     Chris Baugh
## 3   s5098 TV Show                                     Lovesick                
## 4   s7399   Movie   Manolo: The Boy Who Made Shoes for Lizards Michael Roberts
## 5   s8358 TV Show                             The Inbetweeners                
## 6   s8620   Movie Treasures from the Wreck of the Unbelievable   Sam Hobkinson
##                                                                                                                                                                            cast
## 1                         Georgina Campbell, Joe Dempsie, Adrian Edmondson, Steve Evets, Laura Fraser, Julie Graham, John Lynch, Gary Lewis, Juliet Stevenson, Joanna Vanderham
## 2                        Nigel O'Neill, Susan Lynch, J?zef Pawlowski, Stuart Graham, David Pearse, Brian Milligan, Anna Prochniak, Stella McCusker, Ian McElhinney, Lalor Roddy
## 3                                                                  Johnny Flynn, Antonia Thomas, Daniel Ings, Hannah Britland, Joshua McGuire, Richard Thomson, Jessica Ellerby
## 4 Manolo Blahnik, Anna Wintour, Andr? Leon Talley, Paloma Picasso, Candace Bushnell, Iman, Rihanna, Naomi Campbell, Isaac Mizrahi, Rupert Everett, Sofia Coppola, John Galliano
## 5                     Simon Bird, James Buckley, Blake Harrison, Joe Thomas, Greg Davies, Emily Head, Martin Trenaman, Belinda Stewart-Wilson, Robin Weaver, Henry Lloyd-Hughes
## 6                                                                                                                                                                              
##          country       date_added release_year rating  duration
## 1 United Kingdom        30-Jan-18         2016  TV-MA  1 Season
## 2 United Kingdom        18-Jan-18         2017  TV-MA    99 min
## 3 United Kingdom        01-Jan-18         2018  TV-MA 3 Seasons
## 4 United Kingdom        15-Jan-18         2017  TV-MA    89 min
## 5 United Kingdom  January 1, 2018         2010  TV-MA 3 Seasons
## 6 United Kingdom        01-Jan-18         2017   TV-G    82 min
##                                                     listed_in         y2
## 1    British TV Shows, Crime TV Shows, International TV Shows 2018-01-30
## 2         Independent Movies, International Movies, Thrillers 2018-01-18
## 3 British TV Shows, International TV Shows, Romantic TV Shows 2018-01-01
## 4                         Documentaries, International Movies 2018-01-15
## 5                               British TV Shows, TV Comedies 2018-01-01
## 6                 Documentaries, Dramas, International Movies 2018-01-01