def test_sample_down_label_space(self): _, y = load_dataset('yeast') sample10 = sample_down_label_space(y, 10) assert sample10.shape[1] == 10 sample5 = sample_down_label_space(y, 5) assert sample5.shape[1] == 5 self.assert_raises(ValueError, sample_down_label_space, y, 20)
def test_load_enron(self): X, y = load_dataset('enron', 'undivided')
def test_load_yeast(self): X, y = load_dataset('yeast')
An example of :class:`skml.problem_transformation.LabelPowerset` """ from sklearn.metrics import hamming_loss from sklearn.metrics import accuracy_score from sklearn.metrics import f1_score from sklearn.metrics import precision_score from sklearn.metrics import recall_score from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression import numpy as np from skml.problem_transformation import LabelPowerset from skml.datasets import load_dataset X, y = load_dataset('yeast') X_train, X_test, y_train, y_test = train_test_split(X, y) clf = LabelPowerset(LogisticRegression()) clf.fit(X_test, y_test) y_pred = clf.predict(X_test) print("hamming loss: ") print(hamming_loss(y_test, y_pred)) print("accuracy:") print(accuracy_score(y_test, y_pred)) print("f1 score:") print("micro") print(f1_score(y_test, y_pred, average='micro'))