skmultilearn.ext.meka module

class skmultilearn.ext.Meka(meka_classifier=None, weka_classifier=None, java_command=None, meka_classpath=None)[source]

Bases: skmultilearn.base.base.MLClassifierBase

Wrapper for the MEKA classifier

Allows using MEKA, WEKA and some of MULAN classifiers from scikit-compatible API. For more information on how to use this class see the tutorial: Using the MEKA wrapper

  • meka_classifier (str) – The MEKA classifier string and parameters from the MEKA API, such as meka.classifiers.multilabel.MULAN -S RAkEL2
  • weka_classifier (str) – The WEKA classifier string and parameters from the WEKA API, such as weka.classifiers.trees.J48
  • java_command (str) – Path to test the java command
  • meka_classpath (str) – Path to the MEKA class path folder, usually the folder lib in the directory MEKA was extracted into

the full text output of MEKA command



If you use this wrapper please also cite:

    author = {Read, Jesse and Reutemann, Peter and Pfahringer, Bernhard and Holmes, Geoff},
    title = {{MEKA}: A Multi-label/Multi-target Extension to {Weka}},
    journal = {Journal of Machine Learning Research},
    year = {2016},
    volume = {17},
    number = {21},
    pages = {1--5},
    url = {},

    author = {Hall, Mark and Frank, Eibe and Holmes, Geoffrey and Pfahringer, Bernhard and Reutemann, Peter and Witten, Ian H.},
    title = {The WEKA Data Mining Software: An Update},
    journal = {SIGKDD Explor. Newsl.},
    issue_date = {June 2009},
    volume = {11},
    number = {1},
    month = nov,
    year = {2009},
    issn = {1931-0145},
    pages = {10--18},
    numpages = {9},
    url = {},
    doi = {10.1145/1656274.1656278},
    acmid = {1656278},
    publisher = {ACM},
    address = {New York, NY, USA},


Here’s an example of performing Label Powerset classification using MEKA with a WEKA Naive Bayes classifier.

from skmultilearn.ext import Meka, download_meka

meka = Meka(
    meka_classifier = "meka.classifiers.multilabel.LC",
    weka_classifier = "weka.classifiers.bayes.NaiveBayes",
    meka_classpath = download_meka(),
    java_command = '/usr/bin/java'), y_train)
predictions = meka.predict(X_test)
fit(X, y)[source]

Fits classifier to training data

Internally this method dumps X and y to temporary arff files and runs MEKA with relevant arguments using _run(). It uses a sparse DOK representation (scipy.sparse.dok_matrix) of the X matrix.

  • X (array_like, numpy.matrix or scipy.sparse matrix, shape=(n_samples, n_features)) – input feature matrix
  • y (array_like, numpy.matrix or scipy.sparse matrix of {0, 1}, shape=(n_samples, n_labels)) – binary indicator matrix with label assignments

fitted instance of self

Return type:



Predict label assignments for X

Internally this method dumps X to temporary arff files and runs MEKA with relevant arguments using _run(). It uses a sparse DOK representation (scipy.sparse.dok_matrix) of the X matrix.

Parameters:X (numpy.ndarray or scipy.sparse) – input features of shape (n_samples, n_features)
Returns:sparse matrix of integers with shape (n_samples, n_features)
Return type:scipy.sparse of int

Downloads a given version of the MEKA library and returns its classpath


version (str) – the MEKA version to download, default falls back to currently supported version 1.9.2


meka class path string for installed version

Return type:


  • IOError – if unpacking the meka release file does not provide a proper setup
  • Exception – if MD5 mismatch happens after a download error