Tutorial 1
Tutorial 1
Tutorial 1
• Perform element-wise multiplication of arr1 and arr2 and store the result in a
new array.
• Calculate the square root of all elements in arr1 and store the result in a new
array.
• Add 5 to each element in arr2 in place (modify arr2).
1
Machine Learning
Exercise 6: Statistical Analysis
Create a NumPy array containing 100 random values sampled from a normal
distribution with mean 5 and standard deviation 2. Perform the following statistical
analysis:
Exercise 7: Broadcasting
• Create a NumPy array array_a of shape (3, 3) and another array array_b of
shape (3, 1). Use broadcasting to add array_b to each column of array_a.
*************************************************************************************
Exercise 1: Subplots
• Create a figure with two subplots: one for a line plot and another for a scatter
plot.
• Use different datasets for each subplot and customize their appearance.
• Add labels, titles, and legends for each subplot.
• After creating any of the above plots, save it as an image file (e.g., PNG or
PDF) using Matplotlib's savefig function.
• Specify the file name, resolution, and other options as needed.
2
Machine Learning
Exercice 4 :
*************************************************************************************
You are given a dataset containing daily temperature readings for a city over a
month. Your task is to create a line plot to visualize the temperature changes
throughout the month.
Dataset:
temperatures = [28, 29, 30, ..., 32] # Maximum temperatures for each date
Requirements:
1. Create a line plot using Matplotlib to show the maximum temperatures over
the course of the month. The x-axis should represent the dates, and the y-axis
should represent the temperatures.
2. Customize the appearance of the plot:
• Use a blue line for the temperature curve.
• Add labels for the x-axis ("Date") and y-axis ("Temperature (°C)").
• Set a title for the plot ("Monthly Temperature Variation").
3
Machine Learning
• Add grid lines to the plot.
3. Highlight specific points on the plot:
• Mark the highest temperature point with a red circle marker.
• Mark the lowest temperature point with a green triangle marker.
4. Include a legend indicating the meaning of the markers.
5. Save the plot as an image file named "temperature_variation.png."
Optional :
Add a second line to the plot to represent the minimum daily temperatures for each
date in a different color (e.g., red). Adjust the legend accordingly.
You are given a CSV file ("sales_data.csv") containing sales data for a retail store. The
data includes information about products, sales quantities, prices, and dates.
Tasks:
Optional :
4
Machine Learning
In this exercise, you will work with historical stock price data, perform data analysis
using Pandas and NumPy, and create visualizations using Matplotlib.
Dataset:
You are provided with a CSV file named "stock_prices.csv" containing historical
stock price data for a specific company. The dataset has the following columns:
Tasks:
Optional: