Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data? Collection of data objects and their...

52
Data dan Eksplorasi Data Kuliah 2 dan 3 1

Transcript of Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data? Collection of data objects and their...

Page 1: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Data dan Eksplorasi Data

Kuliah 2 dan 3

1

Page 2: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

What is Data?

Collection of data objects and their attributes

An attribute is a property or characteristic of an object Examples: eye color of a person,

temperature, etc. Attribute is also known as variable,

field, characteristic, or feature A collection of attributes describe

an object Object is also known as record,

point, case, sample, entity, or instance

Tid Refund Marital Status

Taxable Income Cheat

1 Yes Single 125K No

2 No Married 100K No

3 No Single 70K No

4 Yes Married 120K No

5 No Divorced 95K Yes

6 No Married 60K No

7 Yes Divorced 220K No

8 No Single 85K Yes

9 No Married 75K No

10 No Single 90K Yes 10

Attributes

Objects

Page 3: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Attribute values Attribute values are numbers or symbols assigned to an

attribute

Distinction between attributes and attribute values Same attribute can be mapped to different attribute values

Example: height can be measured in feet or meters

Different attributes can be mapped to the same set of values Example: Attribute values for ID and age are integers But properties of attribute values can be different

ID has no limit but age has a maximum and minimum value

3

Page 4: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

4

Tipe atribut Deskripsi ContohKategori (kualitatif)

Nominal Nilai dari atribut nominal adalah nama-nama yang berbeda, yaitu nilai nominal hanya menyediakan informasi yang cukup untuk membedakan satu objek dengan objek yang lain. (= dan )

Kode pos, ID Number karyawan, warna mata, jenis kelamin

Ordinal Nilai dari atribut ordinal menyediakan informasi yang cukup mengurutkan objek. (<, >)

Nomor jalan, grade

Numerik (Kuantitatif)

Interval Untuk atribut interval, perbedaan antarnilai adalah sesuatu yang berarti, adanya unit pengukuran. (+,)

Tanggal pada kalender

Ratio Untuk variabel rasio, perbedaan dan rasio merupakan hal yang berarti. (*, /)

Kuantitas moneter, count, umur, panjang, arus listrik

Tipe-tipe atribut yang berbeda

Page 5: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Discrete and Continuous Attributes Discrete Attribute

Has only a finite or countably infinite set of values Examples: zip codes, counts, or the set of words in a collection of

documents Often represented as integer variables. Note: binary attributes are a special case of discrete attributes

Continuous Attribute Has real numbers as attribute values Examples: temperature, height, or weight. Practically, real values can only be measured and represented using a

finite number of digits. Continuous attributes are typically represented as floating-point

variables.

5

Page 6: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Types of data sets

Record Data Matrix Document Data Transaction Data

Graph World Wide Web Molecular Structures

Ordered Spatial Data Temporal Data Sequential Data Genetic Sequence Data

6

Page 7: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Record Data Data that consists of a collection of records, each of

which consists of a fixed set of attributes

Tid Refund Marital Status

Taxable Income Cheat

1 Yes Single 125K No

2 No Married 100K No

3 No Single 70K No

4 Yes Married 120K No

5 No Divorced 95K Yes

6 No Married 60K No

7 Yes Divorced 220K No

8 No Single 85K Yes

9 No Married 75K No

10 No Single 90K Yes 10

7

Page 8: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Transaction Data A special type of record data, where

each record (transaction) involves a set of items. For example, consider a grocery store. The set of products

purchased by a customer during one shopping trip constitute a transaction, while the individual products that were purchased are the items.

TID Items

1 Bread, Coke, Milk

2 Beer, Bread

3 Beer, Coke, Diaper, Milk

4 Beer, Bread, Diaper, Milk

5 Coke, Diaper, Milk

8

Page 9: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Ordered DataTemporal Data • Temporal data is data

whose objects have attributes that represent measurements taken over time.

• For example, financial data set are time series that give the daily prices of various stocks.

• A time series is a sequence of measurements of some attribute

• e.g., stock price or rainfall, taken at (usually regular) points in time.)

9

Page 10: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Ordered Data Sequences of transactions

An element of the sequence

Items/Events

The data still consists of a set of transactions and items, but time and customer ID attributes are associated with each transaction.

10

Page 11: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Data Quality What kinds of data quality problems? How can we detect problems with the data? What can we do about these problems?

Examples of data quality problems: Noise and outliers missing values duplicate data

11

Page 12: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Noise Noise refers to modification of original values

Examples: distortion of a person’s voice when talking on a poor phone and “snow” on television screen

Two Sine Waves Two Sine Waves + Noise12

Page 13: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Outliers Outliers are data objects with characteristics that are

considerably different than most of the other data objects in the data set

13

Page 14: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Missing Values Reasons for missing values

Information is not collected (e.g., people decline to give their age and weight)

Attributes may not be applicable to all cases (e.g., annual income is not applicable to children)

Handling missing values Eliminate Data Objects Estimate Missing Values the missing values can be estimated

(interpolated) by using the remaining values. Ignore the Missing Value During Analysis

e.g., suppose that objects are being clustered and the similarity between pairs of data objects.

the similarity can be calculated by using only the non-missing attributes

14

Page 15: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Duplicate Data Data set may include data objects that are duplicates, or

almost duplicates of one another Major issue when merging data from heterogeous sources Examples: Same person with multiple email addresses

That care needs to be taken to avoid accidentally combining data objects that are similar, but not duplicates.

Data cleaning Process of dealing with duplicate data issues

15

Page 16: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Data Preprocessing Aggregation Sampling Dimensionality Reduction Feature subset selection Feature creation Discretization and Binarization Attribute Transformation

16

Page 17: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Aggregation Combining two or more attributes (or objects) into a

single attribute (or object)

Purpose Data reduction

Reduce the number of attributes or objects Change of scale

Cities aggregated into regions, states, countries, etc More “stable” data

Aggregated data tends to have less variability

17

Page 18: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Several motivations for aggregation Smaller data sets require less memory and processing time. if the aggregation is done properly then the aggregation can

act as a change of scope or scale, providing a high level view of the data instead of a low level view.

the behavior of groups of objects or attributes is often more ‘stable’ that that of individual objects or attributes.

18

Page 19: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Sampling

Sampling is the main technique employed for data selection. It is often used for both the preliminary investigation of the data and

the final data analysis.

Statisticians sample because obtaining the entire set of data of interest is too expensive or time consuming.

Sampling is used in data mining because processing the entire

set of data of interest is too expensive or time consuming.

19

Page 20: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Sampling … The key principle for effective sampling is the following:

using a sample will work almost as well as using the entire data sets, if the sample is representative

A sample is representative if it has approximately the same property (of interest) as the original set of data

if the standard deviation is the property of interest, then a sample is representative if the sample has a standard deviation that is close to that of the original data

20

Page 21: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Types of Sampling Simple Random Sampling

There is an equal probability of selecting any particular item

Sampling without replacement As each item is selected, it is removed from the population

Sampling with replacement Objects are not removed from the population as they are selected for

the sample. In sampling with replacement, the same object can be picked up more than

once

21

Page 22: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Sample Size

8000 points 2000 Points 500 Points

• Larger sample sizes increase the probability that a sample will be representative, but also eliminate much of the advantage of sampling.

• Conversely, with smaller sample sizes, patterns may be missed or erroneous patterns detected.

22

Page 23: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Dimensionality Reduction Purpose:

Reduce amount of time and memory required by data mining algorithms

Allow data to be more easily visualized May help to eliminate irrelevant features or reduce noise

Techniques Principle Component Analysis

23

Page 24: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Feature Subset Selection Another way to reduce dimensionality of data

Redundant features duplicate much or all of the information contained in one or

more other attributes Example: purchase price of a product and the amount of sales

tax paid

Irrelevant features contain no information that is useful for the data mining task

at hand Example: students' ID is often irrelevant to the task of

predicting students' GPA

24

Page 25: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Feature Creation Create new attributes that can capture the important information in a data

set much more efficiently than the original attributes Three general methodologies:

Feature Extraction domain-specific the creation of a new, smaller set of features from the original set of

features. E.g., consider a set of photographs, where each photograph is to be classified

according to whether it contains a human face or not Mapping Data to New Space e.g. for each time series, the Fourier transform produces a new data

object, whose attributes are related to frequencies. Feature Construction

combining features one or more new features constructed out of the original features may be

more useful

25

Page 26: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Attribute Transformation

A function that maps the entire set of values of a given attribute to a new set of replacement values such that each old value can be identified with one of the new values Simple functions: xk, |x| Standardization and Normalization

26

Page 27: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Summary Statistics Summary statistics are numbers that summarize

properties of the data

Summarized properties include frequency, location and spread Examples: location - mean

spread - standard deviation

Most summary statistics can be calculated in a single pass through the data

Page 28: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Frequency and ModeThe 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 a an attribute is the most frequent attribute value The notions of frequency and mode are typically used with

categorical data

Page 29: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

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.

Page 30: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

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.

Page 31: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

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.

Visualization of data is one of the most powerful and appealing techniques for data exploration. Can detect general patterns and trends Can detect outliers and unusual patterns

Page 32: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Example: Sea Surface Temperature The following shows the Sea Surface Temperature (SST) for

July 1982 Tens of thousands of data points are summarized in a single

figure

Page 33: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Representation Is the mapping of information to a visual format Data objects, their attributes, and the relationships among

data objects are translated into graphical elements such as points, lines, shapes, and colors.

Example: 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.

Page 34: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Arrangement Is the placement of visual elements within a display Can make a large difference in how easy it is to understand

the data Example:

Page 35: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Visualization Techniques: Histograms Histogram

Usually shows the distribution of values of a single variable Divide the values into bins and show a bar plot of the number of objects in

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

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

Page 36: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Two-Dimensional Histograms Show the joint distribution of the values of two attributes Example: petal width and petal length

What does this tell us?

Page 37: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Visualization Techniques: Box Plots Box Plots

Invented by J. Tukey Another way of displaying the distribution of data Following figure shows the basic part of a box plot

outlier

10th percentile

25th percentile

75th percentile

50th percentile

10th percentile

Page 38: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Example of Box Plots Box plots can be used to compare attributes

Page 39: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Visualization Techniques: Scatter Plots 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 See example on the next slide

Page 40: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Scatter Plot Array of Iris Attributes

Page 41: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

OLAP On-Line Analytical Processing (OLAP) was proposed by E. F.

Codd, the father of the relational database. Relational databases put data into tables, while OLAP uses

a multidimensional array representation. Such representations of data previously existed in statistics and

other fields There are a number of data analysis and data exploration

operations that are easier with such a data representation.

Page 42: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Creating a Multidimensional Array Two key steps in converting tabular data into a

multidimensional array. First, identify which attributes are to be the dimensions and

which attribute is to be the target attribute whose values appear as entries in the multidimensional array. The attributes used as dimensions must have discrete values The target value is typically a count or continuous value, e.g., the

cost of an item Can have no target variable at all except the count of objects that

have the same set of attribute values Second, find the value of each entry in the multidimensional

array by summing the values (of the target attribute) or count of all objects that have the attribute values corresponding to that entry.

Page 43: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Example: Iris data We show how the attributes, petal length, petal width, and

species type can be converted to a multidimensional array First, we discretized the petal width and length to have

categorical values: low, medium, and high We get the following table - note the count attribute

Page 44: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Example: Iris data (continued) Each unique tuple of petal width, petal length, and species

type identifies one element of the array. This element is assigned the corresponding count value. The figure illustrates

the result. All non-specified

tuples are 0.

Page 45: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Example: Iris data (continued) Slices of the multidimensional array are shown by the

following cross-tabulations What do these tables tell us?

Page 46: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

OLAP Operations: Data Cube The key operation of a OLAP is the formation of a data

cube A data cube is a multidimensional representation of data,

together with all possible aggregates. By all possible aggregates, we mean the aggregates that

result by selecting a proper subset of the dimensions and summing over all remaining dimensions.

For example, if we choose the species type dimension of the Iris data and sum over all other dimensions, the result will be a one-dimensional entry with three entries, each of which gives the number of flowers of each type.

Page 47: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Consider a data set that records the sales of products at a number of company stores at various dates.

This data can be represented as a 3 dimensional array

There are 3 two-dimensionalaggregates (3 choose 2 ),3 one-dimensional aggregates,and 1 zero-dimensional aggregate (the overall total)

Data Cube Example

Page 48: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

The following figure table shows one of the two dimensional aggregates, along with two of the one-dimensional aggregates, and the overall total

Data Cube Example (continued)

Page 49: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

OLAP Operations: Slicing and Dicing Slicing is selecting a group of cells from the entire

multidimensional array by specifying a specific value for one or more dimensions.

Dicing involves selecting a subset of cells by specifying a range of attribute values. This is equivalent to defining a subarray from the complete

array. In practice, both operations can also be accompanied by

aggregation over some dimensions.

Page 50: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

OLAP Operations: Roll-up and Drill-down

Attribute values often have a hierarchical structure. Each date is associated with a year, month, and week. A location is associated with a continent, country, state

(province, etc.), and city. Products can be divided into various categories, such as

clothing, electronics, and furniture. Note that these categories often nest and form a tree or

lattice A year contains months which contains day A country contains a state which contains a city

Page 51: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

OLAP Operations: Roll-up and Drill-down

This hierarchical structure gives rise to the roll-up and drill-down operations. For sales data, we can aggregate (roll up) the sales across all

the dates in a month. Conversely, given a view of the data where the time dimension

is broken into months, we could split the monthly sales totals (drill down) into daily sales totals.

Likewise, we can drill down or roll up on the location or product ID attributes.

Page 52: Data dan Eksplorasi Data Kuliah 2 dan 3 1. What is Data?  Collection of data objects and their attributes  An attribute is a property or characteristic.

Rujukan Tan P., Michael S., & Vipin K. 2006. Introduction to

Data mining. Pearson Education, Inc. Han J & Kamber M. 2006. Data mining – Concept and

Techniques.Morgan-Kauffman, San Diego

52