How to find Maximum and Minimum values in a Matrix?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

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

0

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

41

1

[10 11 12 41]

[23 25 28 41]

Relevant Projects

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

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.

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

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.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.