Skip to content

Instantly share code, notes, and snippets.

View kaivalyar's full-sized avatar

Kai kaivalyar

View GitHub Profile
@kaivalyar
kaivalyar / setup.py
Created July 24, 2018 21:56
Profiling Cython Code
from distutils.core import setup
from Cython.Build import cythonize
setup(
#ext_modules=cythonize(['*.pyx'])
ext_modules=cythonize("*.pyx", compiler_directives={'profile': True})
)
@kaivalyar
kaivalyar / profiling.py
Last active July 24, 2018 20:53
Profiling PracMLN
import os
import time
from pracmln import query
from pracmln import MLN, Database, query
def main(arg='.'):
pth = os.path.join(arg, 'wts.pybpll.smoking-train-smoking.mln')
mln = MLN(mlnfile=pth, grammar='StandardGrammar')
pth = os.path.join(arg, 'smoking-test.db')
db = Database(mln, dbfile=pth)
@kaivalyar
kaivalyar / full_test.sh
Last active August 29, 2018 15:51
PracMLN full system test (for Logic module)
#!/bin/bash
PYTHONPATH="${PYTHONPATH}:/home/kaivalya/ ... /PracMLN/python3/"
source ~/.prac3/bin/activate
python3 test.py
deactivate
PYTHONPATH=""
source ~/p3/bin/activate
python3 test.py
@kaivalyar
kaivalyar / multitest.sh
Created June 28, 2018 08:30
EnumerationAsk - Exact
#!/bin/bash
echo "Python, followed by Cython: "
bash testpc.sh
bash testpc.sh
bash testpc.sh
bash testpc.sh
bash testpc.sh
bash testpc.sh
bash testpc.sh
@kaivalyar
kaivalyar / Performance_cy.csv
Created June 10, 2018 22:56
PracMLN Performance
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 1. in line 1.
Inference, EnumerationAsk, 0.1270275115966797, 0.033542633056640625
()
()
Inference, MC-SAT, 0.4272785186767578, 0.4875507354736328
Inference, GibbsSampler, 0.12882208824157715, 0.12560558319091797
Inference, WCSPInference, 0.14586448669433594, 0.03891730308532715
Inference, EnumerationAsk, 0.12506461143493652, 0.03306984901428223
()
()
Inference, MC-SAT, 0.3744349479675293, 0.4124472141265869
kaivalya@kaivalyarawal ~/Documents/WORK/GSoC/Gists/TaxonomiesInfer/MC-SAT $ bash test.sh
Traceback (most recent call last):
File "test.py", line 27, in <module>
main(sys.argv[1])
File "test.py", line 15, in main
query(queries='has_sense, action_role', method='MC-SAT', mln=mln, db=db, verbose=False, multicore=True).run()
File "/home/kaivalya/Documents/WORK/GSoC/kPracMLN/python3/pracmln/mlnquery.py", line 249, in run
result = inference.run()
File "infer.pyx", line 189, in pracmln.mln.inference.infer.Inference.run
File "mcsat.pyx", line 240, in pracmln.mln.inference.mcsat.MCSAT._run
@kaivalyar
kaivalyar / test.py
Last active June 6, 2018 01:20
PracMLN WCSP Test
import timeit
import sys
import os
import time
from pracmln import query
from pracmln import MLN, Database, query
def main(arg='.'):
#if (len(sys))
pth = os.path.join(arg, 'wts.pybpll.smoking-train-smoking.mln')
@kaivalyar
kaivalyar / test.py
Created June 6, 2018 01:19
PracMLN Gibbs Test
import timeit
import sys
import os
import time
from pracmln import query
from pracmln import MLN, Database, query
def main(arg='.'):
#if (len(sys))
pth = os.path.join(arg, 'wts.pybpll.smoking-train-smoking.mln')
@kaivalyar
kaivalyar / test.py
Last active August 29, 2018 15:46
PracMLN MC-SAT Test
import timeit
import sys
import os
import time
from pracmln import query
from pracmln import MLN, Database, query
def main(arg='.'):
#if (len(sys))
pth = os.path.join(arg, 'wts.pybpll.smoking-train-smoking.mln')
@kaivalyar
kaivalyar / test.py
Created May 24, 2018 23:45
PracMLN Exact Test
mln = None
db = None
def set():
from pracmln import MLN, Database, query
import sys
import os
global mln
global db
pth = os.path.join(sys.argv[1], 'wts.pybpll.smoking-train-smoking.mln')