h2o 準(zhǔn)備

首先,你需要下載R,下載python,之后還需要加載java。然后你可以在R中使用
install.packages(h2o) 進(jìn)行安裝h2o,之后就是library(h2o),然后初始化h2o平臺(tái)h2o.init()

你也可以在python中安裝h2o:
pip install - U h2o
import h2o
h2o.init()

做一個(gè)簡短的開始

h2o.init()

irish2o <- as.h2o(iris %>% filter(Species !='setosa'))
y <- 'Species'
x <- setdiff(names(irish2o),y)
parts <- h2o.splitFrame(irish2o,0.8)

train <- parts[[1]]
test <- parts[[2]]


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

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 http://docs.h2o.ai

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


載入程輯包:‘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:
    /var/folders/jz/qf7zhsc97f71slzzf59mvs2w0000gn/T//RtmpujsoRp/h2o_milin_started_from_r.out
    /var/folders/jz/qf7zhsc97f71slzzf59mvs2w0000gn/T//RtmpujsoRp/h2o_milin_started_from_r.err

java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

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

R is connected to the H2O cluster: 
    H2O cluster uptime:         3 seconds 560 milliseconds 
    H2O cluster timezone:       Asia/Shanghai 
    H2O data parsing timezone:  UTC 
    H2O cluster version:        3.20.0.8 
    H2O cluster version age:    1 month and 20 days  
    H2O cluster name:           H2O_started_from_R_milin_jhc047 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   2.00 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:         XGBoost, Algos, AutoML, Core V3, Core V4 
    R Version:                  R version 3.4.3 (2017-11-30) 

 m <- h2o.randomForest(x = x,y = y,training_frame = train)
  |=============================================================| 100%
> m
Model Details:
==============

H2OBinomialModel: drf
Model ID:  DRF_model_R_1541858573921_1 
Model Summary: 
  number_of_trees number_of_internal_trees model_size_in_bytes
1              50                       50                6827
  min_depth max_depth mean_depth min_leaves max_leaves mean_leaves
1         2         5    3.34000          3         10     5.88000


H2OBinomialMetrics: drf
** Reported on training data. **
** Metrics reported on Out-Of-Bag training samples **

MSE:  0.05615946
RMSE:  0.2369799
LogLoss:  0.2136178
Mean Per-Class Error:  0.05441176
AUC:  0.9779412
Gini:  0.9558824

Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
           versicolor virginica    Error   Rate
versicolor         38         2 0.050000  =2/40
virginica           2        32 0.058824  =2/34
Totals             40        34 0.054054  =4/74

Maximum Metrics: Maximum metrics at their respective thresholds
                        metric threshold    value idx
1                       max f1  0.476190 0.941176  30
2                       max f2  0.260952 0.953757  33
3                 max f0point5  0.937500 0.966667  25
4                 max accuracy  0.476190 0.945946  30
5                max precision  1.000000 1.000000   0
6                   max recall  0.004662 1.000000  49
7              max specificity  1.000000 1.000000   0
8             max absolute_mcc  0.476190 0.891176  30
9   max min_per_class_accuracy  0.476190 0.941176  30
10 max mean_per_class_accuracy  0.476190 0.945588  30

Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`


> p <- h2o.predict(m,test)
  |=============================================================| 100%
> p
     predict versicolor   virginica
1 versicolor  0.9679487 0.032051282
2 versicolor  0.8779487 0.122051282
3 versicolor  0.9979487 0.002051282
4 versicolor  0.9679487 0.032051282
5 versicolor  0.9979487 0.002051282
6 versicolor  0.9979487 0.002051282

[26 rows x 3 columns] 
> 

performance Versus Predictions

h2o.performance(m,test)
H2OMultinomialMetrics: drf

Test Set Metrics: 
=====================

MSE: (Extract with `h2o.mse`) 0.08837984
RMSE: (Extract with `h2o.rmse`) 0.2972875
Logloss: (Extract with `h2o.logloss`) 0.2452472
Mean Per-Class Error: 0.1623932
Confusion Matrix: Extract with `h2o.confusionMatrix(<model>, <data>)`)
=========================================================================
Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
           setosa versicolor virginica  Error     Rate
setosa          6          0         0 0.0000 =  0 / 6
versicolor      0         11         2 0.1538 = 2 / 13
virginica       0          3         6 0.3333 =  3 / 9
Totals          6         14         8 0.1786 = 5 / 28

Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>, <data>)`
=======================================================================
Top-3 Hit Ratios: 
  k hit_ratio
1 1  0.821429
2 2  1.000000
3 3  1.000000

> 

h2o flow

h2o flow 是h2o 的一個(gè)網(wǎng)頁的接口,你可以直接上傳或者下載數(shù)據(jù),你可以查看你所建立的所有模型,你可以直接的創(chuàng)建模型,也可以直接的進(jìn)行預(yù)測。

有幾種方式打開h2o flow ,首先,第一種是在你的R或者python中初始化h2o,然后在你的網(wǎng)頁打開:http://127.0.0.1:54321
另外一種是你要在服務(wù)器部署h2o,然后打開

1.Download H2O. This is a zip file that contains everything you need to get started.
2.
 cd ~/Downloads
unzip h2o-3.22.0.1.zip
cd h2o-3.22.0.1
java -jar h2o.jar

3. Point your browser to [http://你的主機(jī)地址:54321] 

如何使用h2o flow 參見我以前的文章:
http://www.itdecent.cn/p/74d12c682af7

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • h2o 一個(gè)簡單方便的建模工具,提供多種接入方式.java ,python等客戶端.還有一個(gè)h2o-flow的可視...
    wangliang938閱讀 10,614評(píng)論 0 3
  • h2o flow 是一個(gè)機(jī)器學(xué)習(xí)的平臺(tái),本文說的是如何在服務(wù)器部署這個(gè)機(jī)器學(xué)習(xí)平臺(tái),然后通過任何一臺(tái)計(jì)算機(jī)訪問。 ...
    Liam_ml閱讀 1,262評(píng)論 0 0
  • [TOC] 一、運(yùn)行環(huán)境要求 1、操作系統(tǒng): Windows 7或更高版本OS X 10.9或更高版本Ubuntu...
    godvan閱讀 1,501評(píng)論 0 0
  • 介紹 人工智能......在這一點(diǎn)上,你知道這是未來的潮流,如果你把它添加到你的職業(yè)技能列表中并且最終會(huì)殺死我們所...
    Liam_ml閱讀 7,840評(píng)論 0 12
  • [TOC] 準(zhǔn)備工作 1、構(gòu)建環(huán)境準(zhǔn)備: JDK >= 1.7NodejsGradlePythonR.npmPi...
    godvan閱讀 579評(píng)論 0 0

友情鏈接更多精彩內(nèi)容