How Mahout used with Python ?

Answer : You should need to download and instal…

Mahout is used with Python:

  • You should need to download and install the JPype package for python.The initial step is to set up JPype is determining the path to the dynamic library for the jvm ; on linux this will be a .so file and on windows it will be a .dll.
  • In python script, make a global variable with the path to this dll file.
  • Then we need to make sense how we have to set the classpath for mahout. The simplest way to do this is to edit script in “bin/mahout” to print out the classpath. Now include the code line “echo $CLASSPATH” to the script anywhere in the following comment “run it”.
  • Finally execute the script to print out the classpath. Now copy this output and paste into a variable in your python script.
  • Presently we can create a function to begin the jvm in python utilizing jype.
[pastacode lang=”python” manual=”from%20jpype%20import%20*%0Ajvm%3DNone%0Adef%20start_jpype()%3A%0Aglobal%20jvm%0Aif%20(jvm%20is%20None)%3A%0Acpopt%3D%22-Djava.class.path%3D%7Bcp%7D%22.format(cp%3Dclasspath)%0AstartJVM(jvmlib%2C%22-ea%22%2Ccpopt)%0Ajvm%3D%22started%22″ message=”” highlight=”” provider=”manual”/]
  • In the same way while reading or writing call the JPype function:
[pastacode lang=”python” manual=”start_jpype()” message=”” highlight=”” provider=”manual”/]
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like