Decision and Classification Trees, Clearly Explained!!!

StatQuest with Josh Starmer
25 Apr 202118:08

Summary

TLDREl guion del video de StatQuest, presentado por Josh Starmer, explica de manera clara y didáctica cómo funcionan los árboles de decisión y clasificación. Se muestra cómo se construye un árbol a partir de datos brutos, utilizando ejemplos sencillos y avanzando a casos más complejos que combinan datos numéricos y de tipo sí/no. El video profundiza en el proceso de construcción de un árbol de clasificación utilizando datos sobre el gusto por el palomitas, refrescos, la edad y la película 'Cool as Ice' de 1991. Se discuten técnicas para medir la impureza de las hojas del árbol, como la impureza de genio, y se ofrecen estrategias para evitar el sobreajuste, como la poda y la limitación del crecimiento del árbol. El guion finaliza con la promoción de recursos adicionales y la invitación a seguir el canal.

Takeaways

  • 📚 Los árboles de decisión son una herramienta utilizada para la toma de decisiones y la clasificación de datos.
  • 🌳 Un árbol de decisión clasifica cosas en categorías, lo que se conoce como un árbol de clasificación, mientras que predice valores numéricos en lo que se llama un árbol de regresión.
  • 🔍 Los árboles de decisión operan haciendo declaraciones y tomando decisiones basadas en si dichas declaraciones son verdaderas o falsas.
  • 🔄 Se pueden mezclar diferentes tipos de datos, como datos numéricos y de sí/no, en el mismo árbol.
  • 📉 Los umbrales numéricos pueden variar para el mismo conjunto de datos, lo que permite una gran flexibilidad en el modelo.
  • 🏁 Los árboles de decisión terminan en nodos hoja, que son puntos finales donde se clasifica algo basado en las decisiones tomadas.
  • 🔮 Para construir un árbol de decisión, se evalúa qué atributo (por ejemplo, 'amar el pop-corn') mejor predice el resultado final utilizando medidas de impureza como la impureza de Gini.
  • ⚖️ La impureza de Gini es una forma de cuantificar la impureza de los nodos, ayudando a decidir cómo se dividen los datos a lo largo del árbol.
  • 📈 Se pueden establecer límites en el crecimiento del árbol, como requerir un mínimo de personas por nodo hoja, para evitar el sobreajuste y mejorar la precisión de las predicciones.
  • ✂️ El podado (pruning) es una técnica utilizada para reducir la complejidad del árbol una vez que se ha construido, mejorando su rendimiento en nuevos datos.
  • 🔧 La validación cruzada es una técnica utilizada para evaluar y seleccionar el mejor modelo, probando diferentes configuraciones del árbol de decisión.

