Docsity

BASICS OF DATA ANALYTICS, Study notes of Data Analysis & Statistical Methods

Toggle sidebar
bg1
BASICS OF DATA ANALYTICS
BDA โ€” Complete Notes
Prof. Dweepobotee Brahma
Weeks 1โ€“13
WEEK 1 โ€” Introduction to Data Analytics
โ€ข Privacy is the main key of Data
Data Types
โ€ข Continuous & Discrete
โ€ข Nominal
โ€ข Ordinal
Data Storage
โ€ข Databases โ†’ Small (like a small fridge)
โ€ข Data Warehouses โ†’ Large (like a pantry)
โ€ข Data Lakes โ†’ Huge (like a reservoir)
Gathering Data
โ€ข Querying Databases โ†’ Asking
โ€ข API โ†’ Application Programming Interface
โ€ข Web Scraping โ†’ Collecting
Data Cleaning
โ€ข Remove Duplicates
โ€ข Handle Missing Data
โ€ข Fix Errors
โ€ข Correct Inconsistencies
WEEK 2 โ€” Data Analytics Process
โ€ข There is too much information i.e. Data!
Data Analytics Process
Data Analytics โ†’ Gathering โ†’ Cleaning โ†’ Organizing โ†’ Analyzing
Objective: To find patterns & insights in Data!
Steps:
โ€ข 1. Gathering โ†’ Various sources: APIs, Online portals, etc.
โ€ข 2. Cleaning & Organizing โ†’ Removing errors, duplicates, inconsistencies
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download BASICS OF DATA ANALYTICS and more Study notes Data Analysis & Statistical Methods in PDF only on Docsity!

BASICS OF DATA ANALYTICS

BDA โ€” Complete Notes

Prof. Dweepobotee Brahma

Weeks 1โ€“ 13

WEEK 1 โ€” Introduction to Data Analytics

  • Privacy is the main key of Data

Data Types

  • Continuous & Discrete
  • Nominal
  • Ordinal

Data Storage

  • Databases โ†’ Small (like a small fridge)
  • Data Warehouses โ†’ Large (like a pantry)
  • Data Lakes โ†’ Huge (like a reservoir)

Gathering Data

  • Querying Databases โ†’ Asking
  • API โ†’ Application Programming Interface
  • Web Scraping โ†’ Collecting

Data Cleaning

  • Remove Duplicates
  • Handle Missing Data
  • Fix Errors
  • Correct Inconsistencies

WEEK 2 โ€” Data Analytics Process

  • There is too much information i.e. Data!

Data Analytics Process

Data Analytics โ†’ Gathering โ†’ Cleaning โ†’ Organizing โ†’ Analyzing Objective: To find patterns & insights in Data!

Steps:

  • 1. Gathering โ†’ Various sources: APIs, Online portals, etc.
  • 2. Cleaning & Organizing โ†’ Removing errors, duplicates, inconsistencies
  • 3. Analyzing โ†’ Identify Trends/Patterns, Create Data Visualization, Using AI to forecast โ†’ Descriptive Analysis
  • 4. Interpreting โ†’ Presenting the insights, Using Data Visualization โ†’ Conveying the Analysis (understandable)

Who Uses Data Analytics?

Sector Uses Business Analyze past performance, Pros & Cons, Informed Decisions Manufacturing Manage supply chain, Manage Inventory, Allocating Working Retail Buying patterns, Identify popular items, Launch new products Healthcare Analyze Disease Prevalence, Monitor outbreak, Analyze prescriptions, Create new drugs Banking Monitor discrepancies, Predict Fraud, Patterns in spending, New type of credit card Education Patterns from results, Track essential skills Humans use data to make decisions in their life! WEEK 3 โ€” Roles, Tools & Types of Analytics

Responsibilities of Data Analysts

  • Acquiring, Collecting & Gathering Data
  • Extract Relevant Data
  • Filtering, Cleaning, Sorting & Organizing Data
  • Descriptive Analysis
  • Statistical Modelling โ†’ Forecasting revenue for next month!
  • Identify Patterns & Trends
  • Preparing Reports

Tools Needed by Data Analysts

  • Spreadsheets โ†’ Excel or Google Sheets
  • Statistical Analysis Software โ†’ AutoML, Scikit-learn, KNIME, Orange
  • Data Visualization Software โ†’ Microsoft Power BI, Tableau, Matplotlib
  • Programming Language โ†’ Python, C++, Java, MATLAB
  • SQL
  • Data Processing Tools โ†’ Hadoop, Hive, Spark

Functional Skills

  • Proficiency in Statistics
  • Analytical Skills
  • Problem Solving Skills
  • Data Visualization Skills ๐Ÿ“ Note: Logical Fallacy = An error in reasoning that uses invalid arguments to support a claim

Nominal Data Categorical information (no ranking) Gender, Nationality Ordinal Data Categorical (order/ranking) Customer Rating, Educational Levels Discrete Data Distinct Values (whole numbers) Employees in company, Cans in packaging Continuous Data Defined Range (continuous scale) Time, Temperature

Quantitative vs Qualitative

  • Quantitative Data โ†’ Numerical Information (count) โ†’ Discrete & Continuous โ†’ To Perform Calculations โ†’ Average, Correlations โ†’ Eg: Temperature, Age
  • Qualitative Data โ†’ Non-Numerical Information (qualities) โ†’ Nominal & Ordinal โ†’ Involves Categorizing, Coding โ†’ Eg: Customer Feedback, Colours, Texture

Types of Data File Formats

Format Full Form Key Points CSV Delimited Text Files Data as Text, delimiter specifies boundaries (,/TAB/Space), Common Separated Text Excel Spreadsheets Organized into rows & columns, can do statistical analysis, Structured Data XML Extensible Markup Language Specific rules for encoding data, Readable by humans & machines, Data sharing is very simple PDF Portable Document Format Developed by Adobe, Independent of application & OS, Legal Documents JSON JavaScript Object Notation Text based standard format, Transmitting over the web, Can be read by most programming languages WEEK 5 โ€” Data Sources & Repositories

Common Sources of Data

  • Data sources are diverse today
    1. Relational Databases
    1. Flat Files
    1. APIs & Web Services
    1. Web Scraping
    1. Data Streams & Feeds

Relational Databases

  • Business internal databases
  • Each unit is connected to other through common identifiers
  • Eg: SQL, Oracle, MySQL, IBM DB2 โ†’ For Data in structured way
  • Used for various analysis

Flat Files

  • External to Business, Standalone
  • Government & Non-government โ†’ economic dataset
  • Sales Data, Weather Data
  • Eg: Spreadsheets, Delimited Files, XML files โ†’ Both Structured & Unstructured way

APIs & Web Services

  • Multiple users can interact with them
  • Eg: Plain text, XML, JSON
  • Popular APIs โ†’ Twitter & Facebook

Web Scraping

  • Extracting relevant data from websites
  • Unstructured Data
  • Eg: Online retail platforms
  • Tools: Beautiful Soup, Scrapy, Pandas, Selenium

Data Streams & Feeds

  • Flows of Data, Constantly Changing
  • Eg: Search Engine Data, Stock Market Tickers (Sensex), Social Media Feeds โ†’ updated constantly
  • Tools: Apache Kafka / Spark / Stream

Other Sources

  • Data from Satellite Imagery โ†’ Track buildings, forests, weather, rainfall

Types of Data Source

  • First Party Data โ†’ Directly by a business (Direct Way basically) | Eg: Customer Feedback
  • Third Party Data โ†’ By external agencies or government | Eg: Census Data, GDP
  • Population Data โ†’ Larger Dataset
  • Sampled Data โ†’ Subset of population data ๐Ÿ“ Note: Same as studied in FSP!

Data Repository

  • Data collected, organized, categorized and stored for processing & analysis
  • Storage of Data | Easier Data Access | Efficient Reporting & Analytics

Types of Data Repository:

  • 1. Databases โ†’ Store data from various sources
  • 2. Data Warehouses โ†’ Large central repository, uses ETL
  • 3. Data Lakes โ†’ Large amount of data regardless of structure
  • 4. Data Marts โ†’ Small section of data for particular purpose

Detailed: Databases

  • Collection of data created for input, storage, search & retrieval of data
  • In organized format (on servers)

Used in time-series/weather data. Graph Based Store Graphical model. Data connected to each other. Used for visualizing & analyzing. Social media data, product recommendation. Versatile. Difficult to run large volumes of data Neo4J, CosmosDB

Data Warehouses

  • Large Central Repository
  • Uses ETL = Extract, Transform, Load Process
  • Works as multipurpose storage

Data Marts

  • Small section of data for particular purpose
  • Particular Business / Community
  • Eg: Only Customer transactions of a particular business
  • Has Isolate security & performance โ†’ protect data
  • Used for Reporting & Analytics

Data Lake

  • Large amount of data irrespective of structure whether structured, unstructured
  • Stores in original/native format
  • Each element has unique identifier, Has a tag!
  • Storage of Choice
  • Can contain all source data & file formats
  • Needed for predictive & advanced analytics

Data Pipelines โ€” ETL

ETL Pipeline โ†’ Extract, Transform, Load Raw Data โ†’ CONVERT โ†’ Analysis Ready Data

  • 1. Extract โ†’ Data collected from originating location for transformation. Can be performed in batches, in chunks or continuous.
  • 2. Transform โ†’ Raw Data converted into formats ready for analysis. Remove duplicates, making data format common, change format of data.
  • 3. Load โ†’ Transported to the destination.
  • Initial Loading โ†’ Loading data at once only
  • Incremental Loading โ†’ Loading data periodically (small chunks)
  • Full Refresh โ†’ Erasing previously loaded data and load fresh data ๐Ÿ“ Note: Data Pipeline is a broad term. ETL is a part of data pipeline. Data Pipeline is a high performance system. May load data into a data lake. Eg: Apache Beam & Data Flow

SQL Lite โ€” Basic Commands

INTEGER PRIMARY KEY โ†’ Main/Start Column INTEGER | TEXT

FOREIGN KEY โ†’ To combine 1 or more tables WEEK 7 โ€” Data Privacy, Security & Ethics

Data Privacy

  • Principles that govern the collection, use, storage, sharing of personal data
  • Important for identifying theft, consumer trust, brand image
  • Data privacy can uniquely identify an individual
  • Confidential Handling Category Description Examples PII (Personally Identifiable Information) Uniquely identify an individual's identity Full Name, Phone No., Email address, Aadhar PI (Personal Information) All PII + Additional linked directly or indirectly to an individual IP Address, Geo-locations, Videos, Criminal records Sensitive Information If combined with other information can cause harm Political Beliefs, Genetic Information, Religious beliefs

Data Anonymization

  • Process of modifying dataset in such way to avoid the data is very difficult/impossible
  • Preserve Privacy & also data can be used for analysis

Ways of Data Anonymization:

  • 1. Removing PII โ†’ Remove names to replace with unique ID. Minimize data leak to be broadly used for analysis. Eg: Daksh โ†’ A1B3Y
  • 2. Generalization โ†’ Instead of removing data we transform it into a broader, less identifiable form. Reduce Granularity. Replacing DOB with age. Eg: 21 March, Patna โ†’ Patna
  • 3. Perturbation โ†’ When we don't need exact values but only need overall distribution. Includes techniques like randomization, scaling. Average remains same but exact value remains unknown.
  • 4. Data Masking โ†’ Maintaining data privacy by altering original data while maintaining its format/structure. Done for unique ID like Aadhar Card/PAN Card. Eg: 1234 5678 โ†’ XXXX XX
  • Data Anonymization โ†’ Making Data completely Unidentifiable (Irreversible)
  • Data Masking โ†’ Obscuring Sensitive Data replacing with fictitious values (Reversible)

