DEV Manual - ESEC
DEV Manual - ESEC
AIM:
To write a steps to install data Analysis and Visualization tool: R/ Python /Tableau Public/ Power BI.
PROCEDURE:
R:
R is a programming language and software environment specifically designed for statistical
computing and graphics.
Windows:
Download R from the official website: https://cran.r-project.org/mirrors.html
Run the installer and follow the installation instructions.
macOS:
Download R for macOS from the official website: https://cran.r-project.org/mirrors.html
Open the downloaded file and follow the installation instructions.
Linux:
You can typically install R using your distribution's package manager. For example, on Ubuntu, you
can use the following command:
csharp
Copy code
sudo apt-get install r-base
Python:
Python is a versatile programming language widely used for data analysis. You can install Python
and data analysis libraries using a package manager like conda or pip.
Windows:
Download Python from the official website: https://www.python.org/downloads/windows/
Run the installer, and make sure to check the "Add Python to PATH" option during installation.
You can install data analysis libraries like NumPy, pandas, and matplotlib using pip.
macOS:
macOS typically comes with Python pre-installed. You can install additional packages using pip or
set up a virtual environment using Ana
conda.
Linux:
Python is often pre-installed on Linux. Use your distribution's package manager to install Python if
it's not already installed. You can also use conda or pip to manage Python packages.
Tableau Public:
Tableau Public is a free version of Tableau for creating and sharing interactive data visualizations.
Go to the Tableau Public website: https://public.tableau.com/s/gallery
Download and install Tableau Public by following the instructions on the website.
Power BI:
Power BI is a business analytics service by Microsoft for creating interactive reports and dashboards.
Go to the Power BI website: https://powerbi.microsoft.com/en-us/downloads/
Download and install Power BI Desktop, which is the tool for creating reports and dashboards.
Please note that the installation steps may change over time, so it's a good idea to check the official
websites for the most up-to-date instructions and download links. Additionally, system requirements
may vary, so make sure your computer meets the necessary specifications for these tools.
Ex no: 2
Date: Exploratory Data Analysis (EDA) on with Datasets
Aim:
To Perform exploratory data analysis (EDA) on with datasets like email data set.
Procedure:
Exploratory Data Analysis (EDA) on email datasets involves importing the data, cleaning it, visualizing
it, and extracting insights. Here's a step-by-step guide on how to perform EDA on an email dataset using
Python and Pandas
1. Import Necessary Libraries:
Import the required Python libraries for data analysis and visualization.
2. Load Email Data:
Assuming you have a folder containing email files (e.g., .eml files), you can use the email library to
parse and extract the email contents.
3. Data Cleaning:
Depending on your dataset, you may need to clean and preprocess the data. Common
cleaning steps include handling missing values, converting dates to datetime format, and removing
duplicates.
4. Data Exploration:
Now, you can start exploring the dataset using various techniques. Here are some common EDA
tasks:
Basic Statistics:
Get summary statistics of the dataset.
Distribution of Dates:
Visualize the distribution of email dates.
5. Word Cloud for Subject or Message:
Create a word cloud to visualize common words in email subjects or messages.
6. Top Senders and Recipients:
Find the top email senders and recipients.
Depending on your dataset, you can explore further, analyze sentiment, perform network analysis, or
any other relevant analysis to gain insights from your email data.
Program:
# Import necessary libraries
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
# Load the dataset
df = pd.read_csv('D:\ARCHANA\dxv\LAB\DXV\Emaildataset.csv')
# Display basic information about the dataset
print(df.info())
# Display the first few rows of the dataset
print(df.head())
# Descriptive statistics
print(df.describe())
# Check for missing values
print(df.isnull().sum())
# Visualize the distribution of numerical variables
sns.pairplot(df)
plt.show()
# Visualize the distribution of categorical variables
sns.countplot(x='label', data=df)
plt.show()
# Correlation matrix for numerical variables
correlation_matrix = df.corr()
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm')
plt.show()
# Word cloud for text data (if you have a column with text data)
from wordcloud import WordCloud
text_data = ' '.join(df['text_column'])
wordcloud = WordCloud(width=800, height=400, random_state=21,
max_font_size=110).generate(text_data)
plt.figure(figsize=(10, 7))
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis('off')
plt.show()
OUTPUT:
Data columns (total 4 columns):
# Column Non-Null Count Dtype
Aim:
To write the steps for Working with Numpy arrays, Pandas data frames , Basic plots using Matplotlib
Procedure:
1. NumPy:
NumPy is a fundamental library for numerical computing in Python. It provides support for multi-
dimensional arrays and various mathematical functions. To get started, you'll first need to install NumPy if
you haven't already (you can use pip):
df = pd.DataFrame(data)
# Display the entire DataFrame
print("DataFrame:")
print(df)
# Accessing specific columns
print("\nAccessing 'Name' column:")
print(df['Name'])
# Adding a new column
df['Salary'] = [50000, 60000, 75000, 48000, 55000]
# Filtering data
print("\nPeople older than 30:")
print(df[df['Age'] > 30])
# Sorting by a column
print("\nSorting by 'Age' in descending order:")
print(df.sort_values(by='Age', ascending=False))
# Aggregating data
print("\nAverage age:")
print(df['Age'].mean())
# Grouping and aggregation
grouped_data = df.groupby('City')['Salary'].mean()
print("\nAverage salary by city:")
print(grouped_data)
# Applying a function to a column
df['Age_Squared'] = df['Age'].apply(lambda x: x ** 2)
# Removing a column
df = df.drop(columns=['Age_Squared'])
# Saving the DataFrame to a CSV file
df.to_csv('output.csv', index=False)
# Reading a CSV file into a DataFrame
new_df = pd.read_csv('output.csv')
print("\nDataFrame from CSV file:")
print(new_df)
OUTPUT:
3. Matplotlib:
Matplotlib is a popular library for creating static, animated, or interactive plots and graphs.
Install Matplotlib using pip:
pip install matplotlib
Here's a simple example of creating a basic plot:
import matplotlib.pyplot as plt
# Sample data
x = np.linspace(0, 10, 100)
y = np.sin(x)
# Create a line plot
plt.figure(figsize=(8, 6))
plt.plot(x, y, label='Sine Wave')
plt.title('Sine Wave Plot')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.legend()
plt.grid(True)
plt.show()
OUTPUT:
RESULT:
Thus the above working with numpy, pandas, matplotlib has been completed successfully.
Ex no:4
Date: Exploring various variable and row filters in R for cleaning data
Aim:
To explore various variable and row filters in R for cleaning data.
PROCEDURE:
Data Preparation and Cleaning
First, let's create a sample dataset and then explore various variable and row filters to clean the data
PROGRAM:
# Create a sample dataset
set.seed(123)
data <- data.frame(
ID = 1:10,
Age = sample(18:60, 10, replace = TRUE),
Gender = sample(c("Male", "Female"), 10, replace = TRUE),
Score = sample(1:100, 10)
)
# Print the sample data
print(data)
OUTPUT:
Variable Filters
1. Filtering by a Specific Value:
To filter rows based on a specific value in a variable (e.g., only show rows where Age is greater than
30):
filtered_data <- data[data$Age > 30, ]
2. Filtering by Multiple Conditions:
You can filter rows based on multiple conditions using the & (AND) or | (OR) operators (e.g., show
rows where Age is greater than 30 and Gender is "Male"):
filtered_data <- data[data$Age > 30 & data$Gender == "Male", ]
Row Filters
1. Removing Duplicate Rows:
To remove duplicate rows based on certain columns (e.g., remove duplicates based on 'ID'):
cleaned_data <- unique(data[, c("ID", "Age", "Gender")])
2. Removing Rows with Missing Values:
To remove rows with missing values (NA):
cleaned_data <- na.omit(data)
Data Visualization
1. Apply various plot features using the ggplot2 package to visualize the cleaned data.
# Load the ggplot2 package
library(ggplot2)
# Create a scatterplot of Age vs. Score with points colored by Gender
ggplot(data = cleaned_data, aes(x = Age, y = Score, color = Gender)) +
geom_point() +
labs(title = "Scatterplot of Age vs. Score",
x = "Age",
y = "Score")
# Create a histogram of Age
ggplot(data = cleaned_data, aes(x = Age)) +
geom_histogram(binwidth = 5, fill = "blue", alpha = 0.5) +
labs(title = "Histogram of Age",
x = "Age",
y = "Frequency")
# Create a bar chart of Gender distribution
ggplot(data = cleaned_data, aes(x = Gender)) +
geom_bar(fill = "green", alpha = 0.7) +
labs(title = "Gender Distribution",
x = "Gender",
y = "Count")
RESULT:
Thus various variable and row filters in R for cleaning data were explored successfully.
EXNO: 5 PERFORM EDA ON WINE QUALITY DATA SET.
DATE
AIM:
To write a program to Perform EDA on Wine Quality Data Set.
PROGRAM:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Load the dataset
data = pd.read_csv("pathname")
# Display the first few rows of the dataset
print(data.head())
# Get information about the dataset
print(data.info())
# Summary statistics
print(data.describe())
# Distribution of wine quality
sns.countplot(data['quality'])
plt.title(" Wine Quality data set")
plt.show()
# Box plots for selected features by wine quality
features = ['alcohol', 'volatile acidity', 'citric acid', 'residual sugar']
for feature in features:
plt.figure(figsize=(8, 6))
sns.boxplot(x='quality', y=feature, data=data)
plt.title(f'{feature} by Wine Quality')
plt.show()
# Pair plot of selected features
sns.pairplot(data, vars=['alcohol', 'volatile acidity', 'citric acid', 'residual sugar'],
hue='quality', diag_kind='kde')
plt.suptitle("Pair Plot of Selected Features")
plt.show()
# Correlation heatmap
corr_matrix = data.corr()
plt.figure(figsize=(10, 8))
sns.heatmap(corr_matrix, annot=True, cmap="coolwarm", fmt=".2f")
plt.title("Correlation Heatmap")
plt.show()
# Histograms of selected features
features = ['alcohol', 'volatile acidity', 'citric acid', 'residual sugar']
for feature in features:
plt.figure(figsize=(6, 4))
sns.histplot(data[feature], kde=True, bins=20)
plt.title(f"Distribution of {feature}")
plt.show()
OUTPUT:
RESULT:
Thus the above program to perform EDA on Wine Quality Data Set was executed successfully.
EX NO:6
DATE: TIME SERIES ANALYSIS USING VARIOUS VISULAIZATION
TECHNIQUES
AIM:
To perform time series analysis and apply the various visualization techniques.
DOWNLOADING DATASET:
Step 1: Open google and type the following path in the address bar and download a dataset.
http://github.com/jbrownlee/Datasets.
Step 2: Write the following code to get the details.
from pandas import read_csv
from matplotlib import pyplot
series=read_csv(‘pathname')
print(series.head())
series.plot()
pyplot.show()
OUTPUT:
Step 3: To get the time series line plot:
series.plot(style='-.')
pyplot.show()
Step 4:
To create a Histogram:
series.hist()
pyplot.show()
Step 5:
To create density plot:
series.plot(kind='kde')
pyplot.show()
RESULT:
Thus the above time analysis has been checked with various visualization techniques.
EX NO: 7
DATE: DATA ANALYSIS AND REPRESENTATION ON A MAP
AIM:
To write a program to perform data analysis and representation on a map using various map data
sets with mouse rollover effect, user interaction.
PROCEDURE:
STEP 1:
Make sure to install the necessary libraries.
pip install geopandas folium bokeh
PROGRAM:
from bokeh.io import show
from bokeh.models import ColumnDataSource, HoverTool
from bokeh.plotting import figure
from bokeh.layouts import column
import pandas as pd
import folium
# Load your data
data = pd.read_csv('D:\ARCHANA\dxv\LAB\DXV\geographic.csv')
# Create a Bokeh figure
p = figure(width=800, height=400, tools='pan,wheel_zoom,reset')
# Create a ColumnDataSource to hold data
source = ColumnDataSource(data)
# Add circle markers to the figure
p.circle(x='Longitude', y='Latitude', size=10, source=source, color='orange')
# Create a hover tool for mouse rollover effect
hover = HoverTool()
hover.tooltips = [("Info", "@Info"), ("Latitude", "@Latitude"), ("Longitude",
"@Longitude")]
p.add_tools(hover)
# Display the Bokeh plot
layout = column(p)
show(layout)
# Create a map centered at a specific location
m = folium.Map(location=[latitude, longitude], zoom_start=10)
# Add markers for your data points
for index, row in data.iterrows():
folium.Marker(
location=[row['Latitude'], row['Longitude']],
popup=row['Info'], # Display additional info on mouse click
).add_to(m)
# Save the map to an HTML file
m.save('map.html')
OUPUT:
RESULT:
Data analysis and representation on a map using various map data sets with mouse rollover effect,
user interaction has been completed successfully.
EX NO: 8
DATE: BUILDING CARTOGRAPHIC VISUALIZATION
AIM:
Build cartographic visualization for multiple datasets involving various countries of the world;
states and districts in India etc
PROCEDURE:
STEP 1:
Collect Datasets
Gather the datasets containing geographical information for countries, states, or districts. Make sure these
datasets include the necessary attributes for mapping (e.g., country/state/district names, codes, and
relevant data).
STEP 2:
Install Required Libraries:
pip install geopandas matplotlib
STEP 3:
Load Geographic Data:
Use Geopandas to load the geographic data for countries, states, or districts. Make sure to match the
geographical data with your datasets based on the common attributes.
STEP 4:
Merge Datasets:
Merge your datasets with the geographic data based on common attributes. This step is crucial for linking
your data to the corresponding geographic regions.
STEP 5:
Create Cartographic Visualizations:
Use Matplotlib to create cartographic visualizations. You can create separate plots for different datasets
or overlay them on a single map.
STEP 6:
Customize and Enhance:
Customize your visualizations based on your needs. You can add legends, labels, titles, and other
elements to enhance the interpretability of your maps.
STEP 7:
Save and Share:
Save your visualizations as image files or interactive plots if needed. You can then share these
visualizations with others.
PROGRAM:
import pandas as pd
import geopandas as gpd
import shapely
# needs 'descartes'
import matplotlib.pyplot as plt
df = pd.DataFrame({'city': ['Berlin', 'Paris', 'Munich'],
'latitude': [52.518611111111, 48.856666666667, 48.137222222222],
'longitude': [13.408333333333, 2.3516666666667, 11.575555555556]})
gdf = gpd.GeoDataFrame(df.drop(['latitude', 'longitude'], axis=1),
crs={'init': 'epsg:4326'},
geometry=[shapely.geometry.Point(xy)
for xy in zip(df.longitude, df.latitude)])
print(gdf)
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
base = world.plot(color='white', edgecolor='black')
gdf.plot(ax=base, marker='o', color='red', markersize=5)
plt.show()
OUTPUT:
city geometry
0 Berlin POINT (13.40833 52.51861)
1 Paris POINT (2.35167 48.85667)
2 Munich POINT (11.57556 48.13722)
RESULT:
Thus cartographic visualization for multiple datasets involving various countries of the world;
has been built and visualized successfully.
EX NO :9
DATE: VISUALIZING VARIOUS EDA TECHNIQUES AS CASE STUDY FOR
IRIS DATASET
AIM:
Use a case study on a data set and apply the various EDA and visualization techniques and
present an analysis report.
PROCEDURE:
Import Libraries:
Start by importing the necessary libraries and loading the dataset.
Descriptive Statistics:
Compute and display descriptive statistics.
python
Check for Missing Values:
Verify if there are any missing values in the dataset.
Visualize Data Distributions:
Visualize the distribution of numerical variables.
python
Correlation Heatmap:
Examine the correlation between numerical variables.
Boxplots for Categorical Variables:
Use boxplots to visualize the distribution of features by species.
Violin Plots:
Combine box plots with kernel density estimation for better visualization.
Correlation between Features:
Visualize pair-wise feature correlations.
Conclusion and Summary:
Summarize key findings and insights from the analysis.
RESULT:
This case study provides a comprehensive analysis of the Iris dataset, including data exploration,
descriptive statistics, visualization of data distributions, correlation analysis, and feature-specific
visualizations.