Last active
July 21, 2020 22:25
-
-
Save darrenjrobinson/7423cd75a1b7c9ec6a181fd9b05da9be to your computer and use it in GitHub Desktop.
Get Prediction using H2O AI for an Iris using the H2OAI PowerShell Module. Associated Blogpost https://blog.darrenjrobinson.com/h2o-ai-powershell-module/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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