How to find Maximum and Minimum values in a Matrix?

How to find Maximum and Minimum values in a Matrix?

How to find Maximum and Minimum values in a Matrix?

This recipe helps you find Maximum and Minimum values in a Matrix


Recipe Objective

Have you ever tried to find maximum and minimum value in matrix? So lets see how we can do this.

So this is the recipe on how we can find Maximum and Minimum values in a Matrix.

Step 1 - Import the library

import numpy as np

We have only imported numpy which is needed.

Step 2 - Setting up the Matrix

We have created a 4 x 4 matrix using array. matrix_101 = np.array([[10, 11, 12, 23], [4, 5, 6, 25], [7, 8, 9, 28], [1, 2, 3, 41]])

Step 3 - Finding Maximum and Minimum Value

We can find the maximum and minimum values by using the function max and min respectively. We can also pass axis as a parameter which will help us to find maximum or minimum values of every rows and column. print(np.max(matrix_101)) print(); print(np.min(matrix_101)) print(np.max(matrix_101, axis=0)) print(); print(np.max(matrix_101, axis=1)) So the output comes as



[10 11 12 41]

[23 25 28 41]

Relevant Projects

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

Build a Collaborative Filtering Recommender System in Python
Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.