SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
Week02
                                             The Author

                                        November 24, 2009


1    Exercise 1




2    Exercise 2
    • Intuitively, a1 has a higher information gain. The value of a2 has equal distribution
      for both classes, which shows no discriminative ability.

    • H(class) = − 1 log2 ( 1 ) − 1 log2 ( 2 ) = 1
                   2        2     2
                                           1


    • Gain for a1
      H(a1 , true) = − 1 log2 ( 1 ) − 2 log2 ( 3 ) = 0.9183
                       3        3      3
                                               2

      H(a1 , f alse) = − 3 log2 ( 3 ) − 3 log2 ( 2 ) = 0.9183
                         1        1      2
                                                 3
      H(a1 ) = 2 ∗ 0.9183 + 1 ∗ 0.9183 = 0.9183
                 1
                               2
      Gain(a1 ) = 1 − 0.9183 = 0.0817



                                                     1
studentID      score     class
                                      st1            9         yes
                                      st2            4         no
                                      st3            7         yes
                                      ...

                                  Table 1: Example of overfitting

    • Gain for a2
      H(a2 , true) = − 1 log2 ( 1 ) − 1 log2 ( 2 ) = 1
                       2        2      2
                                               1

      H(a2 , f alse) = − 2 log2 ( 2 ) − 2 log2 ( 1 ) = 1
                         1        1      1
                                                 2
                 1
      H(a2 ) = 2 ∗ 1 + 1 ∗ 1 = 1
                        2
      Gain(a2 ) = 1 − 1 = 0



3    Exercise 3
Assume we have following training example shown in Tab 3: For the attribute studentID,
it’s unique for each instance. In the training data, we can easily get the target class value
as long as know the studentID. However, this can not be generalized to unseen data, i.e.,
given a new studentID, we won’t be able to predict its class label.


4    Exercise 4
Example: if an attribute has n values, in an extreme case, we can have a data set of n
instances and each instance has a different value. Assume that we have a binary target,
then for each value of the attribute, the entropy of each value of the attribute is H(Sv ) =
−0 ∗ log2 0 − 1 ∗ log2 1 = 0
                                                               |Sv |
                          H(S, A) = H(S) −                           ∗ 0 = H(S)          (1)
                                                                |S|
                                                 v∈values(A)

since H(S, A) <= H(S), H(S) is the maximum gain we can have, so that the attribute in
this extreme case will always be selected by the information gain criterion. However, this
is not a good choice. (Consider the over-fitting problem discussed in exercise 3)


5    Exercise 5
    • Assign the most common value among examples for the missing value, i.e., “true” for
      attribute a1 at instance 2. In this case, we have
      gain(a1 ) = H(class) − H(class, a1 ) = H(class) − ( 3 H([2, 1]) + 1 H([1, 0]))
                                                          4             4


                                                    2
• A new value “missing” can be assigned to attribute a1 for instance 2. In this case,
  we have
  gain(a1 ) = H(class) − ( 1 H([1, 1]) + 1 H([1, 0]) + 1 H([1, 0]))
                           2             4             4




                                        3

Weitere ähnliche Inhalte

Was ist angesagt?

Engr 213 midterm 1b sol 2009
Engr 213 midterm 1b sol 2009Engr 213 midterm 1b sol 2009
Engr 213 midterm 1b sol 2009akabaka12
 
Day 4 evaluating with add and subtract
Day 4 evaluating with add and subtractDay 4 evaluating with add and subtract
Day 4 evaluating with add and subtractErik Tjersland
 
Yr.12 Transition Workshop 2012-2013
Yr.12 Transition Workshop 2012-2013Yr.12 Transition Workshop 2012-2013
Yr.12 Transition Workshop 2012-2013rdk.rdk
 
Quadratic functions and models
Quadratic functions and modelsQuadratic functions and models
Quadratic functions and modelsTarun Gehlot
 
Lesson 21: Curve Sketching (slides)
Lesson 21: Curve Sketching (slides)Lesson 21: Curve Sketching (slides)
Lesson 21: Curve Sketching (slides)Matthew Leingang
 
0101: Graphing Quadratic Functions
0101: Graphing Quadratic Functions0101: Graphing Quadratic Functions
0101: Graphing Quadratic Functionskijo13
 
Concept map function
Concept map functionConcept map function
Concept map functionzabidah awang
 
Introduction to inverse problems
Introduction to inverse problemsIntroduction to inverse problems
Introduction to inverse problemsDelta Pi Systems
 
