2017-10-30

BigObject Python AI Algorithm Environment





by Mark Hsia 2017/10/30
BigObject: Performance with 100x Speedup


The BigObject AI Algorithm Environment allows users to test their AI algorithm with BigObject in Python environment. BigObject is able to store a large amount of test data and choose the best performance cases from the storage.

In this OpenAI CartPole example, we will create a work space in python and map it to a BigObject table. With the functions of pulltable() and pushtable(), data can be transferred easily between python and BO.

1. Define fields of our space:
fieldsdef=[
['ind','INT32'],
['ob0','FLOAT'],
['ob1','FLOAT'],
['ob2','FLOAT'],
['ob3','FLOAT'],
['ob4','FLOAT'],
['action','INT32'],
['reward','FLOAT'],
['value','FLOAT'],
['dist','FLOAT'],
]

2. Create table space1 and add an empty row:
newspace(fieldsdef,'statespace',keys='')
schema=getschema('statespace')
rows=[]
rowscnt=0

3. Generate data rows into our space1 list:
row=[self.mem_pointer,ob[1],ob[1],ob[3],ob[3],ob[4],a,reward,0]
rows.append(row)
rowscnt+=1

4. Push space1 data back to BigObject table:
pushtable('statespace',rows)
rows=[]
rowscnt=0

5. Extract data from BigObject table with a SQL statement:
sql="select action,AVG(value) as v from (select * "
sql+=" from statespace order by dist) group by action order by v desc"
result=querysql(sql,50)