The Data Mining Forum                             open-source data mining software open-source data mining software data science journal data mining conferences
This forum is about data mining, data science and big data: algorithms, source code, datasets, implementations, optimizations, etc. You are welcome to post call for papers, data mining job ads, link to source code of data mining algorithms or anything else related to data mining. The forum is hosted by P. Fournier-Viger. No registration is required to use this forum!.  
Installation of python wrapper for SPMF
Posted by: Evelyn Edomenko
Date: July 01, 2020 12:48AM

First of all, I am very thankful for this library existing and also is available for python.

I am trying to install the python wrapper for the java implementation I found here:
https://pypi.org/project/spmf/

I was reading through an example to use a json array as an input as I would have to make transformation otherwise. My code looks like this now:






with open("test.json"winking smiley as BOB:
    chains=json.load(BOcool smiley


spmf = Spmf("AprioriInverse", input_direct=chains,
             output_filename="output.txt",
             arguments=[0.1, 0.6]) 

exit()






The main problem is that I am not able to make it work so that the python is picking up or finding the spmf.jar that I downloaded to the spmf to the python lib directory. It is still throwing an error that it cannot find the .jar file.

The error looks like this:



File "test.py", line 34, in <module>
    arguments=[0.1, 0.6]) 
  File "/home/evelyn/.local/lib/python3.6/site-packages/spmf/__init__.py", line 36, in __init__
    " use the spmf_bin_location_dir argument."winking smiley
FileNotFoundError: spmf.jar not found. Please use the spmf_bin_location_dir argument.







I put the .jar into this directory:
/home/evelyn/.local/lib/python3.6/site-packages/spmf

Is this not the right place to put it? Or is the wrapper outdated? Or do I have to give the Spmf object the directory as an argument?
I also tried to run the code with the directory argument spmf_bin_location_dir like this:

python3 test.py /home/evelyn/.local/lib/python3.6/site-packages/spmf/


But this didn't work either.

I am stuck with this and I would be very thankful if there might be some help on this.

Thank you very much in advance!



Edited 1 time(s). Last edit at 07/01/2020 04:48AM by webmasterphilfv.

Options: ReplyQuote
Re: Installation of python wrapper for SPMF
Posted by: Evelyn Edomenko
Date: July 01, 2020 01:09AM

I have found the solution to this and will therefore answer to this myself after going through the __init__.py file.


The Spmf object needs an argument set to find the jar. So the code looks like this:




with open("test.json"winking smiley as BOB:
chains=json.load(BOcool smiley

spmf = Spmf("AprioriInverse", input_direct=chains,
output_filename="output.txt",
spmf_bin_location_dir="/home/evelyn/.local/lib/python3.6/site-packages/spmf/",
arguments=[0.1, 0.6])

spmf.run()

exit()

Options: ReplyQuote
Re: Installation of python wrapper for SPMF
Date: July 01, 2020 04:50AM

Hi!

Glad you have found the solution as I am not a Python user. So that is good that you have found the solution by yourself, and also happy that you share it.

Could you help me to write a small tutorial explaining how to use SPMF from Python to run an algorithm?

Then, I could put it on the official webpage of SPMF and I could also add you as a contributior. I think that many people would be interested to run it from Python!

Best regards,

Philippe

Options: ReplyQuote


This forum is powered by Phorum and provided by P. Fournier-Viger (© 2012).
Terms of use.