-1

Im trying to run a Netlogo model where turtle behavior is dependent on the probabilities from a ML model like Decision tree. This rule set is supplied in the form of a PMML file. Is there a way to do this using python extension ?

Update

Im now able to parse and create a rule list. However im having trouble accessing the rules list generated with in py:run (...) block outside i the Netlogo code. I tried changing read_pmml to t-report and then access as py:runresult without any success

I have a workaround to export as a csv file and import again in netlogo code but i feel it is not efficient

example code:

to read_pmml
  (py:run
    "import csv"
    "import xml.etree.ElementTree as ET"
    "tree = ET.parse('mytest.pmml')"
## reminder of the code
    "print (rule_list)"
   )
end
desertnaut
  • 57,590
  • 26
  • 140
  • 166
KaM
  • 13
  • 3

1 Answers1

0

I'm now able to resolve this by creating a function that returns a value inside py:run block and report the o/p of function using py:result

to-report rules
  (py:run
    "def read_rules(): "
    "    import csv"
    ;###Rest of My code###
    "    return rule_list"
    )
  report (py:runresult (word ("read_rules()")))
end
KaM
  • 13
  • 3