skmultilearn.ext package

The skmultilearn.ext provides wrappers for other multi-label classification libraries. Currently it provides a wrapper for:

  • Meka - the Multilabel Extension to WEKA - MEKA library and through it to MULAN by Tsoumakas. et. al.
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

For more information on how to use this class see the tutorial: Using the meka wrapper

Parameters:

meka_classifier : string

The MEKA classifier string and parameters from the MEKA API, such as: “meka.classifiers.multilabel.MULAN -S RAkEL2”

weka_classifier : string

The WEKA classifier string and parameters from the WEKA API, such as: “weka.classifiers.trees.J48”

java_command : string

Path to test the java command

meka_classpath: string

Path to the MEKA class path folder, usually the folder lib in the directory MEKA was extracted to

clean()[source]
fit(X, y)[source]

Fit classifier with 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.

Parameters:
  • X (dense or sparse matrix (n_samples, n_features)) – input features
  • y (dense or sparse matrix of {0, 1} (n_samples, n_labels)) – binary indicator matrix with label assignments
Returns:

Fitted instance of self

parse_output()[source]

Internal function for parsing MEKA output.

predict(X)[source]

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 (dense or sparse matrix (n_samples, n_features)) – input features
Returns:binary indicator matrix with label assignments
Return type:sparse matrix of int (n_samples, n_labels)
remove_temporary_files(temporary_files)[source]

Internal function for cleaning temporary files

run(train_file, test_file, additional_arguments=[])[source]

Runs the meka classifiers

Parameters:

train_file : string

Path to train .arff file in meka format (big endian, labels first in attributes list).

test_file : string

Path to test .arff file in meka format (big endian, labels first in attributes list).

Returns:

predictions: sparse binary indicator matrix [n_test_samples, n_labels]

array of binary label vectors including label predictions

run_meka_command(args)[source]

Submodules

skmultilearn.ext.meka module

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

Bases: skmultilearn.base.base.MLClassifierBase

Wrapper for the MEKA classifier

For more information on how to use this class see the tutorial: Using the meka wrapper

Parameters:

meka_classifier : string

The MEKA classifier string and parameters from the MEKA API, such as: “meka.classifiers.multilabel.MULAN -S RAkEL2”

weka_classifier : string

The WEKA classifier string and parameters from the WEKA API, such as: “weka.classifiers.trees.J48”

java_command : string

Path to test the java command

meka_classpath: string

Path to the MEKA class path folder, usually the folder lib in the directory MEKA was extracted to

clean()[source]
fit(X, y)[source]

Fit classifier with 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.

Parameters:
  • X (dense or sparse matrix (n_samples, n_features)) – input features
  • y (dense or sparse matrix of {0, 1} (n_samples, n_labels)) – binary indicator matrix with label assignments
Returns:

Fitted instance of self

parse_output()[source]

Internal function for parsing MEKA output.

predict(X)[source]

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 (dense or sparse matrix (n_samples, n_features)) – input features
Returns:binary indicator matrix with label assignments
Return type:sparse matrix of int (n_samples, n_labels)
remove_temporary_files(temporary_files)[source]

Internal function for cleaning temporary files

run(train_file, test_file, additional_arguments=[])[source]

Runs the meka classifiers

Parameters:

train_file : string

Path to train .arff file in meka format (big endian, labels first in attributes list).

test_file : string

Path to test .arff file in meka format (big endian, labels first in attributes list).

Returns:

predictions: sparse binary indicator matrix [n_test_samples, n_labels]

array of binary label vectors including label predictions

run_meka_command(args)[source]