0

when I run this code in mac:

x_train, y_train = load_svmlight_file("mq2008.train")

I get this error in bash:

-bash: syntax error near unexpected token `('

and if I run it in shell, I face this error:

NameError: name 'load_svmlight_file' is not defined

How can I solve this problem?

sam
  • 1,819
  • 1
  • 18
  • 30
Roza
  • 7
  • 2

1 Answers1

0

Welcome to StackOverflow!

IMO, you have a Python code and trying to replicate its output. If so, you should first load all Python-related imports first. This is what it means to NameError here, Python interpreter is not able to understand what it is, because this function is not part of its existing definitions it has.

If I may suggest, please spend some time to get the hands-on-learning of Python.

sam
  • 1,819
  • 1
  • 18
  • 30
  • Would you tell me for this especial code what kind of imports should I load? – Roza Dec 10 '19 at 11:29
  • Sure! You need to import `load_svmlight_file ` function. – sam Dec 10 '19 at 11:58
  • Example of how you import `from os import path`; Here `os` is a python internal library and `path` can be package/function/variable you are importing. – sam Dec 10 '19 at 11:59