1 / 39

Προεπεξεργασία Δεδομένων

Προεπεξεργασία Δεδομένων. Εξόρυξη Δεδομένων και Αλγόριθμοι Μάθησης. 1 ο Φροντιστήριο. Σκούρα Αγγελική skoura@ceid.upatras.gr. Η Διαδικασία Εξόρυξης Γνώσης. Κατηγορίες Συνόλων Δεδομένων. Record Relational records Data matrix, e.g., numerical matrix, crosstabs

winola
Download Presentation

Προεπεξεργασία Δεδομένων

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Προεπεξεργασία Δεδομένων Εξόρυξη Δεδομένων και Αλγόριθμοι Μάθησης 1ο Φροντιστήριο Σκούρα Αγγελική skoura@ceid.upatras.gr

  2. Η Διαδικασία Εξόρυξης Γνώσης

  3. Κατηγορίες Συνόλων Δεδομένων • Record • Relational records • Data matrix, e.g., numerical matrix,crosstabs • Document data: text documents: term-frequencyvector • Transaction data • Graph and network • World Wide Web • Social networks • Molecular Structures • Ordered • Video data: sequence of images • Temporal data: time-series • Sequential Data: transaction sequences • Genetic sequence data • Spatial, image and multimedia: • Spatial data: maps • Image data • Video data

  4. Δεδομένα Αντικειμένων • Data sets are made up of data objects • A data object represents an entity • Examples: • sales database: customers, store items, sales • medical database: patients, treatments • university database: students, professors, courses • Also called samples, examples, instances, datapoints, objects,tuples • Data objects are described by attributes • Database rows -> data objects; columns ->attributes • Αποθήκευση δεδομένων σε ένα flat file • Fixed-column μορφή • Delimited format: tab, comma “,” π.χ. το Wekaχρησιμοποιεί comma-delimited δεδομένα

  5. Κατηγορίες Μεταβλητών

  6. Χρησιμότητα Προεπεξεργασίας • No quality data, no quality mining results! • Για να έχουμε ποιοτικά αποτελέσματα από την εξόρυξη γνώσης χρειαζόμαστε ποιοτικά δεδομένα • π.χ., διπλοτυπίες ή τα ελλιπή δεδομένα μπορεί να παράγουν λανθασμένα ή παραπλανητικά συμπεράσματα • Πιο συγκεκριμένα, τα δεδομένα συνήθως είναι ακάθαρτα • Δεν είναι ολοκληρωμένα: λείπουν τιμές χαρακτηριστικών occupation=“ ” (missing data) • Περιέχουν θόρυβο, σφάλματα ή outliers Salary=“−10” (an error) • Είναι αντιφατικά: περιέχουν ασυμφωνίες σε κωδικούς ή ονόματα Age=“42” Birthday=“03/07/1997” Was rating “1,2,3”, now rating “A, B, C” • Μετά την προεπεξεργασία… • Οι αποθήκες δεδομένων θα πρέπει να περιέχουν συνεπή, ενοποιημένα και ποιοτικά δεδομένα

  7. Βασικά βήματα προεπεξεργασίας A. Καθαρισμός δεδομένων (Data cleaning) Συμπλήρωση των χαμένων τιμών, απαλοιφή θορύβου, απομάκρυνση των outliers, διόρθωση ασυνεπειών, απαλοιφή πλεονασμού B. Ενοποίηση δεδομένων (Data integration) Ενοποίηση πολλαπλών βάσεων δεδομένων, κύβων δεδομένων ή αρχείων, απαλοιφή πλεονασμού Γ. Μετασχηματισμός δεδομένων (Data transformation) και Διακριτοποίηση δεδομένων (Data discretization) Κανονικοποίηση, Μετατροπή των numerical τιμών σε nominal Δ. Μείωση δεδομένων (Data reduction) Μείωση διαστατικότητας, μείωση πληθυκότητας, συμπίεση δεδομένων

  8. Βασικά βήματα προεπεξεργασίας Α. Καθαρισμός δεδομένων (Data cleaning) Συμπλήρωση των χαμένων τιμών, απαλοιφή θορύβου, απομάκρυνση των outliers, διόρθωση ασυνεπειών, απαλοιφή πλεονασμού Β. Ενοποίηση δεδομένων (Data integration) Ενοποίηση πολλαπλών βάσεων δεδομένων, κύβων δεδομένων ή αρχείων, απαλοιφή πλεονασμού Γ. Μετασχηματισμός δεδομένων (Data transformation) και Διακριτοποίηση δεδομένων (Data discretization) Κανονικοποίηση, Μετατροπή των numerical τιμών σε nominal Δ. Μείωση δεδομένων (Data reduction) Μείωση διαστατικότητας, μείωση πληθυκότητας, συμπίεση δεδομένων

  9. Α. Καθαρισμός δεδομένων (Data cleaning) • Συμπλήρωση των χαμένων τιμών • Αναγνώριση των outliers και εξομάλυνση δεδομένων • Διόρθωση ασυνεπειών στα δεδομένα • Απαλοιφή πλεονασμού που προκύπτει από την ενοποίηση των δεδομένων • Ignore the tuple: usually done when class label is missing(when doing classification)—not effective when there exist considerable missing values per attribute • Τα missing data μπορεί να πρέπει να εξαχθούν από τα υπάρχοντα δεδομένα με τεχνικές εξαγωγής συμπερασμάτων • Fill in the missing value manually: tedious + infeasible? • Fill in it automatically with • a global constant : e.g., “unknown” • the attribute mean • the attribute mean for all samples belonging to the same class:smarter • the most probable value: inference-based such as Bayesianformula or decision tree

  10. Α. Καθαρισμός δεδομένων (Data cleaning) • Συμπλήρωση των χαμένων τιμών • Αναγνώριση των outliers και εξομάλυνση δεδομένων • Διόρθωση ασυνεπειών στα δεδομένα • Απαλοιφή πλεονασμού που προκύπτει από την ενοποίηση των δεδομένων • Binning • first sort data and partition into (equal-frequency) bins • then one can smooth by bin means, smooth by bin median, smooth by bin boundaries, etc. • Regression • smooth by fitting the data into regression functions • Clustering • detect and remove outliers • Regression • Εξομάλυνση των δεδομένων με χρήση των regression functions

  11. Εξομάλυνση Δεδομένων: Binning method Sorted data for temperature (in C): 4, 8, 9, 15, 21, 21, 24, 25, 26, 28, 29, 34 Partition into (equi-depth) bins: - Bin 1: 4, 8, 9, 15 - Bin 2: 21, 21, 24, 25 - Bin 3: 26, 28, 29, 34 Smoothing by bin means: - Bin 1: 9, 9, 9, 9 - Bin 2: 23, 23, 23, 23 - Bin 3: 29, 29, 29, 29 Smoothing by bin boundaries: - Bin 1: 4, 4, 4, 15 - Bin 2: 21, 21, 25, 25 - Bin 3: 26, 26, 26, 34

  12. Εξομάλυνση δεδομένων και εντοπισμός outliers Clustering Linear Regression

  13. Α. Καθαρισμός δεδομένων (Data cleaning) • Συμπλήρωση των χαμένων τιμών • Αναγνώριση των outliers και εξομάλυνση δεδομένων • Διόρθωση ασυνεπειών στα δεδομένα • Απαλοιφή πλεονασμού που προκύπτει από την ενοποίηση των δεδομένων • Data discrepancy detection • Use metadata (e.g., domain, range, dependency, distribution) • Check field overloading • Check uniqueness rule, consecutive rule and null rule • Use commercial tools • Data scrubbing: use simple domain knowledge (e.g., postalcode, spell-check) to detect errors and make corrections • Data auditing: by analyzing data to discover rules andrelationship to detect violators (e.g., correlation and clustering tofind outliers)

  14. Α. Καθαρισμός δεδομένων (Data cleaning) • Συμπλήρωση των χαμένων τιμών • Αναγνώριση των outliers και εξομάλυνση δεδομένων • Διόρθωση ασυνεπειών στα δεδομένα • Απαλοιφή πλεονασμού που προκύπτει από την ενοποίηση των δεδομένων • Το πρόβλημα του πλεονασμού μπορεί • να υπάρχει εξαρχής αλλά και • να προκύψει μετά την Ενοποίηση των Δεδομένων (Data integration) • Για τρόπους αντιμετώπισης, βλ. επόμενες διαφάνειες

  15. Βασικά βήματα προεπεξεργασίας Α. Καθαρισμός δεδομένων (Data cleaning) Συμπλήρωση των χαμένων τιμών, απαλοιφή θορύβου, απομάκρυνση των outliers, διόρθωση ασυνεπειών, απαλοιφή πλεονασμού Β. Ενοποίηση δεδομένων (Data integration) Ενοποίηση πολλαπλών βάσεων δεδομένων, κύβων δεδομένων ή αρχείων, απαλοιφή πλεονασμού Γ. Μετασχηματισμός δεδομένων (Data transformation) και Διακριτοποίηση δεδομένων (Data discretization) Κανονικοποίηση, Μετατροπή των numerical τιμών σε nominal Δ. Μείωση δεδομένων (Data reduction) Μείωση διαστατικότητας, μείωση πληθυκότητας, συμπίεση δεδομένων

  16. Β. Ενοποίηση δεδομένων (Data integration) • Data integration • Combines data from multiple sources into a coherent store • Schema integration • e.g., A.cust ≡ B.cust-# • Integrate metadata from different sources • Entity identification problem • Identify real world entities from multiple data sources • e.g., Bill Newton= William Newton • Detecting and resolving data value conflicts • For the same real world entity, attribute values from different sources are different • Possible reasons: different representations, different scales, e.g., metric vs. British units

  17. Χειρισμός Πλεονασμού στην Ενοποίηση Δεδομένων • Redundant data occur often when integration of multipledatabases • Object identification: The same attribute or object may havedifferent names in different databases • Derivable data: One attribute may be a“derived” attribute inanother table, e.g., annual revenue • Redundant attributes may be able to be detected bycorrelation analysis

  18. Correlation Analysis

  19. Correlation Analysis (for Categorical Data) • χ2 (chi-square) test • The larger the Χ2 value, the more likely thevariables are related • Example • Suppose that the ratio of male to female students in the Science Faculty is exactly 1:1, but in the Pharmacology Honours class over the past ten years there have been 80 females and 40 males. Is this a significant departure from expectation? • It is given that concerning the χ2 table, the “critical value” for p = 0.05 and 1 degree of freedom is 3.84

  20. Chi-square test example • Set out a table as shown below, with the "observed" numbers and the "expected" numbers (i.e. our null hypothesis). • Then subtract each "expected" value from the corresponding "observed" value (O-E) • Square the "O-E" values, and divide each by the relevant "expected" value to give (O-E)2/E • Add all the (O-E)2/E values and call the total "X2" • Now we must compare our X2 value with a χ2 (chi squared) value in a table of χ2 with n-1 degrees of freedom (where n is the number of categories, i.e. 2 in our case - males and females) • We have only one degree of freedom (n-1) • If our calculated value of X2 exceeds the critical value of χ2 then we have a significant difference from the expectation • In fact, our calculated X2 (13.34) exceeds even the tabulated χ2 value (10.83) for p = 0.001 • This shows an extreme departure from expectation. It is still possible that we could have got this result by chance - a probability of less than 1 in 1000 • But we could be 99.9% confident that some factor leads to a "bias" towards females entering Pharmacology Honours.

  21. Τable of Chi-square test • A significant difference from your null hypothesis (i.e. difference from your expectation) is indicated when your calculated X2 value is greater than the χ2 value shown in the 0.05 column of this table (i.e. there is only a 5% probability that your calculated X2 value would occur by chance) • You can be even more confident if your calculated value exceeds the χ2 values in the 0.01 or 0.001 probability columns • If your calculated X2 value is equal to, or less than, the tabulated χ2 value for 0.95 then your results give you no reason to reject the null hypothesis (the expectation)

  22. Correlation Analysis (for Numerical Data) • In probability theory and statistics, the mathematical descriptions of covariance and correlation are very similar • Both provides a measure of the strength of the correlation between two or more sets of random variables • Correlation and covariance measure onlythe linear relationship between objects • The Covariance for two random variables X and Y, each with size N, is defined by as cov(X, Y) = <(X-μx)(Y-μY)> = <X Y> - μx μY where μX =<X>, μY =<Y> are the respective means • Covariance can be written out explicitly as • For uncorrelated variables , cov(X, Y) = <X Y> - μx μY = <X><Y> - μx μY = 0. • However, if the variables are correlated in some way, then their covariance will be nonzero • In fact, if , then tends to increase as increases, and if , then tends to decrease as increases. • Note that while statistically independent variables are always uncorrelated, the converse is not necessarily true. • In the special case of Y=X, the covariance reduces to the usual variance

  23. Co-Variance example • Suppose two stocks A and B have the following values in one week: (2, 5), (3, 8), (5, 10), (4, 11), (6, 14). • Question: If the stocks are affected by the same industry trends, will their prices rise or fall together? • Answer: • E(A) = (2 + 3 + 5 + 4 + 6)/ 5 = 20/5 = 4 • E(B) = (5 + 8 + 10 + 11 + 14) /5 = 48/5 = 9.6 • Cov(A,B) = (2×5+3×8+5×10+4×11+6×14)/5 − 4 × 9.6 = 4 • Thus, A and B rise together since Cov(A, B) > 0

  24. Βασικά βήματα προεπεξεργασίας Α. Καθαρισμός δεδομένων (Data cleaning) Συμπλήρωση των χαμένων τιμών, απαλοιφή θορύβου, απομάκρυνση των outliers, διόρθωση ασυνεπειών, απαλοιφή πλεονασμού Β. Ενοποίηση δεδομένων (Data integration) Ενοποίηση πολλαπλών βάσεων δεδομένων, κύβων δεδομένων ή αρχείων, απαλοιφή πλεονασμού Γ. Μετασχηματισμός δεδομένων (Data transformation) και Διακριτοποίηση δεδομένων (Data discretization) Κανονικοποίηση, Μετατροπή των numerical τιμών σε nominal Δ. Μείωση δεδομένων (Data reduction) Μείωση διαστατικότητας, μείωση πληθυκότητας, συμπίεση δεδομένων

  25. Γ. Μετασχηματισμός δεδομένων (Data transformation) • Smoothing: Remove noise from data • Aggregation: Summarization, data cube construction • Generalization: Concept hierarchy climbing • Normalization: Scaled to fall within a small, specifiedrange • min-max normalization • z-score normalization • normalization by decimal scaling • Attribute/feature construction • New attributes constructed from the given ones

  26. Τεχνικές Κανονικοποίησης • Σκοπός της κανονικοποίησης: η αντιστοίχιση των τιμών των δεδομένων από το διάστημα [minA, maxA] [new_minA, new_maxA] • Min-max normalization: • Επίσης, υπάρχουν παραλλαγές της min maxκανονικοποίησης ώστε το διάστημα [new_min, new_max]να μην είναι κατ’ ανάγκη το [0,1] • Decimal scaling: (όταν τα δεδομένα προέρχονται από πηγές που διαφέρουν με λογαριθμικό παράγοντα). Παράδειγμαμια πηγή έχει εύρος τιμών [0,1] και μια άλλη πηγή έχει εύρος τιμών [0, 1000]. Σε αυτήν χρησιμοποιείται η τεχνική Decimal scaling.

  27. Min-Max Τεχνική Κανονικοποίησης • Θεωρούμε τα δεδομένα από 30-50 και έστω ότι θέλουμε να τα μετασχηματίσουμε ώστε να κυμαίνονται από 0-1. • Θα χρησιμοποιήσουμε Min-max normalization • Το στοιχείο s=30 αντιστοιχίζεται ως εξής: • s’30 = (30-30)/(50-30) = 0 • Το στοιχείο s=50 αντιστοιχίζεται ως εξής: • s’50= (50-30)/(50-30) = 1 • Το ενδιάμεσο στοιχείο s=35 αντιστοιχίζεται ως εξής: • s’35 = (35-30)/(50-30) = 5/20 = 0.25

  28. Διακριτοποίηση δεδομένων (Data discretization) • Μερικές μεθοδολογίες εξόρυξης δεδομένων μπορούν να χειριστούν nominal τιμές εσωτερικά • Διακριτοποίηση = μετατροπή Numeric Nominal • Διαχωρισμός του πεδίου των χαρακτηριστικών σε intervals • Οι ετικέτες των intervals χρησιμοποιούνται μετά για την αντικατάσταση των δεδομένων • Τυπικές μέθοδοι για διακριτοποίηση(All the methods can be appliedrecursively) • Binning • Histogram analysis • Clustering analysis • Σημ.: Αντίθετα, άλλες μέθοδοι (regression, nearest neighbor) απαιτούν μόνο numeric τιμές • Για να χρησιμοποιήσουμε τα nominal πεδία σε τέτοιες μεθόδους πρέπει να τις μετατρέψουμε σε numeric τιμές

  29. Βασικά βήματα προεπεξεργασίας Α. Καθαρισμός δεδομένων (Data cleaning) Συμπλήρωση των χαμένων τιμών, απαλοιφή θορύβου, απομάκρυνση των outliers, διόρθωση ασυνεπειών, απαλοιφή πλεονασμού Β. Ενοποίηση δεδομένων (Data integration) Ενοποίηση πολλαπλών βάσεων δεδομένων, κύβων δεδομένων ή αρχείων, απαλοιφή πλεονασμού Γ. Μετασχηματισμός δεδομένων (Data transformation) και Διακριτοποίηση δεδομένων (Data discretization) Κανονικοποίηση, Μετατροπή των numerical τιμών σε nominal Δ. Μείωση δεδομένων (Data reduction) Μείωση διαστατικότητας, μείωση πληθυκότητας, συμπίεση δεδομένων

  30. Δ. Μείωση δεδομένων (Data reduction) • Πρόβλημα: • Μεγάλες αποθήκες δεδομένων μπορούν να έχουν terabytes δεδομένων • Πολύπλοκη ανάλυση δεδομένων και εξόρυξη γνώσης μπορεί να απαιτήσει πολύ χρόνο • Λύση: • Μείωση δεδομένων, δηλαδή να διατηρούνται μειωμένες αναπαραστάσεις δεδομένων σε χωρητικότητα αλλά πρέπει να διατηρούνται ίδια ή παρόμοια αποτελέσματα ανάλυσης • Στρατηγικές: • Data cube aggregation • Dimension Reduction • Instance Selection • Value Discretization • Συμπίεση δεδομένων • Numerosityreduction

  31. Data Cube Aggregation • Το χαμηλότερο επίπεδο ενός data cube • Τα συναθροισμένα δεδομένα για μια ξεχωριστή οντότητα ενδιαφέροντος • Πολλαπλά επίπεδα συνάθροισης σε data cubes • Επιπλέον μείωση του μεγέθους των δεδομένων που θα χρησιμοποιηθούν • Αναφορά σε κατάλληλα επίπεδα • Χρησιμοποιούμε την λιγότερη δυνατή πληροφορία για την επίλυση του προβλήματος μας

  32. Μείωση διαστάσεων • Μπορεί να επιτευχθεί με δύο μεθόδους: • Επιλογή χαρακτηριστικών: Επιλογή ενός ελάχιστου πλήθους m χαρακτηριστικών με τα οποία είναι δυνατή η εξαγωγή ισοδύναμων ή κοντινών αποτελεσμάτων με αυτά που θα είχαμε αν είχαμε κρατήσει όλα τα χαρακτηριστικά για ανάλυση n. Ιδανικά m <<< n. • Μετασχηματισμός χαρακτηριστικών: Είναι γνωστός ως Principle Component Analysis. Ο μετασχηματισμός των χαρακτηριστικών δημιουργεί ένα νέο σύνολο χαρακτηριστικών, λιγότερων διαστάσεων από το αρχικό, αλλά χωρίς μείωση των βασικών διαστάσεων. Επίσης, συχνά χρησιμοποιείται για την οπτικοποίηση των δεδομένων.

  33. Instance Selection • Η επιλογή περιπτώσεων (instance selection) μπορεί να επιτευχθεί με δύο τύπους μεθόδων: • Samplingmethods : • Random Sampling- randomly select "m" instances from the "n" initial instances. • Stratified Sampling- randomly select "m" instances from the "n" initial instances, such that the distribution of classes is maintained in the selected sample. • Search-based methods : • Search for representative instances in the data, based on some criterion and remove the remaining instances. • Use Statistical measures (number of instances, mean or standard deviations) to replace redundant instances with their representative pseudo-instances.

  34. Συμπίεση δεδομένων

  35. Συμπίεση δεδομένων: Huffman • Huffman Coding = lossless compression algorithms • A Huffman encoder takes a block of input characters with fixed length and produces a block of output bits of variable length • It is a fixed-to-variable length code • The design of the Huffman code is optimal (for a fixed blocklength) assuming that the source statistics are known a priori • A Huffman code is designed by merging together the two least probable characters, and repeating this process until there is only one character remaining. A code tree is thus generated and the Huffman code is obtained from the labeling of the code tree.

  36. Συμπίεση δεδομένων: Huffman Gif of the procedure at http://www.data-compression.com/lossless.shtml

  37. Συμπίεση σημάτων • Wavelet Μετασχηματισμοί • Τεχνική που εφαρμόζεται σε ένα διάνυσμα D και το μετασχηματίζει σε ένα αριθμητικά διαφορετικό διάνυσμα D’ ίδιου μήκους • Κυρίως χρησιμοποιείται για συμπίεση χρονοσειρών • Παράδειγμα 2 τύπων wavelet μετασχηματισμών • Daubechies μετασχηματισμός • Haarμετασχηματισμός

  38. Μείωση Πολυαριθμίας (Numerosity reduction) • Παραμετροποιήσιμες μέθοδοι • Χρησιμοποιείται ένα μοντέλο(ή μια συνάρτηση) για την εκτίμηση των δεδομένων και έτσι αποθηκεύονται μόνο οι παράμετροι του αντί των δεδομένων • Log-linear μοντέλα τα οποία διατηρούν διακριτά πολυδιάστατες πιθανοτικές κατανομές • Μη-παραμετροποιήσιμες μέθοδοι • Ιστογράμματα • Συσταδοποίηση • Δειγματοληψία

  39. Τέλος παρουσίασης Απορίες?

More Related