Q & A

  • ¿Qué son los árboles de decisión y cómo se explican en el video de StatQuest?

    -Los árboles de decisión son una herramienta utilizada en el aprendizaje automático para tomar decisiones o realizar clasificaciones basadas en datos. En el video de StatQuest, se explican de manera clara y detallada, mostrando cómo se construye un árbol de decisión y cómo se utiliza para predecir valores numéricos o clasificar cosas en categorías.

  • ¿Cuál es la diferencia entre un árbol de clasificación y un árbol de regresión?

    -Un árbol de clasificación se utiliza para dividir datos en categorías, mientras que un árbol de regresión predice valores numéricos. El video se centra principalmente en los árboles de clasificación.

  • ¿Cómo se mezclan diferentes tipos de datos en un árbol de decisión?

    -En el video se muestra que es posible mezclar datos numéricos y de tipo sí/no en el mismo árbol de decisión, lo que permite una mayor flexibilidad en el modelado de datos.

  • ¿Cómo se determina qué pregunta hacer en la parte superior del árbol de decisión?

    -Para determinar qué pregunta hacer en la parte superior del árbol, se evalúa qué atributo (como 'amar el pop-corn' o 'amar el refresco') mejor predice el resultado de interés, como se muestra en el ejemplo del video donde se compara la impureza de los árboles de decisión para cada atributo.

  • ¿Qué es la impureza en el contexto de un árbol de decisión y cómo se mide?

    -La impureza se refiere a la mezcla de clases o resultados en un nodo del árbol. Se mide utilizando métodos como la impureza de genio, la entropía o la ganancia de información, donde una impureza más baja indica un mejor rendimiento en la predicción.

  • ¿Cómo se calcula la impureza de genio para un nodo de un árbol de decisión?

    -La impureza de genio se calcula para cada hoja del árbol, tomando en cuenta la probabilidad de 'sí' y 'no', y luego se toma el promedio ponderado de las impurezas de las hojas, teniendo en cuenta el número de instancias en cada una.

  • ¿Cómo se decide el umbral numérico para un atributo en un árbol de decisión?

    -Se ordenan los datos por el atributo numérico y se calcula la impureza de genio para diferentes valores medios de edad. Se selecciona el umbral que produce la menor impureza, como se muestra en el ejemplo del video donde se utiliza la edad como atributo.

  • ¿Qué es el podado de un árbol y por qué es necesario?

    -El podado es el proceso de remover ramas del árbol de decisión para evitar el sobreajuste y mejorar la precisión en nuevos datos. Es necesario porque un árbol muy grande y complejo puede ajustarse demasiado bien a los datos de entrenamiento y no generalizar bien a nuevos datos.

  • ¿Cómo se establecen los límites en el crecimiento de un árbol para evitar el sobreajuste?

    -Se pueden establecer límites como requerir un mínimo de instancias por hoja, por ejemplo, tres o más personas. Esto se prueba con validación cruzada para encontrar el número óptimo que funcione mejor para el conjunto de datos.

  • ¿Qué es la validación cruzada y cómo ayuda a determinar la calidad de un árbol de decisión?

    -La validación cruzada es un método utilizado para evaluar el rendimiento de un modelo en diferentes subconjuntos de datos. Ayuda a determinar la calidad de un árbol de decisión al comparar cómo se desempeña con diferentes configuraciones, como el número mínimo de instancias por hoja.

  • ¿Cómo se asignan los valores de salida para las hojas de un árbol de decisión?

    -Los valores de salida para las hojas se asignan basándose en la categoría que tenga la mayoría de valores en esa hoja. Por ejemplo, si la mayoría de las personas en una hoja no aman 'Cool as Ice', entonces la salida de esa hoja sería 'No ama Cool as Ice'.

Outlines

00:00

🌳 Introducción a los árboles de decisión

Josh Darmer de StatQuest presenta un tutorial sobre árboles de decisión y clasificación. Expone la estructura básica de un árbol de decisión y cómo funciona, enfocándose en la clasificación de elementos en categorías o la predicción de valores numéricos. Se menciona que los árboles de decisión pueden combinar datos numéricos y de tipo sí/no, y que los árboles de clasificación son sencillos de usar, comenzando desde la parte superior hasta llegar a una clasificación final. Además, se introducen términos como nodo raíz, nodos internos y hojas, y se explica cómo se construye un árbol de clasificación a partir de datos sin procesar.

05:00

📊 Construcción de un árbol de clasificación

Se describe el proceso de construcción de un árbol de clasificación utilizando datos sobre el gusto por el palomitas, refrescos, la edad y la película 'Cool as Ice' de 1991. Se calcula la impureza de las hojas usando el índice de impureza genie para determinar qué característica (palomitas, refrescos o edad) es la mejor para colocar en la parte superior del árbol. Se ilustra cómo se dividen las hojas en función de las respuestas a preguntas y cómo se calcula la impureza para cada división. Finalmente, se elige la característica con la impureza más baja para la división superior del árbol.

10:01

🔢 Impureza y división de nodos por edad

El proceso de construcción del árbol continúa con el análisis de la edad como variable para dividir los nodos. Se ordenan los datos por edad y se calculan las edades promedio para las personas adyacentes. Se utiliza el índice de impureza genie para cada umbral de edad y se eligen los umbrales que resultan en la menor impureza. En este caso, se elige un umbral de 15 años, que junto con otros umbrales, tiene la impureza más baja. Se describe cómo se dividen las hojas en función de las respuestas a preguntas adicionales y cómo se asignan los valores de salida para cada hoja.

15:04

🎯 Uso y limitaciones de los árboles de clasificación

Josh explica cómo utilizar el árbol construido para predecir si alguien ama 'Cool as Ice'. Además, se discuten las limitaciones de los árboles de decisión, como el riesgo de sobreajuste cuando hay muy pocos datos en una hoja. Se mencionan técnicas como el podado (pruning) y la limitación del crecimiento del árbol mediante la especificación de un número mínimo de personas por hoja. Se destaca la importancia de la validación cruzada para determinar los parámetros óptimos del árbol. Finalmente, Josh promociona los guías de estudio de StatQuest y anima a los espectadores a suscribirse y apoyar el canal.

Mindmap

Keywords

💡Árbol de decisión

El árbol de decisión es una herramienta de aprendizaje automático que se utiliza para tomar decisiones o clasificar datos. En el video, se describe cómo funciona un árbol de decisión y cómo se puede utilizar para predecir si una persona le gustará la película 'Cool as Ice' basándose en su gusto por palomitas, refrescos y su edad. El árbol de decisión se compone de nodos y ramas que representan preguntas y caminos de decisión, respectivamente.

💡Árbol de clasificación

Un árbol de clasificación es un tipo específico de árbol de decisión que se utiliza para dividir los datos en categorías. En el contexto del video, el árbol de clasificación se construye para predecir si alguien ama la película 'Cool as Ice'. Se utiliza la información sobre el consumo de palomitas, refrescos y la edad para llegar a una clasificación final.

💡Árbol de regresión

A diferencia del árbol de clasificación, un árbol de regresión predice valores numéricos en lugar de categorizar datos. Aunque el video se centra en árboles de clasificación, menciona que hay otro video dedicado a árboles de regresión, lo que indica que estos son temas relacionados y de interés en el aprendizaje automático.

💡Impureza

En el video, la impureza se refiere a la mezcla de datos en un nodo del árbol de decisión. Un nodo impuro contiene una combinación de respuestas 'sí' y 'no' a la pregunta que se está evaluando. Por ejemplo, un nodo con dos personas que aman 'Cool as Ice' y una que no, tendría una impureza, ya que no todos los datos apuntan en la misma dirección.

💡Genie impurity

La impureza de Genie es un método para cuantificar la impureza de los nodos en un árbol de decisión. Se calcula como 1 menos el cuadrado de la probabilidad de 'sí' más el cuadrado de la probabilidad de 'no'. En el script, se utiliza para comparar la eficacia de diferentes características en la predicción de si alguien ama 'Cool as Ice'.

💡Nodo raíz

El nodo raíz es el punto de inicio de un árbol de decisión, donde se hace la primera pregunta o se toma la primera decisión. En el video, la pregunta inicial podría ser si una persona ama el refresco, lo que desencadena el resto del árbol de decisión.

💡Nodos internos

Los nodos internos son los puntos en un árbol de decisión que siguen después del nodo raíz y antes de los nodos hoja. Estos nodos representan preguntas adicionales que se hacen para refinar la predicción. En el script, los nodos internos podrían preguntar sobre el consumo de palomitas o la edad de una persona.

💡Nodos hoja

Los nodos hoja son el final de una rama en un árbol de decisión, donde se toma una decisión final o se da una clasificación. En el video, los nodos hoja representan la predicción final de si alguien ama o no 'Cool as Ice'.

💡Podar

El podar es un proceso utilizado para reducir la complejidad de un árbol de decisión y evitar el sobreajuste. En el video, se menciona que el podar es una técnica para manejar problemas de predicción inexacta en los nodos hoja debido a una falta de datos.

💡Validación cruzada

La validación cruzada es una técnica utilizada para evaluar el rendimiento de un modelo de aprendizaje automático. En el contexto del video, se sugiere que la validación cruzada puede ayudar a determinar el número óptimo de personas por hoja para evitar el sobreajuste y mejorar la precisión de las predicciones.

Highlights

Decision trees are explained for classification and regression purposes.

Classification trees categorize things, while regression trees predict numeric values.

A decision tree operates by making decisions based on true or false statements.

Different data types can be mixed within the same decision tree.

Numeric thresholds can vary even for the same data in a decision tree.

Classification trees are easy to work with by following a top-down approach.

Terminology: Root node, internal nodes, branches, and leaf nodes in a decision tree.

Genie impurity is introduced as a method to quantify leaf impurity.

