13 Oct Machine Learning – Mode
Mode is used to get the most common value. It is a useful measure of central tendency because it finds the value that occurs most frequently in a dataset.
The “mode” is the most common value in a dataset. It is calculated by finding the value that occurs most frequently in the dataset.
Mode is not preferred when:
- The dataset has a wide range of value
- The dataset has no repeating values.
Note: The Mode is the most common value
Let us see an example. To calculate the mode in Python, we will use the mode() method. We will use the Pandas library to create a Pandas DataFrame. The Pandas DataFrame is a Two-dimensional tabular data structure i.e. table with rows and columns.
Read: Free Pandas Tutorial
We will also add some repeating values to the dataset.
The following is the Python code to get the mode:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import numpy as np import pandas as pd # create a pandas dataframe marks = pd.DataFrame({ 'student_rollno': ['0001', '0002', '0003', '0004', '0005', '0006', '0007', '0008', '0009', '0010'], 'student_marks': [96, 83, 90, 87, 67, 60, 75, 90, 77, 70] }) # get the mode mode_marks = marks['student_marks'].mode()[0] print('Mode marks of students:', mode_marks) |
The following is the output:
1 2 3 |
Mode marks of students: 90 |
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
- What is Machine Learning
- What is a Machine Learning Model
- Types of Machine Learning
- Supervised vs Unsupervised vs Reinforcement Machine Learning
- What is Deep Learning
- Feedforward Neural Networks (FNN)
- Convolutional Neural Network (CNN)
- Recurrent Neural Networks (RNN)
- Long short-term memory (LSTM)
- Generative Adversarial Networks (GANs)
No Comments