0% found this document useful (0 votes)
11 views2 pages

Aiml Exp 3.1 Mean Median

The student performed an experiment to analyze a dataset containing iris flower measurements. The objective was to calculate and display the mean, median, mode, variance, and standard deviation of each feature in the dataset. The student imported necessary libraries, loaded the iris dataset, calculated the requested statistics for each column, and printed the results. This provided analysis of the central tendency and spread of values in the dataset.

Uploaded by

abbcs8544
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Aiml Exp 3.1 Mean Median

The student performed an experiment to analyze a dataset containing iris flower measurements. The objective was to calculate and display the mean, median, mode, variance, and standard deviation of each feature in the dataset. The student imported necessary libraries, loaded the iris dataset, calculated the requested statistics for each column, and printed the results. This provided analysis of the central tendency and spread of values in the dataset.

Uploaded by

abbcs8544
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

EXPERIMENT: 3.1

Student Name: VASU UID: 21BCS1452


Branch: CSE Section/Group: 617/A
Semester: 5th Date of Performance: 27/10/2023
Subject Name: ARTIFICIAL INTELLIGENCE Subject Code: 21CSH-316
& MACHINE LEARNING WITH LAB

Aim: Write a python program to compute Mean, Median, Mode, Variance and Standard
Deviation using Datasets.

Objective: The objective of this experiment is to analyse the given dataset.

Theory:
Mean: The average of a set of numbers calculated by adding them together and dividing by
the count of numbers.
Median: The middle value in a set of data when arranged in ascending order, or the average
of the two middle values for an even number of elements.
Mode: The value that appears most frequently in a set of data.
Variance: A measure of the spread or dispersion of values in a dataset around the mean.
Standard Deviation: A measure of the amount of variation or dispersion of a set of values
from the mean.

Algorithm:
1. Import the required libraries.
2. Load the iris dataset.
3. Calculate the mean, median, mode, variance and standard deviation.
4. Display the results.

Code:
import pandas as pd
import numpy as np
from scipy import stats

# Load the Iris dataset


url = "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"
column_names = ["sepal_length", "sepal_width", "petal_length", "petal_width", "class"]
iris_data = pd.read_csv(url, names=column_names)
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
# Calculate the mean for each feature
mean_values = iris_data.mean()
# Calculate the median for each feature
median_values = iris_data.median()
# Calculate the mode for each feature
mode_values = iris_data.mode().iloc[0] # Use the first mode in case of multiple modes
# Calculate the variance for each feature
variance_values = iris_data.var()
# Calculate the standard deviation for each feature
std_deviation_values = iris_data.std()

# Display the results


print("Mean:")
print(mean_values)
print("\nMedian:")
print(median_values)
print("\nMode:")
print(mode_values)
print("\nVariance:")
print(variance_values)
print("\nStandard Deviation:")
print(std_deviation_values)

Observation and outcomes:


1. I learned about how to load an iris dataset.
2. I learned about how to calculate mean, median, mode, variance and standard deviation.
3. I learned about how to display these values.

You might also like