Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore first commit Feb 19, 2016
.gitmodules first commit Feb 19, 2016 Add columns if predicted result columns number is not equal to input … Sep 30, 2016

Labeled-LDA for Python (implemented like Sciki-learn)

The Python implementation of Labeled-LDA with collapsed gibbs sampling estimation and online learning by particle filter.

Original file:15.11.30 HIGASHI Koichi

For Python implementation like Scikit-learn:16.02.19 SUZUKI Shinya


  • git clone, git submodule update, and make C library
  • set a path
from sklearn import cross_validation
from sklearn import datasets
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.metrics import f1_score
from LLDA.llda import LLDAClassifier
def main():
    iris = datasets.load_iris(),
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(,, test_size=0.4, random_state=0)
    mlb = MultiLabelBinarizer()
    y_train = [[each] for each in y_train]
    y_train = mlb.fit_transform(y_train)
    llda = LLDAClassifier(alpha = 0.5/y_train.shape[1]), y_train)
    result = mlb.fit_transform(llda.predict(X_test, assignment=True))
    y_test = mlb.fit_transform([[each] for each in y_test])
    score_macro = f1_score(y_test, result, average="macro")
    score_micro = f1_score(y_test, result, average="micro")
    print("F1_macro:{0}, F1_micro:{1}".format(score_macro, score_micro))
if __name__ =='__main__':
You can’t perform that action at this time.