{
"cells": [
{
"cell_type": "markdown",
"id": "20fce00f",
"metadata": {},
"source": [
"# ML, Data Analysis\n",
"### Machine learning: Gini impurity\n",
"\n",
"The **gini impurity** is a fundamental concept used in decision tree algorithms to measure how *impure* or *mixed* a set of items is with respect to their class labels.\n",
"
Imagine you have a basket containing different fruits. Gini Impurity measures the probability that you would be wrong if you randomly picked a fruit and guessed its type based on the distribution of fruits in the basket.\n",
"
**Definition:** Consider we have a dataset of $n$ items having $K$ different types (classes). Let's denote the probability of selecting an item of class $i$ by $p_i$. Then, the Gini impurity is:\n",
"