Data Visualization using different Python libraries .pptx

HamzaAli998966 28 views 54 slides Sep 24, 2024
Slide 1
Slide 1 of 54
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54

About This Presentation

Data Visualization using different Python libraries


Slide Content

Data Visualization using different Python libraries (e.g., pandas, NumPy, matplotlib) Hamza ali MSCS

What is Data Visualization? Introduction to Data Visualization Definition: "Field in data analysis, visually represents data." Purpose: "Effectively communicates inferences through graphics." Benefit : "Provides a quick visual summary of data." Tools: "Utilizes pictures, maps, and graphs." Advantage : "Easier processing and understanding for the human mind." Application: "Applicable to both small and large data sets." Challenge : "Impossible manual processing for large data sets ."

Data Visualization in Python Python offers several plotting libraries, namely  Matplotlib ,  Seaborn  and many other such data visualization packages with different features for creating informative, customized, and appealing plots to present data in the most simple and effective way.

Matplotlib and Seaborn Matplotlib and Seaborn are  python libraries  that are used for data visualization. They have inbuilt modules for plotting different graphs . Matplotlib is used to embed graphs into applications . Seaborn is primarily used for statistical graphs .

Line Charts A Line chart is a graph that represents information as a series of data points connected by a straight line . In line charts, each data point or marker is plotted and connected with a line or curve.  Let's consider the apple yield (tons per hectare) in Kanto. Let's plot a line graph using this data and see how the yield of apples changes over time. We start by importing Matplotlib and Seaborn .

Using Matplotlib We are using random data points to represent the yield of apples .

To better understand the graph and its purpose, we can add the x-axis values too .

Let's add labels to the axes so that we can show what each axis represents .

. To plot multiple datasets on the same graph, just use the plt.plot function once for each dataset. Let's use this to compare the yields of apples vs. oranges on the same graph .

We can add a legend which tells us what each line in our graph means. To understand what we are plotting, we can add a title to our graph .

To show each data point on our graph, we can highlight them with markers using the marker argument. Many different marker shapes like a circle, cross, square, diamond, etc. are provided by Matplotlib .

You can use the plt.figure function to change the size of the figure .

Using Seaborn An easy way to make your charts look beautiful is to use some default styles from the Seaborn library. These can be applied globally using the sns.set_style function .

We can also use the darkgrid option to change the background color to a darker shade

Bar Graphs Categorical Data Representation: Utilize bar graphs for effective representation. Y-axis: Represents values; X-axis: Represents categories. Axis Interpretation: Y-axis reflects numerical data values. X-axis denotes categorical data labels. Data-Category Relationship: Bars visually linked to specific categories. Offers clear representation of data distribution. Effective Communication: Facilitates easy communication of categorical data. Provides quick understanding . Flexibility for Categorical Data: Applicable to various types of categorical data. Enables easy comparison between different categories.

Plotting Bar graphs

We can also stack bars on top of each other. Let's plot the data for apples and oranges

Plotting averages of each bar We can draw a bar chart to visualize how the average bill amount varies across different days of the week. We can do this by computing the day-wise averages and then using plt.bar . The Seaborn library also provides a barplot function that can automatically compute averages .

Plotting multiple bar graphs If you want to compare bar plots side-by-side, you can use the hue argument. The comparison will be done based on the third feature specified in this argument .

Plotting horizontal bar graphs You can make the bars horizontal by switching the axes .

Histograms Histogram Overview: Utilizes bars to represent data variation across a range. Y-axis indicates data frequency, while the X-axis shows value ranges. Bars represent data quantities within specific value ranges .

Iris dataset  Let's again use the ‘Iris’ data which contains information about flowers to plot histograms .

Plotting histograms  Now, let’s plot a histogram using the hist () function .

Changing number of bins We can control the number or size of bins too

Changing number and size of bins We can change the number and size of bins using numpy too .

Bins of unequal size We can create bins of unequal size too .

Multiple histograms Similar to line charts, we can draw multiple histograms in a single chart. We can reduce each histogram's opacity so that one histogram's bars don't hide the others'. Let's draw separate histograms for each species of flowers .

Stacking histograms Multiple histograms can be stacked on top of one another by setting the stacked parameter to True .

📊 Stock Market Analysis 📈 + Prediction using LSTM   Tesla Stock Price ,  S&P 500 stock data ,  AMZN, DPZ, BTC, NTFX adjusted May 2013-May2019  + 1 Data Project - Stock Market Analysis

Time Series data Time Series data is a series of data points indexed in time order. We will discover and explore data from the stock market, particularly some technology stocks (Apple, Amazon, Google, and Microsoft). We will learn how to use yfinance to get stock information, and visualize different aspects of it using Seaborn and Matplotlib . We will also be predicting future stock prices through a Long Short Term Memory (LSTM) method!

We'll be answering the following questions along the way 1.) What was the change in price of the stock over time 2 .) What was the daily return of the stock on average 3 .) What was the moving average of the various stocks 4 .) What was the correlation between different stocks 5 .) How much value do we put at risk by investing in a particular stock 6.) How can we attempt to predict future stock behavior (Predicting the closing price stock price of APPLE inc using LSTM)

Getting the Data The first step is to get the data and load it to memory . We will get our stock data from the Yahoo Finance website . Yahoo Finance is a rich resource of financial market data and tools to find compelling investments. To get the data from Yahoo Finance, we will be using yfinance library which offers a threaded and Pythonic way to download market data from Yahoo.

What was the change in price of the stock overtime? In this section we'll go over how to handle requesting stock information with pandas, and how to analyze basic attributes of a stock .

What was the change in price of the stock overtime? https://www.kaggle.com/code/faressayah/stock-market-analysis-prediction-using-lstm?scriptVersionId=117825740&cellId=5

OUTput

Descriptive Statistics about the Data .describe() generates descriptive statistics. Descriptive statistics include those that summarize the central tendency, dispersion, and shape of a dataset’s distribution, excluding  NaN  values . Analyzes both numeric and object series, as well as  DataFrame  column sets of mixed data types. The output will vary depending on what is provided. Refer to the notes below for more detail.

Descriptive Statistics about the Data We have only 255 records in one year because weekends are not included in the data

Information About the Data .info() method prints information about a DataFrame including the index  dtype  and columns, non-null values, and memory usage .

Closing Price The closing price is the last price at which the stock is traded during the regular trading day. A stock’s closing price is the standard benchmark used by investors to track its performance over time .

Closing Price

Volume of Sales Volume is the amount of an asset or security that changes hands over some period of time, often over the course of a day. For instance, the stock trading volume would refer to the number of shares of security traded between its daily open and close. Trading volume, and changes to volume over the course of time, are important inputs for technical traders .

Volume of Sales

What was the moving average of the various stocks ?

  What was the daily return of the stock on average ?

What was the moving average of the various stocks ?

  What was the daily return of the stock on average ?

  What was the correlation between different stocks closing prices ?

Output

How much value do we put at risk by investing in a particular stock?

How much value do we put at risk by investing in a particular stock?

Predicting the closing price stock price of APPLE inc :

Predicting the closing price stock price of APPLE inc :

Thank You
Tags