How to compute the min-by-max for each row for a numpy array 2d?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

# How to compute the min-by-max for each row for a numpy array 2d?

This recipe helps you compute the min-by-max for each row for a numpy array 2d

0

## Recipe Objective

How to compute the min-by-max for each row for a numpy array 2d? We can find the minimum and maximum values from the each row of a 2D numpy array by using the "min" and "max" functions available in the Numpy library.

## Step 1 - Import the library

``` import numpy as np ```

## Step 2 - Take a Sample array

``` Sample_array = np.array([[1,2,33],[4,5,6],[7,8,9]]) print("This is a Sample array:","\n",Sample_array) ```
```This is a Sample array:
[[ 1  2 33]
[ 4  5  6]
[ 7  8  9]]```

## Step 3 - find minimum and maximum

``` print("The minimum value from each row is:","\n",np.min(Sample_array, axis=1),"\n") print("The maximum value from each row is:","\n",np.max(Sample_array, axis=1)) ```
```The minimum value from each row is:
[1 4 7]

The maximum value from each row is:
[33  6  9]```

#### Relevant Projects

##### Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

##### Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

##### 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.

##### Demand prediction of driver availability using multistep time series analysis
In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

##### NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

##### 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.

##### Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

##### 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.

##### 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.

##### 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.