Data Anonymization Tools

  • ARX โ†’ Open source, used for large organizations
  • IBM Guardium โ†’ Protect Sensitive Data
  • Google TensorFlow Privacy โ†’ Used by individuals

Data Privacy Regulations

  • Various laws govern data privacy
  • GDPR โ†’ Europe | CCPA โ†’ US | Digital Personal Data Protection (DPDP) โ†’ India
  • Market Trends, Research From

Importing Data

  • Imported into a repository, Put data in one place before doing any operations
  • Depending on type we need different tools
  • Structured Data โ†’ Relational Database | Semi-Structured โ†’ NoSQL Database
  • Unstructured Data โ†’ NoSQL or Data Lake | ETL Tools or Data Pipeline
  • Python & R are popularly used WEEK 8 โ€” Data Cleaning

Data Cleaning

Can affect analysis. Steps: (1) Inspecting Data โ†’ (2) Cleaning Data โ†’ (3) Verification of Data

1. Inspecting

  • Detecting Issues & Errors
  • Comparing against rules & constraints
  • Looking at source & format of data
  • Contents of the data
  • Visualizing Data | Data Profiling

2. Cleaning

  • Removing Duplicates | Missing Values
  • Formatting Data (Eg: Format of Date)
  • Errors & Discrepancies

Cleaning Tools:

  • Excel/Spreadsheets โ†’ Built-in formulae for identifying issues, clean, format & transform data. Can import data from different types of sources.
  • Google Data Prep โ†’ Cloud Data Service. Can clean structured as well as unstructured. Can detect schemas, data types & Anomalies.
  • Python โ†’ Large libraries โ†’ Jupyter Notebook, NumPy, Pandas
  • R โ†’ Useful for statistical computing. Large libraries โ†’ Dplyr, Data.table, JsonLite

3. Verification

  • Inspect the results / effectiveness of Data Cleaning
  • Document all changes that are done & also their Reasons โ†’ For References, For Other Members
  • Quality check of current data

Removing Duplicates

  • First Task of Data Cleaning
  • Could be due to human error, while copying/saving, or machine malfunctioning
  • Can be removed through Excel from removing duplicates
  • Before removing ensure that repeated data is indeed an error that we can fix

Data Formatting

  • Data Type Conversion โ†’ Data Types of each field
  • Standardizing Data โ†’ Unit of measurements should be standard
  • Syntax Errors / Look for Inconsistencies
  • Data should be formatted consistently | And also check for blank spaces Examples: โ—ฆ Data Type โ†’ Date โ†’ 45669 โœ— โ†’ Should be correct 01- 02 - 2025 โ—ฆ Date โ†’ Format = 12- 01 - 2025 โ†’ 01 Feb 2025 โœ— โ†’ Standard is it! โ—ฆ Excel โ†’ Home โ†’ A section for correcting format โ—ฆ Price โ†’ Rs/$/Re โ†’ Put the same unit! โ†’ Use Common Sense WEEK 9 โ€” Missing Data & Data Transformations

Missing Data

  • After checking for duplicates & formatting errors
  • Occurs for various reasons, Requires handling carefully

Reasons:

  • Not have information โ†’ Some didn't answer / Question not applicable to particular use
  • Information not recorded โ†’ Machine Malfunction

How to Deal:

  • Filling in the missing values โ†’ NA or N/A
  • Delete the records altogether โ†’ not preferred but sometimes becomes necessary!

Errors / Inconsistencies

  • After removing duplicates, formatting & handling missing values
  • Quite Difficult โ†’ Need common sense, intuition, judgmental and logical
  • Need to know the context & source of collection โ†’ Check same from another source โ†’ May need to drop the records if we couldn't find errors!

Data Transformations

After cleaning the data. Looks like: Changing scale of variables, Encoding categorical variables

