macOS ◆ xterm-256color ◆ zsh 457 views

Quick demo of IntegratedML based on Titanic data

More info on IntegratedML: https://community.intersystems.com/post/intersystems-iris-advanced-analytics-and-iris-health-advanced-analytics-preview-published

Commands from this demo:

a) Run docker container

docker run --name irisml --init --detach --publish 52773:52773 --volume /tmp:/tmp/parent store/intersystems/iris-aa-community:2020.3.0AA.331.0

b) Run terminal session

docker exec -it irisml irissession iris 

c) Check that data is in the file

! head -n 10 /tmp/parent/titanic/train.csv     

d) Specify header for data in csv

set header="ROW(PassengerId %Integer, Survived %Boolean, Pclass %Integer, Name VARCHAR(100), Sex VARCHAR(6), Age %Integer, SibSp %Integer, Parch %Integer, Ticket VARCHAR(20), Fare %Currency, Cabin VARCHAR(20), Embarked VARCHAR(2))"     

e) Specify filename to load train data from

set filename = "/tmp/parent/titanic/train.csv" 

f) Specify table name to load train data to

set tableName = "test.TitanicTrain"

g) Load test data

do ##class(%SQL.Util.Procedures).CSVTOCLASS(,header,filename,,,1,tableName) 

h) Run SQL Shell

do $system.SQL.Shell()  

i) Check that data was loaded correctly

select top 10 * from test.titanicTrain  

j) Create and train model

CREATE MODEL TitanicSurvival Predicting (Survived) From Test.titanicTrain  

TRAIN MODEL TitanicSurvival

k) Leave SQL Shell

quit

l) Load test data. Header is the same, but without Survived column

set header="ROW(PassengerId %Integer, Pclass %Integer, Name VARCHAR(100), Sex VARCHAR(6), Age %Integer, SibSp %Integer, Parch %Integer, Ticket VARCHAR(20), Fare %Currency, Cabin VARCHAR(20), Embarked VARCHAR(2))"    

m) Specify filename to load test data from

set filename = "/tmp/parent/titanic/test.csv"     

n) Specify table name to load test data to

set tableName = "test.titanicTest"

o) Load test data

do ##class(%SQL.Util.Procedures).CSVTOCLASS(,header,filename,,,1,tableName)             

p) Open SQL Shell

do $system.SQL.Shell() 

q) Check that test data was loaded correctly

select top 10 * from test.titanicTest

r) Predict value for Survived for test data

select PassengerId, Predict(TitanicSurvival) Survived from test.titanicTest   

s) Specify output folder to export results to CSV

set displaypath=/tmp/parent/titanic 

t) Specify filename

set displayfile=results.txt

u) Specify encoding

set displaytranslatetable=UTF8

v) Specify format. CSV in our case

set displaymode=csv

w) Repeat last SQL command, now with results forwarded to the file

go

x) Leave the SQL Shell

quit

y) Check the results

! head -n 10 /tmp/parent/titanic/results.txt.csv

z) Replace TAB with comma in results file

! sed 's/\t/,/g' /tmp/parent/titanic/results.txt.csv > /tmp/parent/titanic/results.csv

zz) View final results

! head -n 10 /tmp/parent/titanic/results.csv