H2O 를 활용한 Deep Learning (Neural Networks)
## Warning: package 'h2o' was built under R version 4.0.3
## Connection successful!
##
## R is connected to the H2O cluster:
## H2O cluster uptime: 5 hours 11 minutes
## H2O cluster timezone: Asia/Seoul
## H2O data parsing timezone: UTC
## H2O cluster version: 3.32.0.1
## H2O cluster version age: 25 days
## H2O cluster name: H2O_started_from_R_user_uho906
## H2O cluster total nodes: 1
## H2O cluster total memory: 3.96 GB
## H2O cluster total cores: 4
## H2O cluster allowed cores: 4
## H2O cluster healthy: TRUE
## H2O Connection ip: localhost
## H2O Connection port: 54321
## H2O Connection proxy: NA
## H2O Internal Security: FALSE
## H2O API Extensions: Amazon S3, Algos, AutoML, Core V3, TargetEncoder, Core V4
## R Version: R version 4.0.2 (2020-06-22)
# Import the insurance dataset into H2O:
insurance <- h2o.importFile("http://s3.amazonaws.com/h2o-public-test-data/smalldata/glm_test/insurance.csv")##
|
| | 0%
|
|======================================================================| 100%
## District Group Age Holders Claims
## 1 1 <1l <25 197 38
## 2 1 <1l 25-29 264 35
## 3 1 <1l 30-35 246 20
## 4 1 <1l >35 1680 156
## 5 1 1-1.5l <25 284 63
## 6 1 1-1.5l 25-29 536 84
##
## [64 rows x 5 columns]
# Set the factors:
offset = log(insurance$Holders)
insurance$Holders <- as.factor(insurance$Holders)
insurance$Age <- as.factor(insurance$Age)
insurance$Group <- as.factor(insurance$Group)
insurance$District <- as.factor(insurance$District)# Build and train the model:
dl <- h2o.deeplearning(x = 1:3,
y = "Claims",
distribution = "tweedie",
hidden = c(1),
epochs = 1000,
train_samples_per_iteration = -1,
reproducible = TRUE,
activation = "Tanh",
single_node_mode = FALSE,
balance_classes = FALSE,
force_load_balance = FALSE,
seed = 23123,
tweedie_power = 1.5,
score_training_samples = 0,
score_validation_samples = 0,
training_frame = insurance,
stopping_rounds = 0)##
|
| | 0%
|
|= | 1%
|
|=========== | 16%
|
|=================== | 27%
|
|========================= | 36%
|
|=============================== | 44%
|
|==================================== | 51%
|
|======================================== | 58%
|
|============================================= | 64%
|
|================================================== | 71%
|
|====================================================== | 78%
|
|=========================================================== | 84%
|
|=============================================================== | 90%
|
|=================================================================== | 96%
|
|======================================================================| 100%
## H2ORegressionMetrics: deeplearning
## ** Reported on training data. **
## ** Metrics reported on full training frame **
##
## MSE: 373.5344
## RMSE: 19.32704
## MAE: 9.058789
## RMSLE: 0.3281787
## Mean Residual Deviance : 0.5560917
##
|
| | 0%
|
|======================================================================| 100%
## predict
## 1 17.46302
## 2 33.08835
## 3 38.73943
## 4 166.64276
## 5 50.03000
## 6 86.78265
##
## [64 rows x 1 column]