Giter Site home page Giter Site logo

bignmf's Introduction

BigNmf

Build Status Read the Docs PyPI version License: MIT Downloads

BigNmf (Big Data NMF) is a python 3 package for conducting analysis using NMF algorithms.

NMF Introduction

NMF (Non-negative matrix factorization) factorizes a non-negative input matrix into non-negative factors. The algorithm has an inherent clustering property and has been gaining attention in various fields especially in biological data analysis.

Brunet et al in their paper demonstrated NMF's superior capability in clustering the leukemia dataset compared to standard clustering algorithms like Hierarchial clustering and Self-organizeing maps.

Available algorithms

The following are the algorithms currently available. If you would like to know more about the algorithm, the links below lead to their papers of origin.

Installation

This package is available on the PyPi repository. Therefore you can install, by running the following.

pip3 install bignmf

Usage

The following examples illustrate typical usage of the algorithm.

1. Single NMF

from bignmf.datasets.datasets import Datasets
from bignmf.models.snmf.standard import StandardNmf

Datasets.list_all()
data=Datasets.read("SimulatedX1")
k = 3
iter =100
trials = 50

model = StandardNmf(data,k)

# Runs the model
model.run(trials, iter, verbose=0)
print(model.error)

# Clusters the data
model.cluster_data()
print(model.h_cluster)

#Calculates the consensus matrices
model.calc_consensus_matrices() 
print(model.consensus_matrix_w)

2. Joint NMF

from bignmf.models.jnmf.integrative import IntegrativeJnmf
from bignmf.datasets.datasets import Datasets

Datasets.list_all()
data_dict = {}
data_dict["sim1"] = Datasets.read("SimulatedX1")
data_dict["sim2"] = Datasets.read("SimulatedX2")

k = 3
iter =100
trials = 50
lamb = 0.1

model = IntegrativeJnmf(data_dict, k, lamb)
# Runs the model
model.run(trials, iter, verbose=0)
print(model.error)

# Clusters the data
model.cluster_data()
print(model.h_cluster)

#Calculates the consensus matrices
model.calc_consensus_matrices() 
print(model.consensus_matrix_w)

Here is the extensive documentation for more details.

bignmf's People

Contributors

dependabot[bot] avatar haranrk avatar vaibhav-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hank9cao

bignmf's Issues

ValueError during run

When I run the code:

nmf_cm = StandardNmf(pd.DataFrame(data_tfidf), k = 20)
nmf_cm.run(iterations = 1000, trials = 20)

I get the following error:

ValueError
30 nmf_cm = StandardNmf(pd.DataFrame(data_tfidf), k = k)
---> 31 nmf_cm.run(iterations = 100, trials = 20, verbose = 0)
32 nmf_cm.calc_consensus_matrices()
33 nmf_cm.calc_cophenetic_correlation()

File ...\bignmf\models\snmf\snmf_base.py:52, in SnmfBase.run(self, trials, iterations, verbose)
50 print("\tTrial: %i completed with Error: %f " % (i, self.error))
51 # Normalization
---> 52 self.consensus_matrix_w = self.reorder_consensus_matrix(self.consensus_matrix_w / trials)
53 self.consensus_matrix_h = self.reorder_consensus_matrix(self.consensus_matrix_h / trials)
54 # Converting values to DataFrames

File ...\bignmf\models\nmf.py:69, in NmfBase.reorder_consensus_matrix(M)
67 M = pd.DataFrame(M)
68 Y = 1 - M
---> 69 Z = linkage(squareform(Y), method='average')
70 ivl = leaves_list(Z)
71 ivl = ivl[::-1]

File ...\scipy\spatial\distance.py:2354, in squareform(X, force, checks)
2352 raise ValueError('The matrix argument must be square.')
...
2436 'be zero.') % name)
2437 else:
2438 raise ValueError('Distance matrix diagonal must be zero.')

ValueError: Distance matrix 'X' diagonal must be zero.

My input is TFIDF data and there are no negative elements in it. Is there something wrong in the implementation of the function or am I making a mistake?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.