3 Studi Kasus Machine Learning dan Data Mining

  

MACHINE LEARNING

DAN DATA MINING SUPENO MARDI

Kelas Logistik dan Jadwal

  • 36 Pertemuan • Software yang digunakan
    • – Python 3
    • – TensorFlow (TF) + Keras

  • Final Project + Presentasi

Daftar isi

  • Terminologi AI, Machine Learning dan data mining
  • Learning data untuk model
  • Tipe-tipe Tugas Belajar (Learning Tasks)
  • Pendefinisian tugas belajar (Learning Task)
  • Contoh-contoh kasus machine Learning • Data Mining

  

Terminologi

  • Sinonim
    • – Artificial Intelligence – Machine Learning – Data mining
    • – Pattern recognition
    • – Probability and Statistics – Information theory
    • – Numerical optimization
    • – Computational complexity theory
    • – Control theory (adaptive)

  Machine Learning,Statistics dan Data Mining

  • Differences in terminology:
    • – Ridge regression = weight-decay
    • – Fitting = learning
    • – Held-out data = test data

  • The emphasis is very different:
    • – A good piece of statistics: Clever proof that a

  relatively simple estimation procedure is asymptotically unbiased.

  • – A good piece of machine learning: Demonstration

  that a complicated algorithm produces impressive results on a specific task.

  • Data-mining: Using machine learning techniques on very large databases.

  

“Learning” Data

  • Learning general models dari a data of particular examples
  • Data tersedia banyak dan murah(data warehouses, data marts); knowledge mahal dan jarang.
  • Contoh dalam retail: Customer transactions to consumer behavior:

  People who bought “Da Vinci Code” also bought “The Five People You Meet in Heaven” (www.amazon.com)

  • Pembuatan model yang a good and useful approximation to the data.

  Tipe-tipe Tugas Belajar (Learning Tasks)

  • Association • Supervised learning
    • – Learn to predict output when given an input vector

  • Reinforcement learning
    • – Learn action to maximize payoff • Payoff is often delayed • Exploration vs. exploitation

  • Online setting
  • Unsupervised learning
    • – Create an internal representation of the input e.g. form clusters; extract features • How do we know if a representation is good? – Big datasets do not come with labels.

  Learning Associations

  • Basket analysis:

  P (Y | X ) probability that somebody who buys X also buys Y where X and Y are products/services.

  Example: P ( chips | beer ) = 0.7

  Classification

  • Example: Credit scoring
  • Differentiating between low-risk and

  high-risk customers from their income and savings Discriminant: IF income > θ AND savings > θ 1 2 THEN low-risk ELSE high-risk Aplikasi-aplikasi Classification

  • Aka Pattern recognition Pose, lighting, occlusion (glasses,
  • Face recognition:

  beard), make-up, hair style • Character recognition: Different handwriting styles.

  Temporal dependency.

  • Speech recognition: – Use of a dictionary or the syntax of the language.
    • – Sensor fusion: Combine multiple modalities; eg, visual (lip image) and acoustic for speech

  • Medical diagnosis: From symptoms to illnesses
  • 11 • ...

Face Recognition

  Training examples of a person Test images

  The Role of Learning Penggunaan Supervised Learning

  • Prediction of future cases: Use the rule to predict

  the output for future inputs

  • Knowledge extraction: The rule is easy to

  understand

  • Compression: The rule is simpler than the data it

  explains

  Exceptions that are not covered by the rule, e.g., fraud

  • Outlier detection:
  • Learning “what normally happens”
  • Clustering: Grouping similar instances
  • Example applications

  • – Customer segmentation in CRM (customer relationship management)
  • – Image compression: Color quantization
  • – Bioinformatics: Learning motifs

  Displaying the structure of a set of documents

Contoh: Cancer Diagnosis

  • Application: automatic disease detection
  • Importance: this is modern/future medical diagnosis.
  • Prediction goal: Based on past patients, predict whether you have the disease
  • Data: Past patients with and without the disease
  • Target: Cancer or no-cancer
  • Features: Concentrations of various proteins in

  your blood

Contoh: Zipcodes

  • Application: automatic zipcode recognition
  • Importance: this is modern/future delivery of small goods.
  • Goal: Based on your handwritten digits, predict what they are and use them to route mail
  • Data: Black-and-white pixel values
  • Target: Which digit
  • Features: ?

  What makes a 2?

Contoh: Google

  • Application: automatic ad selection • Importance: this is modern/future advertising.
  • Prediction goal: Based on your search query, predict which ads you might be interested in
  • Data: Past queries
  • Target: Whether the ad was clicked
  • Features: ?

Contoh: Call Centers

  • Application: automatic call routing
  • Importance: this is modern/future customer service.
  • Prediction goal: Based on your speech recording, predict which words you said
  • Data: Past recordings of various people
  • Target: Which word was intended
  • Features: ?

Contoh: Stock Market

  • Application: automatic program trading • Importance: this is modern/future finance.
  • Prediction goal: Based on past patterns, predict whether the stock will go up
  • Data: Past stock prices
  • Target: Up or down
  • Features: ?

  Contoh :Web-based

  • The web contains a lot of data. Tasks with very big datasets often use machine learning – especially if the data is noisy or non-stationary.
  • Spam filtering, fraud detection: – The enemy adapts so we must adapt too.
  • Recommendation systems:
    • – Lots of noisy data. Million dollar prize!

  • Information retrieval: – Find documents or images with similar content.

  What is a Learning Problem?

  • Learning involves performance Develop methods, techniques and improving – with experience E – at some task T
  • available data set of training the problem in combination with an learning machines, that can solve tools for building intelligent – evaluated in terms of performance measure P examples>Example: learn to play checkers – Experience E: playing against itself – Task T: playing checkers over time, without reprogramming, its performance at a given task When a learning machine improves – Performance P: percent of games won something. it can be said to have learned
  • What exactly should be learned? – What specific algorithm should be used? – How might this be represented?
Pendefinisian tugas belajar (Learning Task) Improve on task, T, with respect to performance metric, P, based on experience, E.

  T: Playing checkers P: Percentage of games won against an arbitrary opponent E: Playing practice games against itself T: Recognizing hand-written words P: Percentage of words correctly classified

  E: Database of human-labeled images of handwritten words T: Driving on four-lane highways using vision sensors P: Average distance traveled before a human-judged error

  E: A sequence of images and steering commands recorded while observing a human driver.

  T: Categorize email messages as spam or legitimate. P: Percentage of email messages correctly classified.

  E: Database of emails, some with human-given labels

  

Desain sebuah Learning System

  • Pilih : training experience

    • Pilih : what is too be learned, i.e. the target function .

  • Pilih: how to represent the target function.
  • Pilih: a learning algorithm to infer the target function from the experience.

  Learner Environment/ Knowledge Experience

  Performance Element

  

Komponen-komponen sebuah Learning Problem

Task: the behavior or task that’s being improved, e.g. classification, object recognition, acting in an environment.

  • Data: the experiences that are being used to improve performance in the task.
  • Measure of improvements: How can the improvement be measured? Examples:
    • – Provide more accurate solutions (e.g. increasing the accuracy in prediction)
    • – Cover a wider range of problems
    • – Obtain answers more economically (e.g. improved speed)
    • – Simplify codified knowledge
    • – New skills that were not presented initially

What Experience E to Use? Direct or indirect? – Direct: feedback on individual moves

  • Teacher or not?
    • – Indirect: feedback on a sequence of moves • e.g., whether win or not
    • – Teacher selects board states • Can be more efficient • Tailored learning Questions
    • – Learner selects board states • No teacher – Does training experience represent distribution of outcomes in world? – Is training experience representative of performance goal?

What Exactly Should be Learned?

  • Playing checkers: – Choose moves using some function – Alternating moves with well-defined rules Target function (TF): function to be learned during a learning process ChooseMove: Board  Move
    • – Call this function the Target Function  A key to successful learning is to choose appropriate target function:  Strategy: reduce learning to search for TF
    • ChooseMove is difficult to learn, e.g., with indirect training examples Alternative TF for checkers: – Measure “quality” of the board state V : Board  R
    • – Generate all moves • choose move with largest value

  A Possible Target Function V For

Checkers

  • In checkers, know all legal moves

  

V ( b ) w w bp ( b ) w rp ( b ) w bk ( b ) w rk ( b ) w bt ( b ) w rt ( b )

             1 2 3 4 5 6

  • – From these, choose best move in any situation
    • Possible V function for checkers:

  • if b is a final board state that is win, then V(b) = 100
  • – if b is a final board state that is loss, then V(b) = -100
  • – if b is a final board state that is draw, then V(b) = 0
  • – if b is a not a final state in the game, then V(b) = V(b), where b is the

  best final board state that can be achieved starting from b and playing optimally until the end of the game

  • This gives correct values, but is not operational
    • – So may have to find good approximation to V – Call this approximation V

  

How Might Target Function be Represented?

  • Many possibilities (subject of course)
    • – As collection of rules ?
    • – As neural network ? Example of linear function of board features:
    • – As polynomial function of board features ?
    • bp(b) : number of black pieces on board b
    • 1 2 rp(b) + w bk(b)+w rk(b)+w bt(b)+w rt(b)

      3

      4 5 6 bt(b) : number of red pieces threatened by black (i.e., which can be taken on black's next turn) rk(b) : number of red kings on bbk(b) : number of black kings on b Generally, the more expressive the representation, the more difficult it is to estimate rt(b) : number of black pieces threatened by red

      w + w bp(b) + w rp(b) : number of red pieces on b

      

    Inductive and Deductive Learning

    • Inductive Learning: Reasoning from a set of

      examples to produce a general rules. The rules

      should be applicable to new examples, but there is no guarantee that the result will be correct.

    • Deductive Learning: Reasoning from a set of

      known facts and rules to produce additional rules that are guaranteed to be true.

      

    Assessment of Learning Algorithms

    • The most common criteria for learning algorithms assessments are:
      • – Accuracy (e.g. percentages of correctly classified +’s and –’s)

      • – Efficiency (e.g. examples needed, computational tractability)

      • – Robustness (e.g. against noise, against incompleteness)
      • – Special requirements (e.g. incrementality, concept drift)
      • – Concept complexity (e.g. representational issues – examples & bookkeeping)
      • – Transparency (e.g. comprehensibility for the human user)

      

    Data mining dan algorithms

    • Data Mining
      • – The desired outcome from data mining is to create a model from a given

        dataset that can have its insights generalized to similar datasets. A real-

        world example of a successful data mining application can be seen in automatic fraud detection from banks and credit institutions.
      • – Data mining is the process of discovering predictive information from the

        analysis of large databases. For a data scientist, data mining can be a vague and daunting task – it requires a diverse set of skills and knowledge of many data mining techniques to take raw data and successfully get insights from it.  You’ll want to understand and 

      

    that can help you with data mining at

    scale.  

    Teknik-teknik Data mining

    • Finding natural groupings of data objects based upon the known loan request.

      email as spam or legitimate, or looking at a person’s credit score and approving or denying a

      characteristics of that data. An example could be seen in marketing, where analysis can reveal decisions. customer groupings with unique behavior – which could be applied in business strategy
    • Examining outliers to examine potential causes and reasons for said outliers. An example of which is the use of outlier analysis in fraud detection, and trying to buy beer, so stores placed them close to each other to increase sales. determine if a pattern of behavior outside the norm is fraud or not. 

      Contoh pemakaian panda pada model regresi pada Python

    • Menghitung relasi linear diantara variabel yang tersedia, menggunakan data dari 

      from Kaggle. https://www.springboard.com/blog/data-mining-python-tutorial/

    Python script

      import pandas as pd import matplotlib.pyplot as plt import numpy as np import scipy.stats as stats import seaborn as sns from matplotlib import rcParams

    df = pd.read_csv('/Users/python/kc_house_data.csv')

    df.head()

    Tampilan Hasil

      id date price bedrooms bathrooms sqft_living sqft_lot 7129300520 20141013T000000 221900.0 3 1.00 1180 5650 1 6414100192 20141209T000000 538000.0 3 2.25 2570 7242 2 5631500400 20150225T000000 180000.0 2 1.00 770 10000 3 2487200875 20141209T000000 604000.0 4 3.00 1960 5000 4 1954400510 20150218T000000 510000.0 3 2.00 1680 8080

    • df.describe()

      price bedrooms bathrooms sqft_living count 21613 21613 21613 21613 mean 540088.10 3.37 2.11 2079.90 std 367127.20 0.93 0.77 918.44 min 75000.00 0.00 0.00 290.00 25% 321950.00 3.00 1.75 1427.00 50% 450000.00 3.00 2.25 1910.00 75% 645000.00 4.00 2.50 2550.00 max 7700000.00 33.00 8.00 13540.00