The Wayback Machine - https://web.archive.org/web/20240930232130/https://www.geeksforgeeks.org/non-negative-matrix-factorization/
Open In App

Non-Negative Matrix Factorization

Last Updated : 02 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Prerequisite : Low Rank Approximation

Non-Negative Matrix Factorization: 

Nonnegative Matrix Factorization is a matrix factorization method where we constrain the matrices to be nonnegative. In order to understand NMF, we should clarify the underlying intuition between matrix factorization.

For a matrix A of dimensions m x n, where each element is ≥ 0, NMF can factorize it into two matrices W and H having dimensions m x k and k x n respectively and these two matrices only contain non-negative elements. Here, matrix A is defined as:

A_{m_X n} = W_{m_X k} H_{k_X n}

where,
A -> Original Input Matrix (Linear combination of W & H)
W -> Feature Matrix
H -> Coefficient Matrix (Weights associated with W)
k -> Low rank approximation of A (k ≤ min(m,n))

This method is widely used in performing tasks such as feature reduction in Facial Recognition and for various NLP tasks. 

Intuition:

Fig 1 : NMF Intuition 

The objective of NMF is dimensionality reduction and feature extraction. So, when we set lower dimension as k, the goal of NMF is to find two matrices W ∈ Rm×k and H ∈ Rn×k having only nonnegative elements. (As shown in Fig 1)

Therefore, by using NMF we are able to obtain factorized matrices having significantly lower dimensions than those of the product matrix. Intuitively, NMF assumes that the original input is made of a set of hidden features, represented by each column of W matrix and each column in H matrix represents the ‘coordinates of a data point’ in the matrix W. In simple terms, it contains the weights associated with matrix W.

In this, each data point that is represented as a column in A, can be approximated by an additive combination of the non-negative vectors, which are represented as columns in W.

How Does it Work?

  • NMF decomposes multivariate data by creating a user-defined number of features. Each feature is a linear combination of the original attribute set; the coefficients of these linear combinations are non-negative. 
  • NMF decomposes a data matrix V into the product of two lower rank matrices W and H so that V is approximately equal to W times H.
  • NMF uses an iterative procedure to modify the initial values of W and H so that the product approaches V. The procedure terminates when the approximation error converges or the specified number of iterations is reached
  • During model apply, an NMF model maps the original data into the new set of attributes (features) discovered by the model.

Real-life example: 

Let us consider some real-life examples to understand the working of the NMF algorithm. Let’s take a case of image processing. 

Suppose, we have an input image, having pixels that form matrix A. Using NMF, we factorize it into two matrices, one containing the facial feature set [Matrix W] and the other containing the importance of each facial feature in the input image, i.e. the weights [Matrix H]. (As shown in Fig 2.)

Fig 2 : NMF in Image Processing

NMF is used in major applications such as image processing, text mining, spectral data analysis and many more. Currently, there is an ongoing research on NMF to increase its efficiency and robustness. Other research is being done on collective factorization, efficient update of matrices etc. as well. For any doubt/query, comment below.


Previous Article
Next Article

Similar Reads

