h2o

#insatlling h2o packages
install.packages("h2o")
Installing package into ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'http://rspm/default/__linux__/focal/latest/src/contrib/h2o_3.44.0.3.tar.gz'
Content type 'application/x-gzip' length 266595032 bytes (254.2 MB)
==================================================
downloaded 254.2 MB

* installing *binary* package ‘h2o’ ...
* DONE (h2o)

The downloaded source packages are in
    ‘/tmp/RtmpAuBFVr/downloaded_packages’
#Let's us see if the installation worked
library(h2o)

----------------------------------------------------------------------

Your next step is to start H2O:
    > h2o.init()

For H2O package documentation, ask for help:
    > ??h2o

After starting H2O, you can use the Web UI at http://localhost:54321
For more information visit https://docs.h2o.ai

----------------------------------------------------------------------


Attaching package: ‘h2o’

The following objects are masked from ‘package:stats’:

    cor, sd, var

The following objects are masked from ‘package:base’:

    &&, %*%, %in%, ||, apply, as.factor, as.numeric, colnames, colnames<-, ifelse,
    is.character, is.factor, is.numeric, log, log10, log1p, log2, round, signif, trunc
#
h2o.init()

H2O is not running yet, starting it now...

Note:  In case of errors look at the following log files:
    /tmp/RtmpAuBFVr/file14e26350bec/h2o_r2168188_started_from_r.out
    /tmp/RtmpAuBFVr/file14e4fb4a4a8/h2o_r2168188_started_from_r.err
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu220.04.1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Ubuntu-0ubuntu220.04.1, mixed mode, sharing)

Starting H2O JVM and connecting: ... Connection successful!

R is connected to the H2O cluster: 
    H2O cluster uptime:         2 seconds 764 milliseconds 
    H2O cluster timezone:       UTC 
    H2O data parsing timezone:  UTC 
    H2O cluster version:        3.44.0.3 
    H2O cluster version age:    1 year, 1 month and 14 days 
    H2O cluster name:           H2O_started_from_R_r2168188_eng994 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   0.24 GB 
    H2O cluster total cores:    1 
    H2O cluster allowed cores:  1 
    H2O cluster healthy:        TRUE 
    H2O Connection ip:          localhost 
    H2O Connection port:        54321 
    H2O Connection proxy:       NA 
    H2O Internal Security:      FALSE 
    R Version:                  R version 4.4.2 (2024-10-31) 
Warning in h2o.clusterInfo() : 
Your H2O cluster version is (1 year, 1 month and 14 days) old. There may be a newer version available.
Please download and install the latest version from: https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html
??h20
#use local host 5431 
# We use an h2o cluster on the specified port 5431. We use localhost and port 5431
h2o.init(ip = "localhost", port = 5431)
#Next step is to start h2o cluster
h2o.init()
 Connection successful!

R is connected to the H2O cluster: 
    H2O cluster uptime:         7 minutes 56 seconds 
    H2O cluster timezone:       UTC 
    H2O data parsing timezone:  UTC 
    H2O cluster version:        3.44.0.3 
    H2O cluster version age:    1 year, 1 month and 14 days 
    H2O cluster name:           H2O_started_from_R_r2168188_end099 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   0.18 GB 
    H2O cluster total cores:    1 
    H2O cluster allowed cores:  1 
    H2O cluster healthy:        TRUE 
    H2O Connection ip:          localhost 
    H2O Connection port:        54321 
    H2O Connection proxy:       NA 
    H2O Internal Security:      FALSE 
    R Version:                  R version 4.4.2 (2024-10-31) 
Warning in h2o.clusterInfo() : 
Your H2O cluster version is (1 year, 1 month and 14 days) old. There may be a newer version available.
Please download and install the latest version from: https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html
library(h2o)
#This command is used to initialize the h2o cluster with the specified number of threads for parallel processing
h2o.init(nthreads=-1)
 Connection successful!

R is connected to the H2O cluster: 
    H2O cluster uptime:         9 seconds 778 milliseconds 
    H2O cluster timezone:       UTC 
    H2O data parsing timezone:  UTC 
    H2O cluster version:        3.44.0.3 
    H2O cluster version age:    1 year, 1 month and 14 days 
    H2O cluster name:           H2O_started_from_R_r2168188_eng994 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   0.23 GB 
    H2O cluster total cores:    1 
    H2O cluster allowed cores:  1 
    H2O cluster healthy:        TRUE 
    H2O Connection ip:          localhost 
    H2O Connection port:        54321 
    H2O Connection proxy:       NA 
    H2O Internal Security:      FALSE 
    R Version:                  R version 4.4.2 (2024-10-31) 
Warning in h2o.clusterInfo() : 
Your H2O cluster version is (1 year, 1 month and 14 days) old. There may be a newer version available.
Please download and install the latest version from: https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html
#here we are importing dataset that is built in h20
datasets <- "https://raw.githubusercontent.com/DarrenCook/h2o/bk/datasets/"
data <- h2o.importFile(paste0(datasets, "iris_wheader.csv"))
y <- "class"
x <- setdiff(names(data), y)
parts <- h2o.splitFrame(data, 0.8)

train <- parts[[1]]
test <- parts[[2]]
m <- h2o.deeplearning(x, y, train)

  |                                                                                                    
  |                                                                                              |   0%
  |                                                                                                    
  |==============================================================================================| 100%
#This function is used in teh contact of statistical modelinh and machine learning. 
p <- h2o.predict(m, test)
h2o.mse(m)
#this deeplearning model that we used in this platform is built in and struggles to show the Iris vs vaeriscolor
h2o.confusionMatrix(m)
#The "predict" column in the first row shows the predicted class for the test data, while the other three columns display its confidence. It's very confident it’s a setosa, but less certain about the other predictions.
as.data.frame(p)
#The correct species is in test_class, while H2O’s model's prediction is in deeplearning’s guess, predict.

as.data.frame( h2o.cbind(p$predict, test$class) )
#We can analyze the model's accuracy by calculating mean(predict == testclass) in R, which gives 0.90625. This means the model correctly predicted 90.6% of the 30 test samples.
mean(p$predict ==test$class)
Error: object 'p' not found
#Another way to find the accuracy is by using h2o.performance(m, test) in R instead of predict().
h2o.performance(m,test)
LS0tCnRpdGxlOiAiUiBOb3RlYm9vayIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKaDJvCgoKYGBge3J9CiNpbnNhdGxsaW5nIGgybyBwYWNrYWdlcwppbnN0YWxsLnBhY2thZ2VzKCJoMm8iKQpgYGAKCmBgYHtyfQojTGV0J3MgdXMgc2VlIGlmIHRoZSBpbnN0YWxsYXRpb24gd29ya2VkCmxpYnJhcnkoaDJvKQpgYGAKYGBge3J9CiMKaDJvLmluaXQoKQpgY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