• No results found

Decision Trees Decision Trees

N/A
N/A
Protected

Academic year: 2022

Share "Decision Trees Decision Trees"

Copied!
30
0
0

Loading.... (view fulltext now)

Full text

(1)

CS 101 Computer Programming  and Utilization

Lecture 9 Lecture 9

Separate compilation of functions Separate compilation of functions

Decision Trees Decision Trees

Feb 8, 2011 Feb 8, 2011

Prof. R K Joshi

(2)

Revision: Functions

Giving names to code segments

A unit of reuse, define once, ensure  correctness, use again and again

Functions and procedures

Functions like mathematical functions

Inputs

An output

No history remembered

Function declaration

Also called 'signature'

Name, input types, output 

Function invocation (call)

Send in the actual  parameters

Obtain a return value

Control transfers to  the function

Caller blocks till a function  call completes

When a call returns, the 

control is transferred back to 

(3)

Separate Compilation

What if you wanted to use a function defined in  your program in some other program?

You will have to copy the code in the program  and then use the function call

This can be avoided by writing the function in a  separate file

The file can be linked with your program

(4)

Separating function definition from its use, and  compiling them separately

Function Definition Source file

(5)

Separating function definition from its use, and  compiling them separately

Function Definition Source file

Compiled  code compile

(6)

Separating function definition from its use, and  compiling them separately

Function Definition Source file

Function  Used in this

Source file

Compiled  code compile

(7)

Separating function definition from its use, and  compiling them separately

Function Definition Source file

Function  Used in this

Source file

Compiled

 code Compiled

code compile

compile

(8)

Separating function definition from its use, and  compiling them separately

Function Definition Source file

Function  Used in this

Source file

Compiled

 code Compiled

code compile

compile link

(9)

Separating function definition from its use, and  compiling them separately

Function Definition Source file

Function  Used in this

Source file

Executable code a.out

Compiled

 code Compiled

code compile

compile link

(10)

Decision Trees

First   second   first number ← ←

Whenever a next number   'n'  comes up..       

       

    What would you do?

      

(11)

Decision Tree

      first==second?

(12)

Decision Tree

      first==second?

    Yes

(13)

Decision Tree

      first==second?

    Yes

n is  higher

(14)

Decision Tree

      first==second?

    Yes

n is      n is  higher     lower

(15)

Decision Tree

      first==second?

    Yes

n is      n is        n is same higher     lower     as both

(16)

Decision Tree

      first==second?

    Yes

n is       n is       n is same higher      lower    as both first   n      ←

(17)

Decision Tree

      first==second?

    Yes

n is       n is       n is same  higher      lower      as both

first   n       second   n← ←

(18)

Decision Tree

      first==second?

    Yes

n is       n is       n is same  higher      lower      as both

first   n       second   n     don't bother← ←

(19)

Decision Tree

      first==second?

    Yes       No

        

(20)

Decision Tree

      first==second?

    Yes       No        

      n in       

       between     

(21)

Decision Tree

      first==second?

    Yes       No

      

 n in       n higher                 between     than first      

(22)

Decision Tree

      first==second?

    Yes       No

      

 n in       n higher        n smaller

       between     than first      than second

(23)

Decision Tree

      first==second?

    Yes       No

      

 n in       n higher      n smaller

       between     than first      than second       

       Second   n       ←        

(24)

Decision Tree

      first==second?

    Yes       No

      

 n in       n higher      n smaller

       between     than first      than second       

       Second   n    second   first     ← ←       First   n      ←

(25)

Decision Tree

      first==second?

    Yes       No

      

 n in       n higher      n smaller

       between     than first      than second       

       Second   n    second   first     don't← ←       First   n      bother←

(26)

Decision Tree

      first==second?

    Yes       No

      

 n in       n higher      n smaller

       between     than first      than second       

       Second   n    second   first     don't← ←       First   n      bother←

(27)

Decision Tree

      first==second?

      No

      

 n in       n higher      n smaller       n same as     n same

       between     than first      than second     first      as second        

       Second   n    second   first     don't      don't      don't ← ←       First   n      bother       bother      bother←

(28)

Another tree

n > first

Yes       No       

 

(29)

Another tree..

n > first 

Yes       No       n=first      

      first < n > second       n = second

      n < second

 

(30)

Yet another tree

N < second?

Yes      no

How will you grow this one?  

References

Related documents

Learn decisions in s in proportion to importance of s Advantages of decision trees over BDDs:. I more

practical methods for establishing convexity of a function 1.. verify definition (often simplified by restricting to a

Segment Classification: Target sequence consist of multiple labels and the segment locations of the input is known in advance, e.g.. the timing where each character ends and

information compared to the succinct description (Decision Trees and Rule Base)..

o Decision trees classify instances by sorting them down the tree from the root to leaf node.. o leaf node provides the classification of the

Action to prevent deforestation and forest degradation where it is most acute, and to expand tree cover within other land uses, is recognized as a cost-effective way to reverse

Chapter 2: This Chapter describes the concept of electrical trees and the necessity of electrical trees detection in XLPE cable insulation, its classification and

The concept of convex extendability is introduced to answer the problem of ÿnding the smallest distance convex simple graph containing a given tree.. A problem of similar type