Exemplo n.º 1
0
def nmf(X, method='sklearn', **nmfparams):
    """
    Calculates the non-negative matrix factorization of an input matrix
    """

    #TODO: Documentation

    if method == 'sklearn':
        model = NMF(**nmfparams)
        H = model.fit_transform(X)
        W = model.components_
    elif method == 'nimfa':
        model_tmp = nimfa.mf(X, **nmfparams)
        model = nimfa.mf_run(model_tmp)
        H = model.coef()
        W = model.basis()

    return (H, W, model)
Exemplo n.º 2
0
def nmf(X, method='sklearn', **nmfparams):
    """
    Calculates the non-negative matrix factorization of an input matrix
    """

    #TODO: Documentation

    if method == 'sklearn':
        model = NMF(**nmfparams)
        H = model.fit_transform(X)
        W = model.components_
    elif method == 'nimfa':
        model_tmp = nimfa.mf(X, **nmfparams)
        model = nimfa.mf_run(model_tmp)
        H = model.coef()
        W = model.basis()

    return (H, W, model)