SPMF -Wrappers for R, Python, Weka, Spark, etc.

How to call SPMF from other languages?

SPMF is implemented in Java. If you want to use SPMF from Java or as a standalone program, please see the detailed instructions on installing and running SPMF on the download page.

Now, if you want to use SPMF from other languages or platforms such as Python, R, C#, Spark, there are a few ways to do as explained below.

Option 1: Calling SPMF as an external program

The most simple way to use SPMF from another language is to call SPMF as an external program. Since SPMF can be used from the command line and take as input text files and produce as output text files, it is easy to call SPMF from any language.

I wrote a few articles that gives some examples code about calling SPMF as an external program from various languages:

If you want to call SPMF from a program written in another language, it is actually not difficult and the above example can give some inspiration about how to do. It only requires to know how to call a Java program and how to read/write text files.

Option 2: Calling SPMF using a wrapper

If you want to call SPMF from another language in a more convenient way, it is also possible to use one of the several unofficial wrappers that have been designed for SPMF for languages such as Python, R, Spark and Weka.

Here, I provide a list of such wrappers. Note that these wrappers are unofficial. Thus, I do not offer support for them. Moreover, some of these wrappers do not offer all the features of SPMF.

1) The Py-SPMF wrapper for Python

Author: Lorenz Leitner
Website: https://pypi.org/project/spmf/
Last update: >2020
Requirement: Python > 3
- This wrapper is said to support most of the sequential pattern mining algorithms offered in SPMF and may work for other algorithms but has not been tested for all of them .
- Input data can be specified as file or using data objects.
- Transformation of data to CSV and Panda data frames is supported.
- Several examples are offered of how to use the wrapper.
- To install the wrapper, it requires downloading the spmf.jar file from the download page of spmf, and installing the wrapper using pip: pip install spmf.
The wrapper can also be installed to be used as part of a python pipeline using pip install spmf-py (see webpage of the wrapper for details).

3) The SPMFWrapper for Weka

Author: Cristopher Beckham
Website: https://github.com/christopher-beckham/spmf-wrapper
Last update: ~2014
Requirement: Weka
- This is a Weka package for calling frequent itemset and association rule mining algorithms of SPMF.
- It works only for the algorithms that can take the ARFF format as input. This means that some algorithms like sequential rule mining algorithm will not work.
- Installing the package with ANT and CD is simple: ant -Dpackage=spmfWrapper make_package
Running an algorithm like Apriori is simple: java weka.Run weka.associations.SPMFWrapper -M Apriori -P 0.4 -t <file>.arff

3) A wrapper for R

Author: Michaël Benesty
Website: https://github.com/pommedeterresautee/spmf
Last update: ~2014
Requirement: R
- This is some R code for calling SPMF algorithms from R.
- The documentation is not very detailed but the code has several examples.
- It can be used as example of how to call SPMF from R.

4) Wrapper for the VMSP algorithm from Python

There a few other projects that have developed code to call SPMF from Python such as:

5) Wrapper for some algorithms from Spark

There a few other projects that have developed code to call SPMF from Python such as: