How to Calculate Mean, Variance and Std of a Matrix or ndArray?
DATA MUNGING DATA CLEANING PYTHON MACHINE LEARNING RECIPES PANDAS CHEATSHEET     ALL TAGS

How to Calculate Mean, Variance and Std of a Matrix or ndArray?

How to Calculate Mean, Variance and Std of a Matrix or ndArray?

This recipe helps you Calculate Mean, Variance and Std of a Matrix or ndArray

0

Recipe Objective

Statical analysis is very important part preprocessing. Have you tried to do it for matrix?

So this is the recipe on how we can can Calculate Mean, Variance and Std a Matrix or ndArray.

Step 1 - Importing Library

import numpy as np

We have only imported numpy which is needed.

Step 2 - Creating a matrix

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

Step 3 - Finding Mean, Median, Variance and Standard Deviation

We have calculated mean, median , variance and standard deviation by using numpy functions for a matrix. print("Median: ", np.median(matrixA)) print("Mean: ", np.mean(matrixA)) print("Variance: ", np.var(matrixA)) print("Standrad Dev: ", np.std(matrixA)) So the output comes as

Median:  8.5

Mean:  12.1875

Variance:  118.27734375

Standrad Dev:  10.875538779757076

Relevant Projects

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.

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.

Build an Image Classifier for Plant Species Identification
In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

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.

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.

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.

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.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.