python - C# - IronPython, unexpected token "append" -


so i've been tinkering around ironpython while... i've managed run long scripts no issues. but, when started using sklearn, in script below started getting exception : "microsoft.scripting.syntaxerrorexception: 'unexpected token 'append''" ...

here's script i'm trying run

import numpy np sklearn.naive_bayes import gaussiannb  def predict(a,b):      x = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])     y = np.array([1, 1, 1, 0, 0, 0])      clfr = gaussiannb()     clfr.fit(x,y)     return clfr.predict([[a, b]]) 

here's c# code i'm using:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using ironpython.hosting; using system.io; using ironpython.modules;  namespace bayes {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          void runscript()         {             var ironpythonruntime = python.createruntime();             var engine = ironpythonruntime.getengine("python");             var paths = engine.getsearchpaths();             paths.add(@"c:\users\sushr\appdata\local\programs\python\python36\lib");             paths.add(@"c:\users\sushr\appdata\local\programs\python\python36\lib\site-packages");                engine.setsearchpaths(paths);              try             {                 dynamic loadpythonscript = ironpythonruntime.usefile("c:\\users\\sushr\\pythexp\\bayes.py"); ///<--- exception reported here                 textbox1.text = loadpythonscript.predict(1, -2) + "";             }             catch (filenotfoundexception ex)             {                 messagebox.show(ex.tostring());             }         }          private void button1_click(object sender, eventargs e)         {             runscript();         }     } } 

thanks in advance 🙂


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -