Top Banner
Prof. Pier Luca Lanzi Data Exploration Data Mining and Text Mining (UIC 583 @ Politecnico di Milano)
62

DMTM Lecture 19 Data exploration

Jan 21, 2018

Download

Education

Pier Luca Lanzi
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Data ExplorationData Mining and Text Mining (UIC 583 @ Politecnico di Milano)

Page 2: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Readings

• “Data Mining and Analysis” – Chapter 2 & 3

• Loading Data and Basic Formatting in Rhttp://flowingdata.com/2015/02/18/loading-data-and-basic-formatting-in-r/

2

Page 3: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

http://www.kdnuggets.com/2015/03/cartoon-us-chief-data-scientist-challenge.html

Page 4: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Before trying anything, you should know your data!

Page 5: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

What is Data Exploration?

• It is the preliminary exploration of the data aimed at identifying their most relevant characteristics

• What the key motivations?§Helping to select the right tool for preprocessing and data

mining § Exploiting humans’ abilities to recognize patterns

not captured by automatic tools • Related to Exploratory Data Analysis (EDA), created by

statistician John Tukey

5

Page 6: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Exploratory Data Analysis

• “An approach of analyzing data to summarize their main characteristics without using a statistical model or having formulated a prior hypothesis.”

• “Exploratory data analysis was promoted by John Tukeyto encourage statisticians to explore the data, and possibly formulate hypotheses that could lead to new data collection and experiments.”

• Seminal book is “Exploratory Data Analysis” by Tukey

• Nice online introduction in Chapter 1 of the NIST Engineering Statistics Handbook http://www.itl.nist.gov/div898/handbook/index.htm

• http://en.wikipedia.org/wiki/Exploratory_data_analysis

6

Page 7: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

http://vis.stanford.edu/files/2012-EnterpriseAnalysisInterviews-VAST.pdf

Page 8: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

What Data Exploration Techniques?

• Exploratory Data Analysis (as originally defined by Tukey),was mainly focused on§Visualization§Clustering and anomaly detection

(viewed as exploratory techniques)§ In data mining, clustering and anomaly detection are major

areas of interest, and not thought of as just exploratory• In this section, we focus on data exploration using§ Summary statistics§Visualization

• We will come back later to data exploration when discussing clustering

8

Page 9: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Numerical Attributes

9

Page 10: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 11: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 12: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 13: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 14: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 15: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 16: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 17: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 18: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 19: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Geometric Interpretation of Correlation

• The correlation coefficient is simply the cosine of the angle between the two centered attribute vectors

19

Page 20: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Normalization

20

Page 21: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 22: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 23: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Summary Statistics

• They are numbers that summarize properties of the data

• Summarized properties include location, mean, spread, skewness, standard deviation

• Most summary statistics can be calculated in a single pass

23

Page 24: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Frequency and Mode

• The frequency of an attribute value is the percentage of time the value occurs in the data set

• For example, given the attribute ‘gender’ and a representative population of people, the gender ‘female’ occurs about 50% of the time.

• The mode of an attribute is the most frequent attribute value

• The notions of frequency and mode are typically used with categorical data

24

Page 25: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Measures of Location:Mean and Median

• The mean is the most common measure of the location of a set of points

• However, the mean is very sensitive to outliers

• Thus, the median or a trimmed mean is also commonly used

25

Page 26: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Measures of Spread: Range and Variance

• Range is the difference between the max and min• The variance or standard deviation is the most common measure

of the spread of a set of points

• However, this is also sensitive to outliers, so that other measures are often used

26

Page 27: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Percentiles

• For continuous data, the notion of a percentile is veryuseful

• Given an ordinal or continuous attribute x and a number p between 0 and 100, the p-th percentile is a value xp of x such that p% of the observed values of x are less than xp

• For instance, the 50th percentile is the value x50% such that 50% of all values of x are less than x50%

27

Page 28: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Visualization

• Visualization is the conversion of data into a visual or tabular format so that the characteristics of the data and the relationships among data items or attributes can be analyzed or reported

• Data visualization is one of the most powerful and appealing techniques for data exploration §Humans have a well developed ability to analyze large

amounts of information that is presented visually§Can detect general patterns and trends§Can detect outliers and unusual patterns

28

Page 29: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Barplots

• They use horizontal or vertical bars to compare categories.

• One axis shows the compared categories, the other axis represents a discrete value

• Some bar graphs present bars clustered in groups of more than one (grouped bar graphs), and others show the bars divided into subparts to show cumulate effect (stacked bar graphs)

29

Page 30: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Histograms

• They are a graphical representation of the distribution of data introduced by Karl Pearson in 1895

• They estimate the probability distribution of a continuous variables

• They are representations of tabulated frequencies depicted as adjacent rectangles, erected over discrete intervals (bins). Their areas are proportional to the frequency of the observations in the interval.

30

Page 31: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Histograms

• The height of each bar indicates the number of objects• Shape of histogram depends on the number of bins

31

Example: Petal Width (10 and 20 bins, respectively)

Page 32: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Maps

• Maps are a very effective communications tool that can visualize thousands of data points in just one figure

32

Page 33: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Mapping Data for Visualization

• Data objects, their attributes, and the relationships among data objects are translated into graphical elements such as points, lines, shapes, and colors

• Objects are often represented as points

• Their attribute values can be represented as the position of the points or the characteristics of the points, e.g., color, size, and shape

• If position is used, then the relationships of points, i.e., whether they form groups or a point is an outlier, is easily perceived.

33

Page 34: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Data Arrangement

• Is the placement of visual elements within a display

• Influence on how easy it is to understand the data

34

Page 35: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Selection

• Is the elimination or the de-emphasis of certain objects and attributes

• Selection may involve choosing a subset of attributes §Dimensionality reduction is often used to reduce the number

of dimensions to two or three§Alternatively, pairs of attributes can be considered

• Selection may also involve choosing a subset of objects§ A region of the screen can only show so many points§Can sample, but want to preserve points in sparse areas

35

Page 36: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Box Plots

• Box Plots (invented by Tukey)

• Another way of displaying the distribution of data

• Following figure shows the basic part of a box plot

• IQR is the interquartile range or Q3-Q1

36

outlier

Min (> Q1 -1.5 IQR)

1st quartile (Q1)

3rd quartile (Q3)

2nd quartile (Q2)

Max ( < Q3 +1.5 IQR)

Page 37: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Box Plot Example 37

Page 38: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Scatter Plots

• Attributes values determine the position

• Two-dimensional scatter plots most common, but can have three-dimensional scatter plots

• Often additional attributes can be displayed by using the size, shape, and color of the markers that represent the objects

• It is useful to have arrays of scatter plots can compactly summarize the relationships of several pairs of attributes

• Examples: http://www.statmethods.net/graphs/scatterplot.html

38

Page 39: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Scatter Plots 39

Page 40: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Scatter Plots 40

Page 41: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Scatter Plot Array for Iris 41

Page 42: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Scatter Plot Combined with Box Plots 42

Page 43: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Contour Plots

• Useful for continuous attributes measured on a spatial grid

• They partition the plane into regions of similar values

• The contour lines that form the boundaries of these regions connect points with equal values

• The most common example is contour maps of elevation

• Can also display temperature, rainfall, air pressure, etc.

43

Page 44: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Celsius

Page 45: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Matrix Plots

• Can plot the data matrix

• This can be useful when objects are sorted according to class

• Typically, the attributes are normalized to prevent one attribute from dominating the plot

• Plots of similarity or distance matrices can also be useful for visualizing the relationships between objects

45

Page 46: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Heatmaps 46

Page 47: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Other Visualization Techniques

• Star Plots § Similar approach to parallel coordinates,

but axes radiate from a central point§The line connecting the values of an object is a polygon

• Chernoff Faces§Approach created by Herman Chernoff§This approach associates each attribute with a characteristic of

a face§The values of each attribute determine the appearance of the

corresponding facial characteristic§ Each object becomes a separate face§Relies on human’s ability to distinguish faces

47

Page 48: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 49: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 50: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Chernoff Faces

• More dimensions are plotted using several features of human faces

50

Page 51: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzihttp://cartastrophe.files.wordpress.com/2010/06/spinelli.png

Page 52: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 53: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Examples

Page 54: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

do we read the articles we share?does my banner work?

Page 55: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

“When we combined attention and traffic to find the story that had the largest volume of total engaged time, we found that it had fewer than 100 likes and fewer than 50 tweets. Conversely, the story with the largest number of tweets got about 20% of the total engaged time that the most engaging story received.”

Page 56: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

“Here’s the skinny, 66% of attention on a normal media page is spent below the fold. That leaderboard at the top of the page? People scroll right past that and spend their time where the content not the cruft is. .”

Page 57: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

http://time.com/12933/what-you-think-you-know-about-the-web-is-wrong/?iid=biz-category-mostpop2

Page 58: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

http://apps.startribune.com/news/20140313-beer-me-minnesota/

Page 59: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 60: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 61: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Page 62: DMTM Lecture 19 Data exploration

Prof. Pier Luca Lanzi

Run the Python notebooksfor this lecture