Calculating genie impurity involves probabilities and squared values.

Weighted average of leaf impurities is used to determine total genie impurity.

Sorting data and calculating average ages are part of handling numeric data in trees.

Different candidate values are compared using genie impurity to decide tree structure.

Pruning and limiting tree growth are methods to avoid overfitting.

Cross-validation is used to test different values for optimal tree performance.

Output values for leaves are determined by the majority category.

The process of building a decision tree from raw data is demonstrated.

The importance of having confidence in predictions and dealing with impure leaves.

StatQuest resources for further learning on decision trees and related topics.

Transcripts

play00:00

i like decision trees how about

play00:03

you stat quest

play00:07

hello i'm josh darmer and welcome to

play00:10

statquest

play00:11

today we're going to talk about decision

play00:13

and classification trees

play00:15

and they're going to be clearly

play00:16

explained here is a simple decision tree

play00:21

if a person wants to learn about

play00:22

decision trees

play00:24

then they should watch this stat quest

play00:27

in contrast

play00:28

if a person does not want to learn about

play00:30

decision trees

play00:32

then check out the latest justin bieber

play00:34

video instead

play00:37

in general a decision tree makes a

play00:39

statement

play00:40

and then makes a decision based on

play00:42

whether or not that statement is true or

play00:44

false

play00:46

it's no big deal when a decision tree

play00:49

classifies

play00:50

things into categories it's called a

play00:53

classification tree

play00:55

and when a decision tree predicts

play00:57

numeric values

play00:59

it's called a regression tree in this

play01:02

case

play01:03

we're using diet to predict a numeric

play01:06

value for mouse size

play01:09

note for the remainder of this video we

play01:12

are going to focus on classification

play01:14

trees

play01:15

however if you want to learn more about

play01:18

regression trees

play01:19

fear not there's a whole stat quest

play01:22

dedicated to regression trees

play01:24

the link is in the description below

play01:28

now here's a more complicated

play01:30

classification tree

play01:33

it combines numeric data with yes

play01:36

no data so it's okay to mix data types

play01:40

in the same tree

play01:42

also notice that the tree asks about

play01:45

exercising multiple times

play01:48

and that the amount of time exercising

play01:50

isn't always the same

play01:53

so numeric thresholds can be different

play01:55

for the same data

play01:57

lastly the final classifications can be

play02:00

repeated

play02:02

for the most part classification trees

play02:05

are pretty easy to work with

play02:07

you start at the top and work your way

play02:10

down

play02:11

and down until you get to a point where

play02:14

you can't go any further

play02:16

and that's how you'll classify something

play02:19

note so far i've been labeling the

play02:22

arrows with true

play02:23

or false but usually it is just

play02:26

assumed that if a statement is true you

play02:29

go to the left

play02:31

and if a statement is false you go to

play02:33

the right

play02:35

so sometimes you see true and false

play02:37

labels

play02:38

sometimes you don't it's no big deal

play02:41

oh no it's the dreaded terminology alert

play02:45

the very top of the tree is called the

play02:48

root node

play02:48

or just the root these are called

play02:51

internal nodes or branches

play02:54

branches have arrows pointing to them

play02:57

and they have

play02:58

arrows pointing away from them lastly

play03:02

these are called leaf nodes or just

play03:04

leaves

play03:05

leaves have arrows pointing to them but

play03:08

there are no arrows pointing away from

play03:10

them

play03:11

bam now that we know how to use and

play03:14

interpret classification trees let's

play03:17

learn how to build one from raw data

play03:21

this data tells us whether or not

play03:23

someone loves popcorn

play03:25

whether or not they love soda their age

play03:29

and whether or not they love the 1991

play03:32

blockbuster

play03:33

cool as ice starring vanilla ice

play03:37

so we will use this data to build this

play03:40

classification tree

play03:42

that predicts whether or not someone

play03:44

loves cool as ice

play03:47

now pretend you've never seen this tree

play03:49

before

play03:50

and let's see how to build a tree

play03:52

starting with just

play03:53

data the first thing we do is decide

play03:57

whether loves popcorn

play03:59

love soda or age should be the question

play04:02

we ask

play04:02

at the very top of the tree to make that

play04:06

decision

play04:06

we'll start by looking at how well loves

play04:09

popcorn

play04:09

predicts whether or not someone loves

play04:12

cool as ice

play04:14

to do this we'll make a super simple

play04:16

tree that only asks if someone loves

play04:19

popcorn

play04:20

and then we'll run the data down the

play04:22

tree

play04:24

for example the first person in the

play04:26

dataset

play04:27

loves popcorn so they go to the leaf on

play04:30

the left

play04:32

and because they do not love cool as ice

play04:36

we'll keep track of that by putting a 1

play04:38

under the word

play04:39

no the second person in the data set

play04:43

also loves popcorn so they also go to

play04:47

the leaf on the left

play04:49

and because they also do not love cool

play04:52

as ice

play04:53

we increment no to two

play04:56

the third person does not love popcorn

play05:00

so they go to the leaf on the right and

play05:03

because they love cool as ice

play05:05

we put a 1 under the word yes

play05:09

likewise we run the remaining rows down

play05:11

the tree

play05:12

keeping track of whether or not each one

play05:15

loves

play05:15

cool as ice bam

play05:18

now let's do the exact same thing for

play05:21

love soda

play05:24

at the two little trees we see that

play05:26

neither one does a perfect

play05:28

job predicting who will and who will not

play05:31

love cool as ice specifically

play05:35

these three leaves contain mixtures of

play05:37

people that do

play05:38

and do not love cool as ice

play05:42

dread it's another terminology alert

play05:46

because these three leaves all contain a

play05:48

mixture of people who do

play05:50

and do not love cool as ice they are

play05:53

called

play05:53

impure in contrast

play05:57

this leaf only contains people who do

play05:59

not love cool as ice

play06:02

because both leaves in the love's

play06:03

popcorn tree

play06:05

are impure and only one leaf in the love

play06:08

soda tree is impure

play06:11

it seems like love soda does a better

play06:13

job predicting who will

play06:15

and who will not love cool as ice

play06:19

but it would be nice if we could

play06:20

quantify the differences between love's

play06:23

popcorn

play06:23

and love soda the good news is that

play06:27

there are several ways to quantify the

play06:29

impurity of the leaves

play06:32

one of the most popular methods is

play06:34

called genie impurity

play06:36

but there are also fancy sounding

play06:38

methods like entropy

play06:39

and information gain however

play06:42

numerically the methods are all quite

play06:45

similar

play06:46

so we will focus on genie impurity since

play06:49

not only is it very popular i think it

play06:52

is the most straightforward

play06:54

so let's start by calculating the genie

play06:56

impurity for love's popcorn

play06:59

to calculate the genie impurity for

play07:02

love's popcorn

play07:03

we start by calculating the genie

play07:05

impurity for the individual leaves

play07:08

the genie impurity for the leaf on the

play07:10

left is

play07:12

1 minus the probability of yes

play07:16

squared minus the probability of

play07:19

no squared so we start out with one

play07:24

then we subtract the squared probability

play07:26

of someone in this leaf

play07:28

loving cool as ice which is one

play07:32

the number of people in the leaf who

play07:33

loved cool as ice

play07:35

divided by the total number of people in

play07:38

the leaf four

play07:40

and then the whole term is squared

play07:43

lastly we subtract the squared

play07:45

probability of someone in this leaf

play07:47

not loving cool as ice which is three

play07:51

the number of people in the leaf who did

play07:53

not love cool as ice

play07:55

divided by the total number of people in

play07:57

the leaf

play07:59

squared and when we do the math

play08:02

we get 0.375

play08:05

so let's put 0.375 under the leaf on the

play08:09

left

play08:09

so we don't forget it now let's

play08:12

calculate the genie impurity for the

play08:14

leaf on the right

play08:16

just like before we start out with one

play08:20

then we subtract the squared probability

play08:22

of someone in this leaf

play08:23

loving cool as ice and the squared

play08:26

probability of someone in this leaf

play08:29

not a loving cool is ice

play08:32

and when we do the math we get 0.444

play08:36

now because the leaf on the left has

play08:39

four people in it

play08:40

and the leaf on the right only has three

play08:43

people in it

play08:44

the leaves do not represent the same

play08:46

number of people

play08:48

thus the total genie impurity is the

play08:51

weighted

play08:51

average of the leaf impurities

play08:54

we start by calculating the weight for

play08:57

the leaf on the left

play08:59

the weight for the left leaf is the

play09:01

total number of people in the leaf

play09:03

four divided by the total number of

play09:06

people in both leaves

play09:08

seven then we multiply that weight

play09:12

by its associated genie impurity 0.375

play09:17

now we add the weighted impurity for the

play09:20

leaf on the right

play09:22

which is the total number of people in

play09:24

the leaf 3

play09:26

divided by the total number of people in

play09:28

both leaves

play09:29

7 times the associated genie impurity

play09:34

0.444 and when we do the math

play09:38

we get 0.405

play09:41

so the genie impurity for love's popcorn

play09:44

is 0.405

play09:47

likewise the genium purity for love soda

play09:51

is 0.214

play09:54

now we need to calculate the genie

play09:56

impurity for age

play09:58

however because age contains numeric

play10:01

data

play10:02

and not just yes no values calculating

play10:05

the genie impurity is a little more

play10:07

involved

play10:09

the first thing we do is sort the rows

play10:11

by age

play10:12

from lowest value to highest value

play10:15

then we calculate the average age for

play10:17

all adjacent people

play10:20

lastly we calculate the geniu impurity

play10:22

values for each

play10:24

average age for example

play10:27

to calculate the gd impurity for the

play10:29

first value

play10:31

we put age less than 9.5 in the root

play10:35

and because the only person with age

play10:37

less than 9.5

play10:39

does not love cool is ice

play10:42

we put a 0 under yes and a 1 under

play10:45

no then everyone with age greater than

play10:49

or equal to 9.5

play10:51

goes to the leaf on the right now we

play10:54

calculate the genie impurity for the

play10:56

leaf on the left

play10:58

and get zero and this makes sense

play11:01

because

play11:02

every single person in this leaf does

play11:04

not love cool as ice

play11:06

so there is no impurity

play11:10

then we calculate the genie impurity for

play11:12

the leaf on the right

play11:14

and get 0.5 now we calculate the

play11:18

weighted average of the two impurities

play11:20

to get the total

play11:21

genie impurity and we get 0.429

play11:26

likewise we calculate the genie

play11:28

impurities for all of the other

play11:30

candidate values

play11:33

these two candidate thresholds 15 and 44

play11:37

are tied for the lowest impurity 0.343

play11:42

so we can pick either one in this case

play11:44

we'll pick

play11:45

15. however remember that we are

play11:49

comparing genie impurity values for

play11:51

age loves popcorn and love soda

play11:54

to decide which features should be at

play11:56

the very top of the tree

play11:59

earlier we calculated the genie impurity

play12:02

values for love's popcorn

play12:04

and love soda and now we have the genie

play12:07

impurity for age

play12:10

and because love soda has the lowest

play12:13

genie impurity overall

play12:15

we know that its leaves had the lowest

play12:17

impurity

play12:19

so we put love soda at the top of the

play12:21

tree

play12:22

bam now

play12:26

the four people that love soda go to a

play12:28

node on the left

play12:30

and the people that do not love soda go

play12:33

to a node on the right

play12:36

now let's focus on the node on the left

play12:39

all four people that love soda are in

play12:42

this node

play12:44

three of these people love cool as ice

play12:48

and one does not so this

play12:51

node is impure so let's see if we can

play12:55

reduce the impurity by splitting the

play12:57

people that love

play12:58

soda based on love's popcorn or age

play13:03

we'll start by asking the four people

play13:05

that love soda

play13:06

if they also love popcorn

play13:09

because two of the four people that love

play13:11

soda

play13:12

also love popcorn they end up in the

play13:15

leaf on the left

play13:18

the remaining two people that love soda

play13:20

but do not

play13:21

love popcorn end up on the right

play13:24

and the total genie impurity for this

play13:26

split is 0.25

play13:30

so let's put 0.25 here so we don't

play13:33

forget

play13:35

now we test different age thresholds

play13:37

just like before

play13:39

only this time we only consider the ages

play13:42

of people who love

play13:43

soda and age less than 12.5 gives us the

play13:48

lowest impurity

play13:49

zero because both leaves have no

play13:52

impurity at all

play13:55

so let's put zero here now

play13:58

because zero is less than 0.25

play14:01

we will use age less than 12.5 to split

play14:05

this node into leaves

play14:07

note these are leaves because there is

play14:10

no reason to continue splitting these

play14:12

people

play14:12

into smaller groups likewise

play14:16

this node consisting of the three people

play14:18

who do not love

play14:19

soda is also a leaf because there is no

play14:22

reason to continue splitting these

play14:24

people

play14:25

into smaller groups now there is just

play14:29

one last thing we need to do before we

play14:31

are done building this tree

play14:34

we need to assign output values for each

play14:36

leaf

play14:38

generally speaking the output of a leaf

play14:41

is whatever category that has the most

play14:43

values

play14:45

in other words because the majority of

play14:47

the people in these leaves

play14:48

do not love cool as ice

play14:52

the output values are does not love

play14:55

cool as ice and because the majority of

play14:58

the people in this leaf

play15:00

love cool as ice the output value is

play15:04

love's cool as ice hooray

play15:07

we finished building a tree from this

play15:09

data

play15:11

double bam now if someone new comes

play15:15

along

play15:16

and we want to predict if they will love

play15:18

cool as ice

play15:19

then we run the data down our tree and

play15:22

because they love

play15:23

soda they go to the left and because

play15:26

they are 15

play15:28

so age less than 12.5 is false

play15:31

they end up in this leaf and we predict

play15:34

that they will love cool as ice

play15:37

triple bam okay

play15:41

now that we understand the main ideas of

play15:43

how to build and use classification

play15:45

trees

play15:46

let's discuss one technical detail

play15:49

remember when we built this tree only

play15:52

one person in the original

play15:54

data set made it to this leaf

play15:57

because so few people made it to this

play15:59

leaf it's hard to have confidence that

play16:01

it will do a great job making

play16:03

predictions with future data

play16:05

and it is possible that we have overfit

play16:08

the data

play16:09

note if the term overfit is new to you

play16:13

don't don't

play16:16

instead check out the stack quest on

play16:18

bias and variance in machine learning

play16:21

regardless in practice there are two

play16:24

main ways to deal with this problem

play16:27

one method is called pruning and there's

play16:29

a whole stack quest dedicated to it so

play16:31

check it out

play16:33

alternatively we can put limits on how

play16:36

trees grow

play16:37

for example by requiring three or more

play16:40

people per leaf

play16:42

now we end up with an impure leaf but

play16:45

also a better sense of the accuracy of

play16:47

our prediction

play16:48

because we know that only 75 percent of

play16:50

the people

play16:51

in the leaf love to cool as ice

play16:55

note even when a leaf is impure we still

play16:58

need an

play16:58

output value to make a classification

play17:01

and since most of the people in this

play17:03

leaf

play17:04

love cool as ice that will be the output

play17:07

value

play17:08

also note when we build a tree we don't

play17:11

know in advance if it is better to

play17:13

require three people per leaf

play17:15

or some other number so we test

play17:18

different values with something called

play17:19

cross validation

play17:21

and pick the one that works best and if

play17:23

you don't know what cross validation is

play17:26

check out the quest bam now it's time

play17:29

for some

play17:30

shameless self-promotion if you want to

play17:33

review statistics and machine learning

play17:35

offline

play17:36

check out the statquest study guides at

play17:38

statquest.org

play17:40

there's something for everyone hooray

play17:43

we've made it to the end of another

play17:45

exciting stat quest

play17:46

if you like this stat quest and want to

play17:48

see more please subscribe

play17:50

and if you want to support statquest

play17:52

consider contributing to my patreon

play17:54

campaign

play17:55

becoming a channel member buying one or

play17:58

two of my original songs or a t-shirt or

play18:00

a hoodie or just donate

play18:02

the links are in the description below

play18:04

alright until next time

play18:06

quest on

Rate This

5.0 / 5 (0 votes)

Related Tags
Árboles de DecisiónEstadísticasAprendizaje AutomáticoClasificaciónRegresiónImpureza GenieInformación GananciaMétodos CuantitativosAnálisis de DatosMachine Learning
Do you need a summary in English?