A. Changing Scale of Variables

(a) Standardization (Z-score Normalization)

Zx = (xi - xฬ„ ) / s where xi = original value, xฬ„ = sample mean, s = sample SD โ†’ n(n-1)

  • Used when variables have different units of measurements
  • Used when large numbers dominate the dataset

(b) Min-Max Scaling (Normalization)

x'i = (xi - xmin) / (xmax - xmin) where xmax - xmin = RANGE

JOINS

  • INNER JOIN โ†’ Return only records where a joining field finds a match in both
  • LEFT JOIN โ†’ All from left table and match in right table will come
  • RIGHT JOIN โ†’ All from right table and match in left table will come
  • FULL JOIN โ†’ Combine both means LEFT UNION RIGHT JOIN โ†’ Inspection of Tables!
  • UNION โ†’ Vertically combine โ†’ should have same no. of columns. A corresponding column must have same data type โ†’ Do not join tables, just Duplicates

SQL Functions (Futurense)

JOIN โ†’ Columns Added! UNION โ†’ No. of columns are equal but rows are added! CONCAT โ†’ Adding/Concatenating two things! COALESCE โ†’ For handling missing values / status! ๐Ÿ“ Note: CASE โ†’ like if-else: Use เคคเคญเฅ€ เคœเคฌ IF เคถเฅเคฐเฅ‚ เคนเฅ‹

Hierarchical Data

  • Layers/Branches to the data in datasets
  • Tree-like structure & very common in relational databases
  • Eg: Continents โ†’ Countries โ†’ Cities โ†’ Localities
  • Eg: Degree โ†’ Semester โ†’ Course โ†’ Lecture
  • Long Format โ†’ Multiple records for a given level
  • Wide Format โ†’ Repetitive Records for given records in single row WEEK 11 โ€” Feature Engineering & Descriptive Analytics

Arranging Data

  • Purchase Date, Transaction, Product ID, Product Name, Amount
  • Arrange can be done through 'Sort & Filter'
  • We can group, sort, filter by anything!!

Feature Engineering

  • Steps where we create new features to better understand our data
  • Before Modelling | Can be learned through experience!
  • Eg: Purchase Date (Raw Data) โ†’ Day, Weekend, Weekday (Embedded / Feature Engineering)
  • It is not about technique. We have to understand your field!
  • We need Domain Expertise!!

Descriptive Analytics

  • What happened? โ†’ Summarizes the Data โ†’ Uncover Patterns
  • Eg: Total/Average of some Data!
  • Can find many things about this โ†’ Just see examples

SQL Five Super Functions

COUNT() โ†’ How Many SUM() โ†’ Total AVG() โ†’ Mean / Average MIN() or MAX() GROUP BY โ†’ To give it in a group! ORDER BY โ†’ If want in DESC or ASC. If only want few rows: LIMIT 2 ๐Ÿ“ Note: We can provide nickname also โ†’ orders = 0 WEEK 12 โ€” Data Visualizations

Introduction

  • A picture tells 1000 words!!
  • It should not mislead or distort!
  • Should be aesthetically pleasing
  • Anscombe's Quartet โ†’ 4 different samples but approx. same result. Statistics says the same (almost). Visualization says different relationships.

A Good Data Visualization Will Have

    1. Informative Title
    1. Clearly Labelled Axes with unit of measurement
    1. A Legend โ†’ give content of graph
    1. A different Colour to represent types

Aesthetics

  • Neat Graph
  • No unnecessary use of colours
  • Clearly Labelled
  • Convey Relationships Well Data Visualization โ†’ Powerful tool in data analytics. Helps to understand effectively. Consists key elements like: title, axes, legends, labels, visual attributes. Choice depends on type & purpose of data.

A. Univariate Visualization (One Variable)

(a) Continuous:

  • 1. Histogram โ†’ Visualizing 'Quantitative' variable. Bin plotted in vertical. Bin-width very important.