Algebra 1 chapter 2 notes
Algebra 1 chapter 2 notesAlgebra 1 chapter 2 notes
Algebra 1 chapter 2 noteshhennigan
 
Chapter 1 functions
Chapter 1  functionsChapter 1  functions
Chapter 1 functionsUmair Pearl
 
Multiplying Polynomials
Multiplying PolynomialsMultiplying Polynomials
Multiplying Polynomialsnina
 
Linear algebra-solutions-manual-kuttler-1-30-11-otc
Linear algebra-solutions-manual-kuttler-1-30-11-otcLinear algebra-solutions-manual-kuttler-1-30-11-otc
Linear algebra-solutions-manual-kuttler-1-30-11-otckjalili
 
Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...
Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...
Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...MarcelloSantosChaves
 

Was ist angesagt? (18)

Engr 213 midterm 1b sol 2009
Engr 213 midterm 1b sol 2009Engr 213 midterm 1b sol 2009
Engr 213 midterm 1b sol 2009
 
Day 4 evaluating with add and subtract
Day 4 evaluating with add and subtractDay 4 evaluating with add and subtract
Day 4 evaluating with add and subtract
 
Cs 601
Cs 601Cs 601
Cs 601
 
Yr.12 Transition Workshop 2012-2013
Yr.12 Transition Workshop 2012-2013Yr.12 Transition Workshop 2012-2013
Yr.12 Transition Workshop 2012-2013
 
Quadratic functions and models
Quadratic functions and modelsQuadratic functions and models
Quadratic functions and models
 
Lesson 21: Curve Sketching (slides)
Lesson 21: Curve Sketching (slides)Lesson 21: Curve Sketching (slides)
Lesson 21: Curve Sketching (slides)
 
0101: Graphing Quadratic Functions
0101: Graphing Quadratic Functions0101: Graphing Quadratic Functions
0101: Graphing Quadratic Functions
 
Sect3 7
Sect3 7Sect3 7
Sect3 7
 
Concept map function
Concept map functionConcept map function
Concept map function
 
Introduction to inverse problems
Introduction to inverse problemsIntroduction to inverse problems
Introduction to inverse problems
 
11848 ch04(1) (1)
11848 ch04(1) (1)11848 ch04(1) (1)
11848 ch04(1) (1)
 
Algebra 1 chapter 2 notes
Algebra 1 chapter 2 notesAlgebra 1 chapter 2 notes
Algebra 1 chapter 2 notes
 
Chapter 1 functions
Chapter 1  functionsChapter 1  functions
Chapter 1 functions
 
Multiplying Polynomials
Multiplying PolynomialsMultiplying Polynomials
Multiplying Polynomials
 
Algebra
AlgebraAlgebra
Algebra
 
Composite functions
Composite functionsComposite functions
Composite functions
 
Linear algebra-solutions-manual-kuttler-1-30-11-otc
Linear algebra-solutions-manual-kuttler-1-30-11-otcLinear algebra-solutions-manual-kuttler-1-30-11-otc
Linear algebra-solutions-manual-kuttler-1-30-11-otc
 
Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...
Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...
Profº. Marcelo Santos Chaves - Cálculo I (Limites e Continuidades) - Exercíci...
 

Ähnlich wie Week02 answer

Ähnlich wie Week02 answer (20)

Up1 math t 2012
Up1 math t 2012Up1 math t 2012
Up1 math t 2012
 
Number theory lecture (part 2)
Number theory lecture (part 2)Number theory lecture (part 2)
Number theory lecture (part 2)
 
Assignment6
Assignment6Assignment6
Assignment6
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Statistical Inference Using Stochastic Gradient Descent
Statistical Inference Using Stochastic Gradient DescentStatistical Inference Using Stochastic Gradient Descent
Statistical Inference Using Stochastic Gradient Descent
 
Statistical Inference Using Stochastic Gradient Descent
Statistical Inference Using Stochastic Gradient DescentStatistical Inference Using Stochastic Gradient Descent
Statistical Inference Using Stochastic Gradient Descent
 
Funcion gamma
Funcion gammaFuncion gamma
Funcion gamma
 
3.2 factoring polynomials
3.2   factoring polynomials3.2   factoring polynomials
3.2 factoring polynomials
 
Jacob's and Vlad's D.E.V. Project - 2012
Jacob's and Vlad's D.E.V. Project - 2012Jacob's and Vlad's D.E.V. Project - 2012
Jacob's and Vlad's D.E.V. Project - 2012
 
Last+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptxLast+minute+revision(+Final)+(1) (1).pptx
Last+minute+revision(+Final)+(1) (1).pptx
 
Em01 ba
Em01 baEm01 ba
Em01 ba
 
8-6 Solving Rational Functions
8-6 Solving Rational Functions8-6 Solving Rational Functions
8-6 Solving Rational Functions
 
Variations on the method of Coleman-Chabauty
Variations on the method of Coleman-ChabautyVariations on the method of Coleman-Chabauty
Variations on the method of Coleman-Chabauty
 
Magic graphs
Magic graphsMagic graphs
Magic graphs
 
Circles and Tangent Lines
Circles and Tangent LinesCircles and Tangent Lines
Circles and Tangent Lines
 
Number theory lecture (part 1)
Number theory lecture (part 1)Number theory lecture (part 1)
Number theory lecture (part 1)
 
Exponential functions
Exponential functionsExponential functions
Exponential functions
 
Appendex
AppendexAppendex
Appendex
 
CH04.ppt
CH04.pptCH04.ppt
CH04.ppt
 
10.1 Distance and Midpoint Formulas
10.1 Distance and Midpoint Formulas10.1 Distance and Midpoint Formulas
10.1 Distance and Midpoint Formulas
 

Mehr von okeee

Dm uitwerkingen wc4
Dm uitwerkingen wc4Dm uitwerkingen wc4
Dm uitwerkingen wc4okeee
 
Dm uitwerkingen wc2
Dm uitwerkingen wc2Dm uitwerkingen wc2
Dm uitwerkingen wc2okeee
 
Dm uitwerkingen wc1
Dm uitwerkingen wc1Dm uitwerkingen wc1
Dm uitwerkingen wc1okeee
 
Dm uitwerkingen wc3
Dm uitwerkingen wc3Dm uitwerkingen wc3
Dm uitwerkingen wc3okeee
 
Dm uitwerkingen wc1
Dm uitwerkingen wc1Dm uitwerkingen wc1
Dm uitwerkingen wc1okeee
 
Dm part03 neural-networks-handout
Dm part03 neural-networks-handoutDm part03 neural-networks-handout
Dm part03 neural-networks-handoutokeee
 
Dm part03 neural-networks-homework
Dm part03 neural-networks-homeworkDm part03 neural-networks-homework
Dm part03 neural-networks-homeworkokeee
 
10[1].1.1.115.9508
10[1].1.1.115.950810[1].1.1.115.9508
10[1].1.1.115.9508okeee
 
Hcm p137 hilliges
Hcm p137 hilligesHcm p137 hilliges
Hcm p137 hilligesokeee
 
Prob18
Prob18Prob18
Prob18okeee
 
Overfit10
Overfit10Overfit10
Overfit10okeee
 
Decision tree.10.11
Decision tree.10.11Decision tree.10.11
Decision tree.10.11okeee
 
Dm week01 linreg.handout
Dm week01 linreg.handoutDm week01 linreg.handout
Dm week01 linreg.handoutokeee
 
Dm week02 decision-trees-handout
Dm week02 decision-trees-handoutDm week02 decision-trees-handout
Dm week02 decision-trees-handoutokeee
 
Dm week01 prob-refresher.handout
Dm week01 prob-refresher.handoutDm week01 prob-refresher.handout
Dm week01 prob-refresher.handoutokeee
 
Dm week01 intro.handout
Dm week01 intro.handoutDm week01 intro.handout
Dm week01 intro.handoutokeee
 
Dm week01 homework(1)
Dm week01 homework(1)Dm week01 homework(1)
Dm week01 homework(1)okeee
 
Chapter7 huizing
Chapter7 huizingChapter7 huizing
Chapter7 huizingokeee
 
Chapter8 choo
Chapter8 chooChapter8 choo
Chapter8 choookeee
 
Chapter6 huizing
Chapter6 huizingChapter6 huizing
Chapter6 huizingokeee
 

Mehr von okeee (20)

Dm uitwerkingen wc4
Dm uitwerkingen wc4Dm uitwerkingen wc4
Dm uitwerkingen wc4
 
Dm uitwerkingen wc2
Dm uitwerkingen wc2Dm uitwerkingen wc2
Dm uitwerkingen wc2
 
Dm uitwerkingen wc1
Dm uitwerkingen wc1Dm uitwerkingen wc1
Dm uitwerkingen wc1
 
Dm uitwerkingen wc3
Dm uitwerkingen wc3Dm uitwerkingen wc3
Dm uitwerkingen wc3
 
Dm uitwerkingen wc1
Dm uitwerkingen wc1Dm uitwerkingen wc1
Dm uitwerkingen wc1
 
Dm part03 neural-networks-handout
Dm part03 neural-networks-handoutDm part03 neural-networks-handout
Dm part03 neural-networks-handout
 
Dm part03 neural-networks-homework
Dm part03 neural-networks-homeworkDm part03 neural-networks-homework
Dm part03 neural-networks-homework
 
10[1].1.1.115.9508
10[1].1.1.115.950810[1].1.1.115.9508
10[1].1.1.115.9508
 
Hcm p137 hilliges
Hcm p137 hilligesHcm p137 hilliges
Hcm p137 hilliges
 
Prob18
Prob18Prob18
Prob18
 
Overfit10
Overfit10Overfit10
Overfit10
 
Decision tree.10.11
Decision tree.10.11Decision tree.10.11
Decision tree.10.11
 
Dm week01 linreg.handout
Dm week01 linreg.handoutDm week01 linreg.handout
Dm week01 linreg.handout
 
Dm week02 decision-trees-handout
Dm week02 decision-trees-handoutDm week02 decision-trees-handout
Dm week02 decision-trees-handout
 
Dm week01 prob-refresher.handout
Dm week01 prob-refresher.handoutDm week01 prob-refresher.handout
Dm week01 prob-refresher.handout
 
Dm week01 intro.handout
Dm week01 intro.handoutDm week01 intro.handout
Dm week01 intro.handout
 
Dm week01 homework(1)
Dm week01 homework(1)Dm week01 homework(1)
Dm week01 homework(1)
 
Chapter7 huizing
Chapter7 huizingChapter7 huizing
Chapter7 huizing
 
Chapter8 choo
Chapter8 chooChapter8 choo
Chapter8 choo
 
Chapter6 huizing
Chapter6 huizingChapter6 huizing
Chapter6 huizing
 

Week02 answer

  • 1. Week02 The Author November 24, 2009 1 Exercise 1 2 Exercise 2 • Intuitively, a1 has a higher information gain. The value of a2 has equal distribution for both classes, which shows no discriminative ability. • H(class) = − 1 log2 ( 1 ) − 1 log2 ( 2 ) = 1 2 2 2 1 • Gain for a1 H(a1 , true) = − 1 log2 ( 1 ) − 2 log2 ( 3 ) = 0.9183 3 3 3 2 H(a1 , f alse) = − 3 log2 ( 3 ) − 3 log2 ( 2 ) = 0.9183 1 1 2 3 H(a1 ) = 2 ∗ 0.9183 + 1 ∗ 0.9183 = 0.9183 1 2 Gain(a1 ) = 1 − 0.9183 = 0.0817 1
  • 2. studentID score class st1 9 yes st2 4 no st3 7 yes ... Table 1: Example of overfitting • Gain for a2 H(a2 , true) = − 1 log2 ( 1 ) − 1 log2 ( 2 ) = 1 2 2 2 1 H(a2 , f alse) = − 2 log2 ( 2 ) − 2 log2 ( 1 ) = 1 1 1 1 2 1 H(a2 ) = 2 ∗ 1 + 1 ∗ 1 = 1 2 Gain(a2 ) = 1 − 1 = 0 3 Exercise 3 Assume we have following training example shown in Tab 3: For the attribute studentID, it’s unique for each instance. In the training data, we can easily get the target class value as long as know the studentID. However, this can not be generalized to unseen data, i.e., given a new studentID, we won’t be able to predict its class label. 4 Exercise 4 Example: if an attribute has n values, in an extreme case, we can have a data set of n instances and each instance has a different value. Assume that we have a binary target, then for each value of the attribute, the entropy of each value of the attribute is H(Sv ) = −0 ∗ log2 0 − 1 ∗ log2 1 = 0 |Sv | H(S, A) = H(S) − ∗ 0 = H(S) (1) |S| v∈values(A) since H(S, A) <= H(S), H(S) is the maximum gain we can have, so that the attribute in this extreme case will always be selected by the information gain criterion. However, this is not a good choice. (Consider the over-fitting problem discussed in exercise 3) 5 Exercise 5 • Assign the most common value among examples for the missing value, i.e., “true” for attribute a1 at instance 2. In this case, we have gain(a1 ) = H(class) − H(class, a1 ) = H(class) − ( 3 H([2, 1]) + 1 H([1, 0])) 4 4 2
  • 3. • A new value “missing” can be assigned to attribute a1 for instance 2. In this case, we have gain(a1 ) = H(class) − ( 1 H([1, 1]) + 1 H([1, 0]) + 1 H([1, 0])) 2 4 4 3