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
Parameters: - 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
References
If you use this wrapper please also cite:
@article{MEKA, 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 = {http://jmlr.org/papers/v17/12-164.html}, } @article{Hall:2009:WDM:1656274.1656278, 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 = {http://doi.acm.org/10.1145/1656274.1656278}, doi = {10.1145/1656274.1656278}, acmid = {1656278}, publisher = {ACM}, address = {New York, NY, USA}, }
Examples
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') meka.fit(X_train, 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.Parameters: - X (array_like,
numpy.matrix
orscipy.sparse
matrix, shape=(n_samples, n_features)) – input feature matrix - y (array_like,
numpy.matrix
orscipy.sparse
matrix of {0, 1}, shape=(n_samples, n_labels)) – binary indicator matrix with label assignments
Returns: fitted instance of self
Return type: self
- X (array_like,
-
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 (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
- meka_classifier (str) – The MEKA classifier string and parameters from the MEKA API,
such as
-
skmultilearn.ext.
download_meka
(version=None)[source]¶ Downloads a given version of the MEKA library and returns its classpath
Parameters: version (str) – the MEKA version to download, default falls back to currently supported version 1.9.2
Returns: meka class path string for installed version
Return type: string
Raises: