-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ai lessons #2029
base: master
Are you sure you want to change the base?
Ai lessons #2029
Changes from 22 commits
51f2ac7
0850c2c
6d5a21e
847ee4d
c71822c
64896a3
1634be5
933de9b
c9daaaf
3cc772f
cfc2582
8920e66
008feef
6ce4ef1
5372018
e55e7a3
9477886
fbb174f
443fc12
2abc652
01b9070
8c1193d
0a56724
0e7161d
a3c6190
0ed5616
9b54d79
d904029
41af4d5
897a04f
1de0757
d122785
73f2a8c
4a461c2
d5414d9
1fd603b
8b4c9e1
3a3e27f
00e57e5
bcdb715
9edc7cc
5bbfa09
9a7f36d
f16da8f
c602736
f858b52
baaa679
061fd85
f3ded58
1607cce
e4e3962
7727de0
7f59606
c42d31a
5ec0751
5aa9fff
1e7ca43
177d7a0
15110db
ef04339
55953f1
b739182
9bc3878
bfcb596
e167acd
b90be4e
ea97543
fd0817c
c4e0382
bbc2654
3821c29
c11ef89
995be15
d60e012
e221008
9847dd8
6387d74
f1b69ad
3c400ae
b443756
44e9844
4c2529f
f97f9cf
8261818
14292ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"tree1.png" : { | ||
"description" : "A portion of a decision tree (leading from utensil to knife) with two levels.", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"tree2.png" : { | ||
"description" : "A portion of a decision tree (leading from utensil to knife, and from not-utensil to cup) with three levels.", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"tree3.png" : { | ||
"description" : "A decision tree that categorizes knife, fork, spoon, plate, mug, and cup", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"incomplete-tree.png" : { | ||
"description" : "A decision tree (with blanks) that categorizes knife, fork, spoon, plate, mug, and cup", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"tree4.png" : { | ||
"description" : "A less-accurate decision tree that categorizes knife, fork, spoon, plate, mug, and cup.", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"age-stump.png" : { | ||
"description" : "A one-level decision tree showing three branches (teens, twenties and thirties), coming from the root node of age.", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"age-stump-checks.png" : { | ||
"description" : "A one-level decision tree showing three branches (teens, twenties and thirties), coming from the root node of age with checkmarks indicating correct predictions", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"blank-stump.png" : { | ||
"description" : "A blank decision tree stump", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"final-tree.png" : { | ||
"description" : "A decision tree that predicts if individuals will buy a video game", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"history-stump.png" : { | ||
"description" : "A decision tree stump for the column shopping history", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"interest-stump.png" : { | ||
"description" : "A decision tree stump for the column interest in game", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"terminology-tree.png" : { | ||
"description" : "A decision tree indicating where the root, nodes, and leaves are located", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"iris-data.png" : { | ||
"description" : "An excerpt of Ronald Fisher's Iris dataset", | ||
"source" : "Created by the Bootstrap", | ||
"license" : "Creative Commons 4.0 - NC - SA", | ||
"caption" : "British statistician and biologist Ronald Fisher first published his findings about the Iris Dataset in 1936. The dataset includes 150 different plants' sepal length, sepal width, petal length, and petal width. Today, this dataset is considered a go-to dataset useful for illustrating a wide range of problems in data science and machine learning." | ||
} | ||
} |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
= Building and Testing a Decision Tree | ||
|
||
On @printable-exercise{level-1.adoc}, we decided that the decision mode at the end of the "teens" branch should be "interest in game". Let's create the rest of the tree and test it out. You can refer to the training dataset on @handout{decision-tree-data.adoc}. | ||
|
||
== Build and Understand the Tree | ||
|
||
@vspace{1ex} | ||
|
||
Fill in the remainder of the tree using the algorithm you have learned (left) before filling in the blanks (right). | ||
|
||
@vspace{1ex} | ||
|
||
[cols="1,1", stripes="none"] | ||
|=== | ||
|
||
| | ||
@ifnotsoln{@center{@image{../images/incomplete-tree.png, 350}}} | ||
|
||
@ifsoln{@center{@image{../images/final-tree.png, 350}}} | ||
|
||
| | ||
|
||
@n The root node of this tree is @fitb{10em}{@ifsoln{age}}. | ||
|
||
|
||
@n The first set of branches includes @fitb{10em}{@ifsoln{teens}}, @fitb{10em}{@ifsoln{twenties}}, and @fitb{10em}{@ifsoln{thirties}}. | ||
|
||
@vspace{1ex} | ||
|
||
@n Write the rules that this decision tree follows: @ifsoln{Answers will vary.} | ||
|
||
|
||
a) Predict that @fitb{10em}{@ifsoln{interested teens}} will buy the game. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is relevant here, but also for a number of other fitbrubies where it's a "will" or "will not" answer: Why not just phrase this as a question, and let kids write yes or no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I want them to write the rules that the decision tree follows. you disagree with this? Trees are considered simple and flexible because they produce these easy-to-interpret rules. |
||
|
||
@vspace{1ex} | ||
|
||
b) Predict that *all* individuals in their twenties @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
|
||
c) Predict that @fitb{15em}{@ifsoln{new customers in their thirties}} will not buy the game. | ||
|
||
|=== | ||
|
||
|
||
== Test the Tree | ||
|
||
@vspace{1ex} | ||
|
||
Let's see how well our decision tree predicts if Kat, Billy, or Chen will buy the game. | ||
|
||
@vspace{1ex} | ||
|
||
[cols="2,2,3,2,2", stripes="none", options="header"] | ||
|=== | ||
|
||
| name | age | shopping history | interest in game | buys game | ||
| Kat | teen | new customer | yes | yes | ||
| Billy | twenties | new customer | no | no | ||
| Chen | twenties | previous customer | no | no | ||
|
||
|=== | ||
|
||
@n What prediction will the decision tree make for Kat? @fitb{10em}{@ifsoln{will buy}} Billy? @fitb{10em}{@ifsoln{will buy}} Chen? @fitb{10em}{@ifsoln{will buy}} | ||
|
||
@n Compare the test data with the decision tree recommendations. How often was the computer correct? @fitb{}{@ifsoln{1 out of 3 times}} | ||
|
||
@n Based on this new test data, which rule (see Q3, above) needs to change? Why? @fitb{}{@ifsoln{We need to change Rule b,}} | ||
|
||
@fitb{}{@ifsoln{that all individuals in their 20s will buy the game. The new test data contradicts the rule.}} | ||
|
||
== Reflect | ||
|
||
@n The decision tree we built was correct 100% of the time with our training dataset, but correct only 33% of with our test dataset. Why? | ||
|
||
@fitb{}{@ifsoln{The training dataset is small, and only represents a sample of the population. The sample was not representative,}} | ||
|
||
@fitb{}{@ifsoln{as there are individuals in their twenties who choose not to purchase, among others who contradict the training data.}} | ||
|
||
@n What could we do to improve the quality of this decision tree? @fitb{}{@ifsoln{We would need to collect a bigger, more representative dataset,}} | ||
|
||
@fitb{}{@ifsoln{and then build the tree again.}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
= Comparing Decision Trees | ||
|
||
Use the two decision trees (below) to respond to the prompts. | ||
|
||
[cols="^.^1,^.^1", stripes="none"] | ||
|=== | ||
|
||
| | ||
|
||
@image{../images/tree3.png, 300} | ||
|
||
| | ||
|
||
@image{../images/tree4.png, 290} | ||
|
||
|=== | ||
|
||
@n What do you Notice about the two decision trees above? | ||
|
||
@fitb{}{@ifsoln{The trees are different because the "not flat" branch of the tree on the right terminates with "mug or cup".}} | ||
|
||
@fitb{}{} | ||
|
||
@fitb{}{} | ||
|
||
@n What do you Wonder about the two decision trees? | ||
|
||
@fitb{}{} | ||
|
||
@fitb{}{} | ||
|
||
@fitb{}{} | ||
|
||
@n The tree on the @fitbruby{10em}{@ifsoln{left}}{[left / right]} is more accurate, while the tree on the @fitbruby{10em}{@ifsoln{right}}{[left / right]} is more efficient. | ||
retabak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@n With AI, there is often a trade-off between *efficiency* and *accuracy*. Explain what this statement means to you by describing the efficiency and accuracy of the two example trees. | ||
|
||
@fitb{}{@ifsoln{The tree with four nodes cannot label the six listed items with 100% accuracy. It cannot distinguish between "cup" and "mug".}} | ||
|
||
@fitb{}{@ifsoln{The tree with five nodes is more accurate and knows the difference between "cup" and "mug", but it is less efficient.}} | ||
|
||
@fitb{}{} | ||
|
||
@n How will the decision tree on the left label the items below? Explain your response. | ||
|
||
@indented{ | ||
a) knife @fitb{}{@ifsoln{"knife"}} | ||
|
||
@fitb{}{} | ||
|
||
b) chopstick @fitb{}{@ifsoln{uncertain response... maybe "mug"?}} | ||
|
||
@fitb{}{} | ||
|
||
c) spork @fitb{}{@ifsoln{"fork"}} | ||
|
||
@fitb{}{} | ||
|
||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a mostly-empty handout, so there's tons of room on the page. Why not use it to add scaffolding questions to support the discussion about what kids notice and wonder? In that case, it could be in the workbook instead of a handout that teachers need to pause and distribute There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely love the idea of adding questions to support N&W in the empty space. It would be a huge PITA for kids to make decision stumps without having this page visible at the same time to annotate. They are going to end up putting Xs and checks and other symbols all over it. (That's what I did. I had to print it out multiple times for myself as I was creating the worksheets.) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
= Decision Tree Training Dataset | ||
|
||
|
||
|
||
[cols="2,2,3,2,2", stripes="none", options="header"] | ||
|=== | ||
|
||
| name | age| shopping history | interest in game | buys game | ||
|
||
| Jan | 16 | previous customer | no | no | ||
| Jose | 19 | previous customer | no | no | ||
| Maribel | 21 | previous customer | no | yes | ||
| Noah | 33 | previous customer | no | yes | ||
| Sydney | 36 | previous customer | yes | yes | ||
| Mariana | 32 | new customer | yes | no | ||
| Rasula | 24 | new customer | yes | yes | ||
| Jillian | 14 | previous customer | no | no | ||
| Ariella | 16 | new customer | yes | yes | ||
| Isabela | 38 | previous customer | yes | yes | ||
| Danial | 19 | previous customer | yes | yes | ||
| Kate | 27 | previous customer | no | yes | ||
| Taikhoom | 22 | previous customer | yes | yes | ||
| Peter | 35 | new customers | no | no | ||
|
||
|=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
= Decision Tree: Level 1 | ||
|
||
[.linkInstructions]#Use the @handout{decision-tree-data.adoc, "training data"} to respond to the prompts below.# Let's investigate what happens when we begin our tree with "age" as the root. | ||
|
||
== Investigating "age" | ||
|
||
@n Using information from the "age" column and the "buys game" column, fill in the blanks below. | ||
|
||
- The training data indicates that individuals in their thirties probably @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
|
||
- The training data indicates that individuals in their twenties probably @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
|
||
- The training data indicates that teens @fitbruby{10em}{@ifsoln{will not}}{will / will not} buy the game. | ||
|
||
|
||
Here’s our rule: | ||
|
||
- *Predict that individuals in their @fitbruby{15em}{@ifsoln{twenties}}{teens / twenties / thirties} and in their @fitbruby{15em}{@ifsoln{thirties}}{teens / twenties / thirties} will buy the game.* | ||
- *Predict that individuals in their @fitbruby{15em}{@ifsoln{teens}}{teens / twenties / thirties} will not.* | ||
|
||
@n Will a computer following this rule make correct predictions for all 14 individuals in the training dataset? @fitb{5em}{@ifsoln{No.}} | ||
|
||
@n According to our training data, this rule is correct in @fitb{5em}{@ifsoln{10}} instances out of 14. | ||
|
||
@n Here is one way to represent the decision tree for "age". We call this a "decision stump" because it has just one level. Place checkmarks below all correctly predicted values in the "twenties" and "thirties" leaf nodes. | ||
|
||
@ifnotsoln{@center{@image{../images/age-stump.png, 250}}} | ||
|
||
@ifsoln{@center{@image{../images/age-stump-checks.png, 250}}} | ||
|
||
@n Are any of the leaf nodes for "age" pure? (_Pure_ means that the leaf contains exclusively one single value.) @fitb{5em}{@ifsoln{Yes; "twenties".}} | ||
|
||
@n If we used the decision tree stump above to make predictions: | ||
|
||
- the likelihood of a correct prediction for a teenage shopper is @fitb{5em}{@ifsoln{60}}% | ||
|
||
- the likelihood of a correct prediction for a shopper in their twenties is @fitb{5em}{@ifsoln{100} }% | ||
|
||
- the likelihood of a correct prediction for a shopper in their thirties? @fitb{5em}{@ifsoln{60} }% | ||
|
||
@vspace{1ex} | ||
|
||
== Branching beyond "age" | ||
|
||
@n After creating the first level of his decision tree, Ernie removed Maribel, Rasula, Kate, and Taikhoom from the training set. As Bert watched Ernie grab a pencil and cross out those rows, he said, "I don't think that's a good idea! Why would we alter our dataset just because we're starting the second level of the tree?" Why does it make sense to remove those four individuals from the dataset? Explain Ernie's (correct) decision to Bert. | ||
|
||
@fitb{}{} | ||
|
||
@fitb{}{} | ||
|
||
@n For each decision node we have created ("teens" and "thirties"), we need to decide whether it makes more sense to branch to @fitbruby{15em}{@ifsoln{interest in game}}{[column]} or @fitbruby{15em}{@ifsoln{shopping history}}{[column]}. We do not need to branch from "twenties" because @fitb{}{} | ||
|
||
@fitb{}{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
= Decision Tree: Level 2 | ||
|
||
[.linkInstructions]#Use the @handout{decision-tree-data.adoc, "training data"} to respond to the prompts below.# Let's decide what decision nodes to use in the 2nd level of our tree. | ||
|
||
== Shopping History as the Decision Node | ||
|
||
@n Using information from the "age" column and the "shopping history" column, fill in the blanks below. | ||
|
||
@indented{a) The training data indicates that *frequent customers in their teens* @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
|
||
b) The training data indicates that *new customers in their teens* probably @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
|
||
@vspace{1ex} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this space here? The uneven spacing between the lines on the page is a little jarring |
||
|
||
c) What does the training data on *infrequent customers in their teens* tell us? @fitb{}{} | ||
|
||
@fitb{}{@ifsoln{The data does not provide any information on the likelihood of game purchase.}} | ||
} | ||
|
||
|
||
@n Rule: *Predict that frequent teenager shoppers @fitbruby{5em}{@ifsoln{will}}{will / will not} buy the game and that new teenage customers @fitbruby{5em}{@ifsoln{will}}{will / will not} buy the game.* | ||
|
||
@n Will a computer following this rule make the correct prediction every time? @fitb{5em}{@ifsoln{No.}} | ||
|
||
@n According to our training data, this rule is correct in @fitb{5m}{@ifsoln{four}} instances out of five. | ||
|
||
@n Create a decision stump for "shopping history" with a root node of "teens". Place checkmarks below all correctly predicted values in the leaf node. | ||
|
||
@ifnotsoln{@center{@image{../images/blank-stump.png, 150}}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These blanks need to be 2x as large |
||
|
||
|
||
@ifsoln{@center{@image{../images/history-stump.png, 150}}} | ||
|
||
|
||
== Interest in Game as the Decision Node | ||
|
||
@n Using information from the "age" column and the "interest in game" column, fill in the blanks below. | ||
|
||
@indented{ | ||
|
||
a) The training data indicates that *interested teens* @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
|
||
b) The training data indicates *uninterested teens* probably @fitbruby{10em}{@ifsoln{will}}{will / will not} buy the game. | ||
} | ||
|
||
@n Rule: *Predict that interested teenager shoppers @fitbruby{5em}{@ifsoln{will}}{will / will not} buy the game and uninterested teenagers shoppers @fitbruby{5em}{@ifsoln{will}}{will / will not}.* | ||
|
||
@n Will a computer following this rule make the correct prediction every time? @fitb{5em}{@ifsoln{Yes!}} | ||
|
||
@n Create a decision stump for teenagers' interest in the game.Place checkmarks below all correctly predicted values in the leaf node. | ||
|
||
@ifnotsoln{@center{@image{../images/blank-stump.png, 150}}} | ||
|
||
@ifsoln{@center{@image{../images/interest-stump.png, 150}}} | ||
|
||
== What decision attribute should we use? | ||
|
||
@n Shopping history or interest? Explain your response. @fitb{}{@ifsoln{interest in game}} | ||
|
||
@fitb{}{} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
level-1.adoc | ||
level-2.adoc | ||
build-and-test.adoc | ||
comparing-trees.adoc |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pyret |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why have an empty file for slide id? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"navlab.png" : { | ||
"description" : "ALVINN / the Navlab, a retrofitted self-driving army ambulance", | ||
"source" : "Carnegie Mellon Robotics Institute, https://www.ri.cmu.edu/robot/navlab-ii/", | ||
"license" : "Creative Commons 4.0 - NC - SA" | ||
}, | ||
"road1.png" : { | ||
"description" : "US Route 191 near Monomunt Valley", | ||
"source" : "Wikimedia Commons", | ||
"license" : "Creative Commons Attribution-Share Alike 2.0 Generic" | ||
}, | ||
"road2.png" : { | ||
"description" : "curved concrete road surrounded with trees", | ||
"source" : "picpik.com", | ||
"license" : "Creative Commons 1.0 Public Domain" | ||
}, | ||
"road3.png" : { | ||
"description" : "curved road in South Moravia", | ||
"source" : "rawpixel.com", | ||
"license" : "CCO 1.0 Universal" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we let the underlines take up the whole space? The jagged line endings are a little jarring