(b) Categorical:

  • 1. Bar Graph โ†’ For showing categories. Height shows frequency. Can be vertical as well as horizontal.
  • 2. Column Chart / Bar Chart โ†’ Vertically / Horizontally. Depends on aesthetics.
  • 3. Stacked Bar/Column Chart โ†’ Bar chart more creatively. Diff. components of diff. 'categories'. Each bar consists multiple segments.
  • 4. Grouped Column Chart โ†’ Instead of stacking we can use this. We can look at heights easily. Very cluttered.
  • 5. Pie Chart โ†’ Size of components of whole. Usually percentages.

Data Visualization

  • Allows user to draw their own conclusion
  • Small Dataset, Representative of Data
  • For Reports, Dashboards

Dashboards

  • Useful component in Data Analyst Toolkit
  • Scientific Aspect as well as Aesthetic Aspect
  • We put all business information in one place in form of graphical displays
  • Allow user to interact also!

Uses of Dashboards:

  • Offer Insights
  • Alert you to patterns & trends
  • Provide Interactive Experience for user
  • Allows user to filter
  • Updated in real time

Applications:

  • Forecasting & Reporting
  • Project Management
  • Executive Reporting
  • Customer Service & Human Resources
  • Help Desk issue tracking | Social Media Marketing

Software:

  • Microsoft Excel / Google Sheets
  • Bokeh / Dash in Python
  • R Studio's Shiny
  • Tableau
  • IBM Cognos Analytics

Interpreting Results

  • After cleaning & analyzing
  • We have to generate insights
  • Analytical Findings โ†’ Business Context
  • We need to look 'Objective of Our Analysis'
  • It's basically generating actionable insights for better decisions to help for business

Understanding Analysis

  • Answer some basic questions after interpreting
    1. Put some Questions
    1. Answer them with 'How' & 'What'
    1. Be Confident with Answers โ†’ don't be overconfident (It will check in Modelling Regression, Statistical Tests)
    1. Significance of Results

Communicating Our Results

  • Need to tell the story with your data by visualizing, creating structured narrative
  • Begin with yourself asking some questions: Who is my audience? Why is it important to them? What will help them trust me?
  • A Presentation should not a 'data dump' โ†’ What is important? โ†’ Deliver this. เคœเฅเคฏเคพเคฆเคพ เคœเฅเคžเคพเคจ เคฎเคค เคฆเฅ‹!
  • Begin with demonstrating ideas
  • Don't assume audience knows everything
  • Structure & Organize your presentation
  • Organize information into logical categories
  • What takeaways your audience need? โ†’ Executive Summary, Fact Sheet, Report
  • A Powerful visualization to bring data live
  • Establish 'credibility' of your findings

Generative AI for Data Analytics

  • Specific form of AI โ†’ Focuses on creating new synthetic data
  • Different from traditional AI What can Gen AI do?
  • Can create synthetic data to prevent privacy (similar but not same)
  • Can transform data in different representations
  • Text to Video or Video to Infographic
  • Contributes by automating & Enhancing Data Cleaning
  • Efficiency & Innovation in querying Databases
  • Enhance the quality
  • Can combine with dynamic visualization โ†’ Tableau AI, IBM Cognos AI Quick Reference โ€” Key Concepts Concept Key Point Data Analytics Process Gathering โ†’ Cleaning โ†’ Organizing โ†’ Analyzing โ†’ Interpreting Exploratory Analytics What is in the data? (Gathering, Sorting, Reviewing) Descriptive Analytics What happened? (Summarize past data) Diagnostic Analytics Why did it happen? (Root cause) Predictive Analytics What could happen next? (Forecast) Prescriptive Analytics What should be done? (Optimization) Structured Data Rigid format (Spreadsheets, SQL databases) Semi-Structured Data Mix format (XML, JSON, Emails) Unstructured Data No format (Images, Videos) ETL Extract โ†’ Transform โ†’ Load Primary Key Uniquely identifies each row/observation