Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: SyntaxError: keyword can't be an expression

In a Python script I call a function from rpy2, but I get this error:

#using an R module 
res = DirichletReg.ddirichlet(np.asarray(my_values),alphas,
                              log=False, sum.up=False) 
SyntaxError: keyword can't be an expression

What exactly went wrong here?

like image 523
Ricky Robinson Avatar asked Jul 24 '12 14:07

Ricky Robinson


2 Answers

sum.up is not a valid keyword argument name. Keyword arguments must be valid identifiers. You should look in the documentation of the library you are using how this argument really is called – maybe sum_up?

like image 128
Sven Marnach Avatar answered Oct 23 '22 22:10

Sven Marnach


I guess many of us who came to this page have a problem with Scikit Learn, one way to solve it is to create a dictionary with parameters and pass it to the model:

params = {'C': 1e9, 'gamma': 1e-07}
cls = SVC(**params)    
like image 24
Vadim Avatar answered Oct 23 '22 21:10

Vadim