ML-LAB-VI-SEM

Exercise 02

Study of Python Libraries for ML Applications such as Pandas and Matplotlib

Aim

To explore and experiment with Python libraries Pandas and Matplotlib, which are commonly used in Machine Learning applications.

Procedure/Program

Pandas Example:

import pandas as pd

# sample dataset
data = {
    "Name": ["Alice", "Bob", "Charlie", "David"],
    "Age": [25, 30, 35, 40],
    "Salary": [50000, 60000, 70000, 80000]
}

# DataFrame
df = pd.DataFrame(data)

print("DataFrame:\n", df)

# basic operations
print("\nDescriptive Statistics:\n", df.describe())
print("\nSelecting Age Column:\n", df["Age"])
print("\nFiltering Rows where Age > 30:\n", df[df["Age"] > 30])

Matplotlib Example:

import matplotlib.pyplot as plt

# sample data
names = ["Alice", "Bob", "Charlie", "David"]
salaries = [50000, 60000, 70000, 80000]

# bar chart
plt.bar(names, salaries, color=['blue', 'orange', 'green', 'red'])
plt.xlabel("Employees")
plt.ylabel("Salary")
plt.title("Employee Salary Chart")
plt.show()

Output/Explanation