Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Prediction using H2O AI for an Iris using the H2OAI PowerShell Module. Associated Blogpost https://blog.darrenjrobinson.com/h2o-ai-powershell-module/
# Default H2O AI Server running locally via Start-H2O
$url = "http://localhost:54321/3/{0}"
# Neural net algorithm for determining Iris type
$modelAlgorithm = 'deeplearning'
# Get Iris Training data and put on the local filesystem
Invoke-RestMethod -Method Get 'https://raw.githubusercontent.com/DarrenCook/h2o/bk/datasets/iris_wheader.csv' | out-file ./iris_wheader.csv
# Prediction Column
$predictValues = 'class'
# Data to make prediction from stored as a CSV on the local filesystem
@"
sepal_len, sepal_wid, petal_len, petal_wid
5.1,3.5,1.4,0.15
"@ | out-file -encoding ASCII ./iris_predict.csv
# Send to H2O AI and get prediction
$dataPath = (Get-ChildItem ./iris_predict.csv).DirectoryName
$result = $null
$result = Get-H2OPrediction -url $url -dataset "$($dataPath)/iris_wheader.csv" -predictData "$($dataPath)/iris_predict.csv" -modelAlgorithm $modelAlgorithm -modelSplit ".85,.15" -predictColumn $predictValues
$result.prediction | Format-Table
<# OUTPUT
label data
----- ----
predict {0}
Iris-setosa {0.999969054518561}
Iris-versicolor {3.09454814387964E-05}
Iris-virginica {2.15784441455808E-28}
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.