Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
# https://gist.github.com/FranzDiebold/898396a6be785d9b5ca6f3706ef9b0bc | |
"""Hack to add per-session state to Streamlit. | |
Works for Streamlit >= v0.65 | |
Usage | |
----- | |
>>> import SessionState | |
>>> |
This file contains hidden or 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
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
from PIL import Image | |
from swat import CAS, options | |
import json | |
import time | |
import math | |
import SessionState | |
import altair as alt |
This file contains hidden or 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
shapvals = s.linearExplainer( | |
table = {"name" : 'hmeqTest','caslib':'public'}, | |
query = {"name" : 'realtime','caslib':'public'}, | |
modelTable = {"name" :"hmeqTestAstore",'caslib':'public'}, | |
modelTableType = "ASTORE", | |
predictedTarget = 'P_BAD1', | |
seed = 1234, | |
preset = "KERNELSHAP", | |
inputs = ['LOAN','MORTDUE','VALUE','YOJ','DEROG','DELINQ','CLAGE','NINQ','CLNO','DEBTINC','REASON', 'JOB','BAD'], | |
nominals = ['REASON', 'JOB','BAD'] |
This file contains hidden or 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
!pip install swat | |
from swat import CAS, options | |
import pandas as pd | |
import numpy as np |
This file contains hidden or 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
s = CAS(host, port, username, password) | |
s.loadActionSet('autotune') | |
s.loadactionset('aStore') | |
s.loadactionset('decisionTree') | |
s.loadactionset("explainModel") | |
s.loadactionset('table') |
This file contains hidden or 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
hmeq = pd.read_csv('hmeq.csv') | |
hmeq |
This file contains hidden or 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
s.upload(hmeq,casout={'name' : 'hmeqTest', 'caslib' : 'public','replace' : True}) |
This file contains hidden or 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
result = s.autotune.tuneGradientBoostTree( | |
trainOptions = { | |
"table" : {"name":'hmeqTest', 'caslib' : 'public'}, | |
"inputs" : {'LOAN','MORTDUE','VALUE','YOJ','DEROG','DELINQ','CLAGE','NINQ','CLNO','DEBTINC','REASON', 'JOB'}, | |
"target" : 'BAD', | |
"nominal" : {'BAD','REASON', 'JOB'}, | |
"casout" : {"name":"gradboosthmeqtest", "caslib":"public",'replace':True}, | |
"varImp" : True | |
}, | |
tunerOptions={"seed":12345, "maxTime":60} |
This file contains hidden or 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
s.table.promote(name="hmeqTest", caslib='public',target="hmeqTest",targetLib='public') | |
modelAstore = s.decisionTree.dtreeExportModel(modelTable = {"caslib":"public","name":"gradboosthmeqtest" }, | |
casOut = {"caslib":"public","name":'hmeqTestAstore','replace':True}) | |
s.table.promote(name='hmeqTestAstore', caslib='public',target='hmeqTestAstore',targetLib='public') |
OlderNewer