Handling Missing Values in Non-Negative Matrix Factorization (NMF)
Dealing with missing values is a common challenge in data preprocessing, especially when using algorithms like Non-Negative Matrix Factorization (NMF) in Python's scikit-learn library. NMF is a popular technique for dimensionality reduction, data compression, and feature extraction, but it does not natively handle missing values. In this article, w
6 min read
Probabilistic Matrix Factorization
Probabilistic Matrix Factorization (PMF) is a sophisticated technique in the realm of recommendation systems that leverages probability theory to uncover latent factors from user-item interaction data. PMF is particularly effective in scenarios where data is sparse, making it a powerful tool for delivering personalized recommendations. This article
6 min read
Implicit Matrix Factorization in NLP
Implicit matrix factorization is a technique in natural language processing (NLP) used to identify latent structures in word co-occurrence data. In this article, we will then delve into Pointwise Mutual Information (PMI), Positive Pointwise Mutual Information (PPMI), and Shifted PMI, and implement these techniques in Python for hands-on experience.
5 min read
Python - tensorflow.math.negative()
TensorFlow is open-source python library designed by Google to develop Machine Learning models and deep learning neural networks. negative() is used to find element wise negative value of x. Syntax: tf.math.negative(x, name) Parameter: x: It's the input tensor. Allowed dtype for this tensor are bfloat16, half, float32, float64, int32, int64, comple
2 min read
Necessity of Balancing Positive/Negative Examples in Binary Classification Machine Learning?
Answer: In this it is crucial to prevent model bias towards the majority class and ensure accurate predictions across both classes.In binary classification tasks within machine learning, the balance between positive and negative examples is paramount to the model's ability to accurately generalize and make predictions. An imbalance can lead to skew
2 min read
ML | Using SVM to perform classification on a non-linear dataset
Prerequisite: Support Vector Machines Definition of a hyperplane and SVM classifier: For a linearly separable dataset having n features (thereby needing n dimensions for representation), a hyperplane is basically an (n - 1) dimensional subspace used for separating the dataset into two sets, each set containing data points belonging to a different c
4 min read
ML | Non-Linear SVM
Support Vector Machine (SVM) is one of the powerful and versatile machine learning algorithms that can be used for various applications like classification, regression, and outlier detection. It is capable of handling both linear and nonlinear data by finding an optimal hyperplane or decision boundary that maximizes the margin between different cla
6 min read
Polynomial Regression for Non-Linear Data - ML
Non-linear data is usually encountered in daily life. Consider some of the equations of motion as studied in physics. Projectile Motion: The height of a projectile is calculated as h = -½ gt2 +ut +ho Equation of motion under free fall: The distance travelled by an object after falling freely under gravity for ‘t’ seconds is ½ g t2. Distance travell
5 min read
Difference between Hierarchical and Non Hierarchical Clustering
Hierarchical Clustering: Hierarchical clustering is basically an unsupervised clustering technique which involves creating clusters in a predefined order. The clusters are ordered in a top to bottom manner. In this type of clustering, similar clusters are grouped together and are arranged in a hierarchical manner. It can be further divided into two
2 min read
Difference between Linear Pipeline and Non-Linear Pipeline
1. Linear Pipeline : Linear pipeline is a pipeline in which a series of processors are connected together in a serial manner. In linear pipeline the data flows from the first block to the final block of processor. The processing of data is done in a linear and sequential manner. The input is supplied to the first block and we get the output from th
4 min read
Support Vector Regression (SVR) using Linear and Non-Linear Kernels in Scikit Learn
Support vector regression (SVR) is a type of support vector machine (SVM) that is used for regression tasks. It tries to find a function that best predicts the continuous output value for a given input value. SVR can use both linear and non-linear kernels. A linear kernel is a simple dot product between two input vectors, while a non-linear kernel
5 min read
Non Parametric Density Estimation Methods in Machine Learning
Non-parametric methods: Similar inputs have similar outputs. These are also called instance-based or memory-based learning algorithms. There are 4 Non - parametric density estimation methods: Histogram EstimatorNaive EstimatorKernel Density Estimator (KDE)KNN estimator (K - Nearest Neighbor Estimator)Histogram Estimator It is the oldest and the mos
5 min read
Non-Linear Regression in R
Non-Linear Regression is a form of regression analysis in which function models observational data is a nonlinear combination with non-linear parameters To perform non-linear regression in R, you can use various functions and packages, including 'nls', 'nlme', and 'mgcv'. You need to provide the equation of the model and the data, and the function
7 min read
Non-Probability sampling
In the realm of studies and facts collection, sampling techniques play a pivotal position in acquiring representative data without the want to survey an entire population. While probability sampling strategies like simple random sampling and stratified sampling are famous for his or her statistical rigor, non-possibility sampling techniques also ha
10 min read
How to become data scienctist if you are non cs student?
A data scientist is a person who does research part on projects to be able to process big data using the tools of technology, mathematics, business, and communications. Companies use this information in better decision-making, solving complex questions, and growing better. They are responsible for collecting, analyzing, and interpreting large and c
10 min read
Isomap | A Non-linear Dimensionality Reduction Technique
A nonlinear dimensionality reduction method used in data analysis and machine learning is called isomap, short for isometric mapping. Isomap was developed to maintain the inherent geometry of high-dimensional data as a substitute for conventional techniques like Principal Component Analysis (PCA). Isomap creates a low-dimensional representation, us
8 min read
Difference between Parametric and Non-Parametric Methods
Statistical analysis plays a crucial role in understanding and interpreting data across various disciplines. Two prominent approaches in statistical analysis are Parametric and Non-Parametric Methods. While both aim to draw inferences from data, they differ in their assumptions and underlying principles. This article delves into the differences bet
8 min read
How to add Non-Image Features alongside Images as the Input of CNNs?
Answer: To incorporate non-image features alongside images as input for Convolutional Neural Networks (CNNs), concatenate the flattened output from the convolutional layers with the vectorized non-image features before feeding them into the fully connected layers of the neural network.When integrating non-image features alongside images as input fo
2 min read
How to Remove Non-Stationarity in Time Series Forecasting
Removing non-stationarity in time series data is crucial for accurate forecasting because many time series forecasting models assume stationarity, where the statistical properties of the time series do not change over time. Non-stationarity can manifest as trends, seasonality, or other forms of irregular patterns in the data. The article comprehens
7 min read
Difference Between Autoregressive And Non-Autoregressive Models
In the realm of natural language processing (NLP) and time series analysis, two fundamental approaches for generating sequences are autoregressive (AR) models and non-autoregressive (NAR) models. Understanding the distinctions between these models is crucial for selecting the appropriate method for various applications. Table of Content Autoregress
5 min read
Can Degrees of Freedom be a Non-Integer Number in R?
Degrees of freedom (DF) are a fundamental concept in statistics, playing a crucial role in various analyses, including hypothesis testing, regression models, and the calculation of statistical distributions. They are traditionally viewed as whole numbers, but there are scenarios where degrees of freedom can take non-integer values. This article exp
4 min read
Handling Large Datasets Efficiently on Non-Super Computers
In today's data-driven world, the ability to handle and analyze large datasets is crucial for businesses, researchers, and data enthusiasts. However, not everyone has access to supercomputers or high-end servers. This article explores general techniques to work with huge amounts of data on a non-super computer, ensuring efficient processing and ana
5 min read
What is the Non-Parametric Equivalent of a Two-Way ANOVA in R?
In statistical analysis, when dealing with data that does not meet the assumptions required for parametric tests like the Two-Way ANOVA, researchers often turn to non-parametric equivalents. These alternatives do not assume normality or homogeneity of variances and are more flexible for various types of data. This article explores the non-parametri
4 min read
Linear vs. Non-linear Classification: Analyzing Differences Using the Kernel Trick
Classification is a fundamental task in machine learning, where the goal is to assign a class label to a given input. There are two primary approaches to classification: linear and non-linear. Support Vector Machines (SVMs) are a popular choice for classification tasks due to their robustness and effectiveness. SVMs can handle both linear and non-l
8 min read
What is the difference between Linear and non-linear filters?
Digital filters which include linear and non-linear filters play a major role in signal and image processing since they are capable of producing different results depending on their type. Linear filters take a linear mathematical operation that helps in removing noise, improving or extracting certain features from the signals or images and is very
7 min read
Difference between Parametric and Non-Parametric Models in Machine Learning
When it comes to statistical modeling and machine learning, parametric and non-parametric models represent two fundamental approaches, each with its strengths and suitability depending on the data and the problem at hand. In this article, we are going to explore parametric and non-parametric models along with the implementation and comparison betwe
9 min read
What is Non-Maximum Suppression?
Non-Maximum Suppression (NMS) is a critical technique used in object detection to refine and enhance the accuracy of detected objects. Accurate object detection is the ability to correctly identify and localize objects within an image or video stream can significantly enhance the performance and reliability of these systems. The article aims to pro
7 min read
How to Plot Non-Square Seaborn jointplot or JointGrid
Seaborn is a powerful visualization library in Python that builds on top of Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. One of the most commonly used plots in Seaborn is the jointplot, which allows for the visualization of bivariate distributions and their marginal distributions. Howev
4 min read
How to fix "R neuralNet: non-conformable arguments
When working with neural networks in R, especially using the neuralnet package, encountering the error "non-conformable arguments" can be frustrating. This error typically indicates a mismatch in the dimensions of matrices or vectors being used in the computation. This article will guide you through understanding the causes of this error and how to
4 min read
Non-Dominated Sorting Genetic Algorithm 2 (NSGA-II)
The Non-dominated Sorting Genetic Algorithm II (NSGA-II) is a widely used algorithm for multi-objective optimization. It is renowned for its efficiency in handling large populations and its ability to maintain diversity among solutions. NSGA-II utilizes a fast non-dominated sorting approach, elitism, and a crowding distance mechanism to ensure a we
10 min read
Article Tags :
Practice Tags :