| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d8c7992 commit b13bb02
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,7 +124,7 @@ | |||
| 124 | 124 | "\n", | |
| 125 | 125 | "* **examples**: Holds the items of the dataset. Each item is a list of values.\n", | |
| 126 | 126 | "\n", | |
| 127 | - "* **attrs**: The indexes of the features (by default in the range of [0,f), where *f* is the number of features. For example, `item[i]` returns the feature at index *i* of *item*.\n", | ||
| 127 | + "* **attrs**: The indexes of the features (by default in the range of [0,f), where *f* is the number of features). For example, `item[i]` returns the feature at index *i* of *item*.\n", | ||
| 128 | 128 | "\n", | |
| 129 | 129 | "* **attrnames**: An optional list with attribute names. For example, `item[s]`, where *s* is a feature name, returns the feature of name *s* in *item*.\n", | |
| 130 | 130 | "\n", | |
@@ -1072,6 +1072,42 @@ | |||
| 1072 | 1072 | "</ol>" | |
| 1073 | 1073 | ] | |
| 1074 | 1074 | }, | |
| 1075 | + { | ||
| 1076 | + "cell_type": "markdown", | ||
| 1077 | + "metadata": {}, | ||
| 1078 | + "source": [ | ||
| 1079 | + "### Example\n", | ||
| 1080 | + "\n", | ||
| 1081 | + "We will now use the Decision Tree Learner to classify a sample with values: 5.1, 3.0, 1.1, 0.1." | ||
| 1082 | + ] | ||
| 1083 | + }, | ||
| 1084 | + { | ||
| 1085 | + "cell_type": "code", | ||
| 1086 | + "execution_count": 2, | ||
| 1087 | + "metadata": {}, | ||
| 1088 | + "outputs": [ | ||
| 1089 | + { | ||
| 1090 | + "name": "stdout", | ||
| 1091 | + "output_type": "stream", | ||
| 1092 | + "text": [ | ||
| 1093 | + "setosa\n" | ||
| 1094 | + ] | ||
| 1095 | + } | ||
| 1096 | + ], | ||
| 1097 | + "source": [ | ||
| 1098 | + "iris = DataSet(name=\"iris\")\n", | ||
| 1099 | + "\n", | ||
| 1100 | + "DTL = DecisionTreeLearner(iris)\n", | ||
| 1101 | + "print(DTL([5.1, 3.0, 1.1, 0.1]))" | ||
| 1102 | + ] | ||
| 1103 | + }, | ||
| 1104 | + { | ||
| 1105 | + "cell_type": "markdown", | ||
| 1106 | + "metadata": {}, | ||
| 1107 | + "source": [ | ||
| 1108 | + "As expected, the Decision Tree learner classifies the sample as \"setosa\" as seen in the previous section." | ||
| 1109 | + ] | ||
| 1110 | + }, | ||
| 1075 | 1111 | { | |
| 1076 | 1112 | "cell_type": "markdown", | |
| 1077 | 1113 | "metadata": {}, | |
@@ -1760,7 +1796,7 @@ | |||
| 1760 | 1796 | "name": "python", | |
| 1761 | 1797 | "nbconvert_exporter": "python", | |
| 1762 | 1798 | "pygments_lexer": "ipython3", | |
| 1763 | - "version": "3.5.3" | ||
| 1799 | + "version": "3.6.3" | ||
| 1764 | 1800 | } | |
| 1765 | 1801 | }, | |
| 1766 | 1802 | "nbformat": 4, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -542,7 +542,7 @@ def plurality_value(examples): | |||
| 542 | 542 | return DecisionLeaf(popular) | |
| 543 | 543 | ||
| 544 | 544 | def count(attr, val, examples): | |
| 545 | - """Count the number of examples that have attr = val.""" | ||
| 545 | + """Count the number of examples that have example[attr] = val.""" | ||
| 546 | 546 | return sum(e[attr] == val for e in examples) | |
| 547 | 547 | ||
| 548 | 548 | def all_same_class(examples): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments