Label Network Embeddings for Multi-label Classification (LNEMLC)¶
-
class
skmultilearn.embedding.
OpenNetworkEmbedder
(graph_builder, embedding, dimension, aggregation_function, normalize_weights, param_dict=None)[source]¶ Bases:
object
Embed the label space using a label network embedder from OpenNE
Implements an OpenNE based LNEMLC: label network embeddings for multi-label classification.
Parameters: - graph_builder (a GraphBuilderBase inherited transformer) – the graph builder to provide the adjacency matrix and weight map for the underlying graph
- embedding (string, one of {'GraphFactorization', 'GraRep', 'HOPE', 'LaplacianEigenmaps', 'LINE', 'LLE'}) –
the selected OpenNE embedding
Method name string Description GraphFactorization Graph factorization embeddings GraRep Graph representations with global structural information HOPE High-order Proximity Preserved Embedding LaplacianEigenmaps Detecting communities from multiple async label propagation on the graph LINE Large-scale information network embedding LLE Locally Linear Embedding
- dimension: int
- the dimension of the label embedding vectors
- aggregation_function: ‘add’, ‘multiply’, ‘average’ or Callable
- the function used to aggregate label vectors for all labels assigned to each of the samples
- normalize_weights: boolean
- whether to normalize weights in the label graph by the number of samples or not
- param_dict
- parameters passed to the embedder, don’t use the dimension and graph parameters, this class will set them at fit
If you use this classifier please cite the relevant embedding method paper and the label network embedding for multi-label classification paper:
@article{zhang2007ml, title={ML-KNN: A lazy learning approach to multi-label learning}, author={Zhang, Min-Ling and Zhou, Zhi-Hua}, journal={Pattern recognition}, volume={40}, number={7}, pages={2038--2048}, year={2007}, publisher={Elsevier} }
Example code for using this embedder looks like this:
from skmultilearn.embedding import OpenNetworkEmbedder, EmbeddingClassifier from sklearn.ensemble import RandomForestRegressor from skmultilearn.adapt import MLkNN from skmultilearn.cluster import LabelCooccurrenceGraphBuilder graph_builder = LabelCooccurrenceGraphBuilder(weighted=True, include_self_edges=False) openne_line_params = dict(batch_size=1000, negative_ratio=5) clf = EmbeddingClassifier( OpenNetworkEmbedder(graph_builder, 'LINE', 4, 'add', True, openne_line_params), RandomForestRegressor(n_estimators=10), MLkNN(k=5) ) clf.fit(X_train, y_train) predictions = clf.predict(X_test)