Docsity

Data Analysis 2025/26 - IULM, Appunti di Analisi Dei Dati

Toggle sidebar
bg1
DATA ANALYSIS
Lecture 1 – 22/09
Introduction
Data analysis is the process of collecting, analysing, and interpreting data to generate meaningful insights
that can be used to make strategic business decisions.
This course is important to
• have the basic skills to continue your studies.
For example, “Competitive Analysis” course, where you will learn to analyse markets.
- Hedonic Pricing: to understand the attributes of a product that are more relevant on the choice of
consumer, starting from its price (regression) à regression on product attributes to explain price
- Demand Segmentation: to create segment of similar consumers (cluster analysis) à clustering
consumers based on similarities
• to provide a valuable tool for the future job
Data is among the most precious resources available; this course will provide the basics to understand it.
No business willing to scale can overlook the importance of data. Data Analysis is the common ground
language between marketers, scientists, engineers, and stakeholders.
Course content
Prerequisites
Basic statistical concepts and terminology
- Data types
- Numerical and categorical
- Descriptive statistics
- Frequency distributions
- Mean, variance.
Software: basic Excel functionality
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Anteprima parziale del testo

Scarica Data Analysis 2025/26 - IULM e più Appunti in PDF di Analisi Dei Dati solo su Docsity!

DATA ANALYSIS

Lecture 1 – 22/

Introduction

Data analysis is the process of collecting, analysing, and interpreting data to generate meaningful insights

that can be used to make strategic business decisions.

This course is important to

  • have the basic skills to continue your studies.

For example, “Competitive Analysis” course, where you will learn to analyse markets.

- Hedonic Pricing : to understand the attributes of a product that are more relevant on the choice of

consumer, starting from its price ( regression ) à regression on product attributes to explain price

- Demand Segmentation: to create segment of similar consumers ( cluster analysis ) à clustering

consumers based on similarities

  • to provide a valuable tool for the future job

Data is among the most precious resources available; this course will provide the basics to understand it.

No business willing to scale can overlook the importance of data. Data Analysis is the common ground

language between marketers, scientists, engineers, and stakeholders.

Course content

Prerequisites

Basic statistical concepts and terminology

  • Data types
  • Numerical and categorical
  • Descriptive statistics
  • Frequency distributions
  • Mean, variance.

Software: basic Excel functionality

CONTEXT

INTRODUCTION TO DATA FOR DATA ANALYSIS

Book: Sarstedt, Mooi: chapters 1, 2, and 3

What is data?

Data is not only numbers, but also sales figures, survey responses, customer reviews, clicks, web/social

traces. They are fundamental to take decisions.

Why data matters in marketing?

(1) concrete basis for decisions , not just intuition

(2) reduce risks and improve strategy.

Goal of Data Analysis à the goal is to transform raw data to actionable insights ( information ) into

decisions. The decision is therefore based on concrete reality.

As presented in the figure, one information is visible and intuitive à the lowest sales of product B are done

in the South ( information ). The following decision will be targeted marketing (local advertising campaigns)

to increase product awareness ( decision ).

Another example à a fashion company wants to understand why sales have dropped. With data analysis it

can (1) identify causes (new competitors, prices, changing tastes) and (2) find strategies to respond.

Data Analysis: the main tool in Market Analysis

Market analysis helps companies to better understand the environment in which a company operates:

customers, competitors, opportunities, and risks.

It also answers questions about :

  • Market: How big is it? Is it growing or shrinking?
  • Customers: Who are they? What do they want? How do they behave?
  • Competitors: Who are they? What do they offer differently than us?

This can lead to:

  • Opportunities → example: discovering a new market segment (e.g., young people interested in

sustainable products).

  • Problems → example: realizing we're losing market share because a competitor offers better prices.
  • Insights → example: segmenting (dividing customers into similar groups) or measuring customer

satisfaction.

Conclusions about market analysis

Market analysis is like having a compass à it tells the company.

  • Where is the company?
  • Who are the company’s traveling companions (customer)?

The process of (qualitative) market analysis

Example: Interview a group of customers to understand their views on sustainability in a cosmetics

collection.

Sometimes it precedes quantitative analysis for exploratory purposes: define the contours of the problem;

develop working hypotheses; identify variables and relationships to explore further.

à this means that sometimes it might appear that the problem is the product, but sometimes it’s just about

hearing and understanding customers’ opinions.

What it collects: opinions, motivations, perceptions, attitudes.

How: in-depth interviews, focus groups (a small group of people discuss under the

guidance of a moderator), and observations.

Objective: To understand the reasons behind consumer choices (ideas, emotions, values).

The process of (quantitative) market analysis

This analysis is different from qualitative, but it’s still fundamental.

Information sources

Primary Data:

We specifically collect them for our purpose.

Example: If we want to know what customers think of a new product, we conduct a survey or interview.

Secondary Data:

They already exist but have been collected for other purposes.

For example: internal company data (invoices, CRM, social media, call center) or external sources (Istat,

AIDA, Google, Nielsen, etc.).

Types of information

Secondary

Data (AIDA,

Istat)

Primary

Data

(Survey)

Classification data

Example: age, education, nationality, sector, company size, revenue YES YES

Opinions

Examples: values, opinions, lifestyle, satisfaction.

NO YES

Behaviors

Examples: purchases (frequency and quantity)

YES (observed

data)

YES

(declared

data)

Data Science and ML (Machine Learning) platforms: main players

This is one of the most well-known representation of data science

and machine learning companies that build software for data

analysis.

Picture: Gartner 2021 Magic Quadrant for Data Science and

Machine Learning Platforms.

Data Science Software Classification

By Application à statistics, machine learning, deep learning, data

mining, text analytics… One platform can support multiple

applications.

By Commercial Policy – how the software is distributed

  • licence (yearly o perpetual)
  • freeware
  • open source software, allows transparency, flexibility, and no

licensing costs.

Interface – how users interact with the software

  • GUI (Graphical User Interface) menu or workflow bases
  • CLI (command line interface) using the computer terminal
  • Library extending an existing programming language such as Python, R.

Example :

  • Vague = “regular consumers of product X”
  • Precise = “consumers who purchased product X at least once in the last 30 days”

Why we can’t study everyone

Studying the entire population is often impractical (too costly, time-consuming, or even impossible).

Example :

You want to know what all Coca-Cola consumers think in 2024

  • We’re talking about millions of people, spread across many countries.
  • Result: interviewing the entire population is not realistic (too expensive, too slow, too complex)

è Solution: So we usually use a sample!

Sampling

Sampling is the process through which we select

cases from a population. The most important aspect

of sampling is that the selected sample is

representative of the population. Representative

means that the characteristics of the sample closely

match those of the population.

Probability sampling a pproaches provide every

individual in the population with a chance (not equal

to zero) of being included in the sample.

Non-probability sampling procedures do not give

every individual in the population an equal chance

of being included in the sample.

A good sample speaks for all

The sample should reflect the diversity of all population. The sample must be representative:

  • It should reflect the diversity of the whole population
  • So that the conclusions we draw are reliable and valid.

Example : a representative sample for coca-cola mean:

  • Different ages
  • Different countries and cultures
  • Different consumption habits

à This way, what we learn from the sample can be generalised to all Coca-Cola consumers.

An example of a non-representative (biased) sample:

  • A fashion company seeks feedback on a new collection
  • The population is huge and made up of different types of consumers (ages, budgets, and so on)
  • The sample, composed of the Milan students, is non-representative of all consumers:
  • Then, their preferences are not those of their entire population. For example, students prefer low-cost

streetwear.

  • Wrong decision: new collection focused on low-cost streetwear
  • Negative consequence: Loss of premium market share

Probabilistic Sampling

Choosing the Right Sample Method

Non-probabilistic Sampling

  • Sample size does not depend on population size, provided the population is sufficiently large

(roughly 10,000 units or more).

Example: If the population is made of 100.000 or 10.000 consumers, then a sample of 400-500 units is

enough in both the cases.

  • Sample size can be estimated in advance using inferential statistics methods.
  • The optimal sample size is the one that achieves the research objectives at the lowest possible cost.

Accuracy vs. Precision

  • Representativeness implies Accuracy
  • Sample size implies Precision

Consider a target with a centre, where the center represent the real

value of the population and the shots (arrows or balls) represent the

estimates obtained from the sample. Then, accuracy means that the

shots are close to the centre of the target (the estimates are close to

the real value of the population). Precision means that the shots are close to each other, even if they don’t hit

the centre (the estimates from different samples are very similar, and so they have low variability).

Common exam traps 🚨

❌ “A larger population requires a larger sample” → False

❌ “400 observations are too few for 100,000 people” → False

✅ “Representativeness is more important than size” → True

Survey

Data is the core of the analysis. A survey is a method to collect data.

à A survey is a collection of primary data through structured interviews with a sample of subjects.

Survey Alternatives

  • Census : data collection on the entire population (for market analysis this is only a theoretical

possibility);

  • Analysis of secondary data from external sources (example: ISTAT);
  • Analysis of secondary internal data (example: CRM – Customer Relationship Management).

Survey Advantages

  • Precise investigation (provide targeted data and results), with a desired level of deph
  • With an adeguate sampling, it provides a representative picture of the population under the study

à Surveys = depth + representativeness

Phases of a Survey

  1. Definition of the objective
  2. Identification of the research design : relevant information, expected level of analysis (exploratory,

diagnostic, predictive), expected results, population, sample.

  1. Choice of the contact method.
  2. Construction of the questionnaire.
  3. Administration of the questionnaire to the sample.
  4. Data collection and cleaning.
  5. Analysis.
  6. Reporting.

à Secide what you want to know → prepare → ask → analyze → report

Contact Method

Having an interviewer ensures more accurate and reliable responses, but it makes the process more

expensive + bias.

Construction of the Questionnaire

à Fundamental principles: clarity, simplicity, brevity

1. What to ask

a. Identify information of primary and secondary interest

b. Example : opinions, habits, satisfaction.

2. Questionnaire structure

a. Put questions in a clear order.

b. Example : start with opinions → then behaviours → then demographics

3. How to ask

a. Example : open/closed questions, scales (1–5), include “I don’t know”.

à Decide the content → order it well → choose how to ask

Question Formulation: Recommendations

  • Avoid duplicate questions
  • Avoid ambiguity
  • Beware of negatives
  • Give exhaustive and mutually exclusive answers
  • Don't take anything for granted
  • Be careful with questions about the past and sensitive topics
  • Avoid biased wording

Key Takeaways:

  • Statistics is the methodological toolbox; data analysis applies it (with ML) to support decision-

making, while statistics ensures interpretability.

  • The population is the complete set of units under study and must be clearly and precisely defined.
  • Because studying the whole population is impractical, analysis is based on a sample.
  • A good sample must be random, representative, and adequately sized.
  • Representativeness ensures accuracy , while sample size ensures precision.
  • For large populations (≈10,000+), sample size does not depend on population size; about 400– 500

observations are often sufficient.

Binary Data

  • They can only take on two possible values (0/1)
  • Binary data of this kind are sometimes referred to as

dummy variables , indicating the presence (1) or

absence (0) of a certain characteristic

  • The flexibility offered by binary data makes it

possible to transform nominal categorical data into

numerical data.

Data Type Summary Diagram

Data Munging: Cleaning & Transformation

  • Most time-consuming, least enjoyable data science task (Forbes, 2016)

Data Cleaning - Examples:

  • Correct distortions from samples to make data more representative

o Impossible values: Age = 999 → error → replace with missing or from the record

o Missing values: Preferred brand = NULL → decide whether to impute or drop the row

o Standardizing formats: “zappalà” → “Zappalà”

o Out-of-scale responses: “pizza” is not a valid frequency → flag as error or recode

Data Cleaning - Missing Values

Missing data is a problem for many analyses.

  • Common causes :

o In Survey data: inapplicable questions, total or

partial non-response

o In Official data: non-publication

o In General: technical errors, mistakes

Outlier

Outliers are numbers in a dataset that are very different from all the others.

  • Sometimes they are errors (for example, someone typed 999 instead of 99)
  • Sometimes they are real extreme events

The key question is: Why is that number so different?

  • If it’s an error → maybe it should be corrected or removed.
  • If it’s real → it can teach us something valuable.

In some fields (like fraud detection in banking), finding outliers is the main goal of the analysis.

Example: Pizza expenditure, you want to know how much money your friends spend on a pizza

  • Friends spend: €10, €12, €9, €11, €
  • Consideration à everyone spends between €9 and €12, but one person spends €200, which is

an outlier , as it does not reflect typical behavior

  • Sometimes is important to understand why an outlier appers (maybe they ordered champagne)

Why consider outliers:

  • Outliers can skew statistics , they can affect the results of the analysis e.g., mean:

o Ex. à Mean with outlier: (10+12+9+11+200)/5 = 48 → misleading, it gives the wrong idea

that my friends spend €48 each on pizza

Identifying and treating outliers

Ourliers can be identifies by statistical tools. They should not be ignored à they can be errors, but also

valuable information!

  • How you handle them depends on the context:

o error → eliminate,

o real but extreme value → ranking or capping.

§ Corrected by ranking or capping :

§ Ranking : exclude 200 → mean = 10.5. 200 is not considered for the mean

(but we specify that is the highest value) à (10 + 12 + 9 + 11) / 4 = 10,

§ Capping : replace 200 with next highest (12) → mean = 10.8. 200 is

substituted with the other highest value (in this case 12=

Example:

A histogram of customer ages may group ages into intervals:

15 – 24, 25–34, 35–44, etc.

3. Probability

Probability in Everyday Life

We use probabilities to describe uncertainty:

  • The probability that it will be sunny tomorrow is 70%
  • The probability that this drug works is 90%
  • The probability that I will pass the exam is 60%
  • The probability that the university will be closed tomorrow is almost 0%

Definition

  • Probability quantifies how likely an event is to happen , it’s a number that shows how easy or

difficult it is for something to happen

  • It’s always a number between 0 and 1 :

o 0 → impossible event

o 1 → certain event

o Between 0 and 1 → varying degrees of likelihood

Example: Coin Toss

  • Two possible outcomes: Head or Tail.
  • Each outcome is equally likely.

à If we toss a coin many times, we expect about half to be heads, but the exact proportion may vary

for small numbers of tosses.

4. Experimental Probability and Relative Frequency (results)

When we actually perform an experiment (e.g., tossing a coin 20 times), the observed results ( relative

frequency ) may differ slightly from the theoretical probability.

Example :

20 coin tosses → 9 Heads

This might not be exactly 0.5 (50%), but as the number of trials increases , it gets closer to the true

probability.

Law of Large Numbers

As the number of experiments increases indefinitely, the relative frequency converges to the

theoretical probability.

The relative frequency = probability

When the number of tosses tend to infinity.

________________________________________________________________________________

Seeing Theory – Ch. 1 Basic Probability https://seeing-theory.brown.edu/basic-probability/index.html

This chapter is an introduction to the basic concepts of probability theory.

Chance Events

Randomness is all around us. Probability theory is the mathematical framework that allows us to analyze

chance events in a logically sound manner. The probability of an event is a number indicating how likely that

event will occur. This number is always between 0 and 1, where 0 indicates impossibility and 1 indicates

certainty.

A classic example of a probabilistic experiment is a fair coin toss , in which the two possible outcomes are

heads or tails. In this case, the probability of flipping a head or a tail is 1/2. In an actual series of coin tosses,

we may get more or less than exactly 50% heads. But as the number of flips increases, the long-run

frequency of heads is bound to get closer and closer to 50%.

Expectation

The expectation of a random variable is a number that attempts to capture the center of that random

variable's distribution. It can be interpreted as the long-run average of many independent samples from the

given distribution. More precisely, it is defined as the probability-weighted sum of all possible values in the

random variable's support,

𝑬[𝑿] = ∑𝒙 ∈ 𝑿𝒙𝑷(𝒙)

Variance

Whereas expectation provides a measure of centrality, the variance of a random variable quantifies the

spread of that random variable's distribution. The variance is the average value of the squared difference

between the random variable and its expectation,

𝑽𝒂𝒓(𝑿) = 𝑬[(𝑿 − 𝑬[𝑿])𝟐]

_______________________________________________________________________________________

5. Basic Probability Rules

Concept Example Probability

Certain Event P (Head or Tail) = 1 (or 100%)

Impossible Event P (rolling a 7 on dice) = 0

Between 0 and 1 – closer to 1=more likely; 0=less likely P (raining tomorrow) = 0.

Sum Rule - The sum of the probabilities of all possible events is 1 P(Head) + P(Tail) = 1 = 1

Interpretation:

All possible outcomes of an experiment together must add up to a total probability of 1.

6. Frequency Distributions vs Probability Distributions

Aspect Frequency Distribution Probability Distribution

Based on Observed (sample) data Theoretical model

Purpose Describe what we observe Predict or model what could happen

Values Counts or percentages Probabilities that sum to 1

  • Frequency distributions describe data from a sample, observed data.
  • Probability distributions describe expected behavior for a random variable in theory.

Many curves of different shapes exist to model different

phenomena:

o Mean (μ) → the center

o Standard Deviation ( 𝛔

𝟐

) → the spread, variance

  • It is denoted as N (μ, σ)

Properties

  • The normal distirbution is symmetric around the mean.
  • Mean = Median = Mode.
  • Total area under the curve = 1.

Examples of normally distributed variables:

  • Birth weight
  • Human height
  • Exam scores
  • Daily customer counts

Examples of non-normal variables

  • Income
  • Size of Italian companies (employees or turnover)
  • Number (!) of followers or daily visits to a website
  • Waiting time for a service
  • Time between two consecutive calls to a call center
  • Subway waiting time

Using Probability Distributions

  • Knowledge of a theoretical distribution allows us to answer questions such as:

What is the probability of values between a and b?

What is the probability of values greater (or less) than a?

  • In applied problems, we attempt to reduce the observed (sample) distribution to a known theoretical distribution:

standard normal distribution

Example of application of the normal

Suppose the number of customers per day at a store follows an approximately normal distribution with:

We can write this as:

𝑋 _

i ~ 𝑁

'

This means:

  • The average (mean) number of customers per day is 750.
  • The standard deviation (a measure of spread) is 100 customers.

Question

What is the probability that there are more than 700 customers in a day?

What is the probability that in X>700 (in 𝑁(750; 100

'

What is the area to the right of 700 (𝑁(750; 100

'

Answer

  1. Find the area to the left of 700 (Excel example):

P(X<700)=0.

  1. Then, probability of more than 700 :

P(X>700)=1−0.3085=0.

Interpretation:

There’s a 69.15% chance that more than 700 customers will visit the store in a day.

9. Standard Normal Distribution

A special case of the normal distribution where:

This is denoted as:

Any normal variable can be standardized (converted to Z) using:

This makes it easier to look up probabilities using Z-tables or software.