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.
from jpype import *
jvm=None
def start_jpype():
global jvm
if (jvm is None):
cpopt="-Djava.class.path={cp}".format(cp=classpath)
startJVM(jvmlib,"-ea",cpopt)
jvm="started"
  • In the same way while reading or writing call the JPype function:
start_jpype()

Categorized in: