bayes_project/test.ipynb

586 lines
697 KiB
Plaintext
Raw Normal View History

2021-05-30 15:36:17 +02:00
{
"cells": [
{
"cell_type": "code",
2021-05-31 20:38:26 +02:00
"execution_count": 20,
"id": "coordinated-findings",
2021-05-30 15:36:17 +02:00
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd \n",
"import numpy as np\n",
"from sklearn.model_selection import train_test_split\n",
"import matplotlib.pyplot as plt\n",
"\n",
2021-05-31 16:33:55 +02:00
"# Wizualizacja\n",
"def autolabel(rects, values ,ax):\n",
" # Attach some text labels.\n",
" for (rect, value) in zip(rects, values):\n",
" ax.text(rect.get_x() + rect.get_width() / 2.,\n",
" rect.get_y() + rect.get_height() / 2.,\n",
" '%.3f'%value,\n",
" ha = 'center',\n",
" va = 'center',\n",
" fontsize= 15,\n",
2021-05-31 18:56:34 +02:00
" color ='black') \n",
"def plot_priori(labels, posteriori, name): \n",
2021-05-31 16:33:55 +02:00
" keys =[ r\"$\\bf{\" + (x.split('.',1)[0]).replace('_', ' ')+ \"}$\" + '\\n' + x.split('.',1)[1] for i in range(1) for j in range(len(labels[i])) for x in labels[i][j].keys()]\n",
" aprori = [list(x) for i in range(1) for j in range(len(labels[i])) for x in labels[i][j].values()]\n",
" yes_aprori = np.array(aprori)[:,0]\n",
" no_aprori = np.array(aprori)[:,1]\n",
" \n",
" width = 0.55\n",
"\n",
" fig = plt.figure(figsize=(25,10))\n",
" \n",
" ax1 = fig.add_subplot(121)\n",
" rec1 = ax1.bar(keys,yes_aprori,width, color ='lime', label= 'Positive stroke')\n",
" rec2 = ax1.bar(keys,no_aprori,width, color ='crimson', bottom = yes_aprori, label= 'Negative stroke')\n",
" ax1.set_yticks(np.arange(0, 1.1,0.1))\n",
" ax1.set_ylabel('Probability',fontsize=18)\n",
" ax1.set_xlabel('\\nFeatures',fontsize=18)\n",
" ax1.tick_params(axis='x', which='major', labelsize=12)\n",
" autolabel(rec1,yes_aprori, ax1)\n",
" autolabel(rec2,no_aprori, ax1)\n",
" ax1.legend(fontsize=15)\n",
" \n",
" ax2 = fig.add_subplot(122)\n",
" rec3 = ax2.bar(0, posteriori[1],capsize=1 ,color=['crimson'], label='Negative stroke')\n",
" rec4 = ax2.bar(1, posteriori[0], color=['lime'],label='Positive stroke')\n",
" ax2.set_ylabel('Probability',fontsize=18)\n",
" ax2.set_xlabel('\\nClasses',fontsize=18)\n",
" ax2.set_xticks([0,1])\n",
" ax2.set_yticks(np.arange(0, 1.1,0.1))\n",
" ax2.tick_params(axis='x', which='major', labelsize=15)\n",
" autolabel(rec3,[posteriori[1]], ax2)\n",
" autolabel(rec4,[posteriori[0]], ax2)\n",
" ax2.legend(fontsize=15)\n",
" \n",
2021-05-31 18:56:34 +02:00
"# plt.show()\n",
" plt.savefig(name + \".png\", dpi=100)\n",
2021-05-31 16:33:55 +02:00
"\n",
"\n",
2021-05-31 20:38:26 +02:00
"# Wczytanie i normalizacja danych\n",
2021-05-30 15:36:17 +02:00
"def NormalizeData(data):\n",
" for col in data.columns:\n",
" if data[col].dtype == object: \n",
" data[col] = data[col].str.lower()\n",
" if col == 'smoking_status':\n",
" data[col] = data[col].str.replace(\" \", \"_\")\n",
" if col == 'stroke':\n",
" data[col] = data[col].replace({1: 'yes'})\n",
" data[col] = data[col].replace({0: 'no'})\n",
" if col == 'hypertension':\n",
" data[col] = data[col].replace({1: 'yes'})\n",
" data[col] = data[col].replace({0: 'no'})\n",
" if col == 'heart_disease':\n",
" data[col] = data[col].replace({1: 'yes'})\n",
" data[col] = data[col].replace({0: 'no'})\n",
" if col == 'bmi':\n",
" bins = [19,25,30,35,40,90]\n",
" labels=['correct','overweight','obesity_1','obesity_2','extreme']\n",
" data[col] = pd.cut(data[col], bins, labels = labels,include_lowest = True)\n",
" if col == 'age':\n",
" bins = [0, 30, 40, 50, 60, 70, 80, 90]\n",
" labels = ['0-29', '30-39', '40-49', '50-59', '60-69', '70-79', '80-89',]\n",
" data[col] = pd.cut(data[col], bins, labels = labels,include_lowest = True)\n",
" if col == 'avg_glucose_level':\n",
2021-05-31 20:38:26 +02:00
" bins = [50,90,130,170,210,250,290]\n",
" labels = ['50-90', '90-130','130-170','170-210','210-250','250-290']\n",
2021-05-30 15:36:17 +02:00
" data[col] = pd.cut(data[col], bins, labels = labels,include_lowest = True)\n",
" data = data.dropna()\n",
" return data\n",
"\n",
"def count_a_priori_prob(dataset):\n",
" is_stroke_amount = len(dataset[dataset.stroke == 'yes'])\n",
" no_stroke_amount = len(dataset[dataset.stroke == 'no'])\n",
" data_length = len(dataset.stroke)\n",
" return {'yes': float(is_stroke_amount)/float(data_length), 'no': float(no_stroke_amount)/float(data_length)}\n",
"\n",
"def separate_labels_from_properties(X_train):\n",
"\n",
" labels = X_train.columns\n",
" labels_values = {}\n",
" for label in labels:\n",
" labels_values[label] = set(X_train[label])\n",
" \n",
" to_return = []\n",
" for x in labels:\n",
" to_return.append({x: labels_values[x]})\n",
"\n",
" return to_return\n",
"\n",
"data = pd.read_csv(\"healthcare-dataset-stroke-data.csv\")\n",
"data = NormalizeData(data)\n",
"\n",
"\n",
2021-05-31 20:38:26 +02:00
"# Rozdzielenie etykiet i cech\n",
"data = data[['gender', 'age', 'bmi','smoking_status', 'work_type','hypertension','heart_disease','avg_glucose_level','stroke']]\n",
"\n",
2021-05-30 15:36:17 +02:00
"\n",
"\n",
2021-05-31 20:38:26 +02:00
"# Dane wejściowe - zbiór danych, wektor etykiet, wektor prawdopodobieństw a priori dla klas.\n",
2021-05-30 15:36:17 +02:00
"# Wygenerowanie wektora prawdopodobieństw a priori dla klas.\n",
"a_priori_prob = count_a_priori_prob(data_train)\n",
"labels = separate_labels_from_properties(X_train)\n",
"\n",
"class NaiveBayes():\n",
" def __init__(self, dataset, labels, a_priori_prob):\n",
" self.dataset = dataset\n",
" self.labels = labels\n",
" self.a_priori_prob = a_priori_prob\n",
" \n",
" def count_bayes(self):\n",
" label_probs_return = []\n",
" posteriori_return = []\n",
" final_probs = {'top_yes': 0.0, 'top_no': 0.0, 'total': 0.0}\n",
" \n",
" # self.labels - Wartości etykiet które nas interesują, opcjonalnie podane sa wszystkie.\n",
" # [{'gender': {'female', 'male', 'other'}}, {'age': {'50-59', '40-49', '60-69', '70+', '18-29', '30-39'}}, {'ever_married': {'no', 'yes'}}, {'Residence_type': {'rural', 'urban'}}, {'bmi': {'high', 'mid', 'low'}}, {'smoking_status': {'unknown', 'smokes', 'never_smoked', 'formerly_smoked'}}, {'work_type': {'self_employed', 'private', 'never_worked', 'govt_job'}}, {'hypertension': {'no', 'yes'}}, {'heart_disease': {'no', 'yes'}}]\n",
" # Dla kazdej z klas - 'yes', 'no'\n",
" for idx, cls in enumerate(list(set(self.dataset['stroke']))):\n",
" label_probs = []\n",
" for label in self.labels:\n",
" label_name = list(label.keys())[0]\n",
" for label_value in label[label_name]:\n",
" # Oblicz ilość występowania danej cechy w zbiorze danych np. heart_disease.yes\n",
"\n",
" amount_label_value_yes_class = len(self.dataset.loc[(self.dataset['stroke'] == 'yes') & (self.dataset[label_name] == label_value)])\n",
" amount_label_value_no_class = len(self.dataset.loc[(self.dataset['stroke'] == 'no') & (self.dataset[label_name] == label_value)])\n",
" amount_yes_class = len(self.dataset.loc[(self.dataset['stroke'] == 'yes')])\n",
" amount_no_class = len(self.dataset.loc[(self.dataset['stroke'] == 'no')]) \n",
" # Obliczenie P(heart_disease.yes|'stroke'|), P(heart_disease.yes|'no stroke') itd. dla kazdej cechy.\n",
" # Zapisujemy do listy w formacie (cecha.wartość: prob stroke, cecha.wartość: prob no stroke)\n",
" label_probs.append({str(label_name + \".\" + label_value):(amount_label_value_yes_class/amount_yes_class, amount_label_value_no_class/amount_no_class)})\n",
"\n",
" label_probs_return.append(label_probs)\n",
" # Obliczanie licznika wzoru Bayesa (mnozymy wartosci prob cech z prawdop apriori danej klasy):\n",
" top = 1\n",
" for label_prob in label_probs:\n",
" top *= list(label_prob.values())[0][idx]\n",
" top *= self.a_priori_prob[cls]\n",
"\n",
" final_probs[cls] = top\n",
" final_probs['total'] += top\n",
" \n",
" posteriori_return.append(final_probs['yes']/final_probs['total'])\n",
" posteriori_return.append(final_probs['no']/final_probs['total'])\n",
" return posteriori_return, label_probs_return\n",
"\n",
2021-05-31 16:05:08 +02:00
"labels = [{'age': {'70-79'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'correct'}},{'gender': {'male'}},{'smoking_status': {'smokes'}}]\n",
2021-05-31 20:38:26 +02:00
"naive_bayes = NaiveBayes(data, labels, a_priori_prob)\n",
2021-05-30 15:36:17 +02:00
"posteriori, labels = naive_bayes.count_bayes()"
]
},
{
"cell_type": "code",
2021-05-31 20:38:26 +02:00
"execution_count": null,
"id": "protecting-boating",
2021-05-30 15:36:17 +02:00
"metadata": {},
"outputs": [],
2021-05-31 20:38:26 +02:00
"source": []
2021-05-30 15:36:17 +02:00
},
{
"cell_type": "code",
2021-05-31 20:38:26 +02:00
"execution_count": 21,
"id": "bored-rouge",
2021-05-30 15:36:17 +02:00
"metadata": {},
"outputs": [
{
"data": {
2021-05-31 20:38:26 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAClIklEQVR4nOzdeXhV1d3//ffKQAZIGMMggyAiTjiB1CoqBVQURK0D6K8Vh4o+VXo71xmkVaugdahWaWvRais4VLHgUFvHFgtYbRUVBFQUUVGUAEkgw3r+SEgzQggZDvB+3de5zF577X2++9z0YuXDOmuFGCOSJEmSJEmSJCWKpOYuQJIkSZIkSZKkigyuJUmSJEmSJEkJxeBakiRJkiRJkpRQDK4lSZIkSZIkSQnF4FqSJEmSJEmSlFAMriVJkiRJkiRJCcXgWpIkSVKDCCHcH0L4MoTwTi3nQwjhzhDC4hDCf0MIBzR1jZIkSdo2GFxLkiRJaijTgOGbOH800KfsNQ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9OjRg0MPPZTZs2dXCpu3xsb7b87+++/fIO/XlPLz8915XpIkSQmlXbt2dO3alRtuuKHGCSOJJicnh5ycnOYuY4vEGFm/fj3p6enNXUq9OONakiRtc/r37w/ARx99BMBXX33F2LFjad++PZmZmQwePJj58+dXumbmzJn079+fli1b0rZtW77zne/w8ssvl5+vuFTI4MGDeeONN3jggQfKlyiZNm0aUHkpjWnTptGiRYtqszEWLFhACIEXXnihvO2pp55iwIABpKen07lzZy6//HIKCws3+ZyvvfYahx56KNnZ2WRnZ7Pffvvx6KOPltfx9ddfc/3115fXuHH2dQiB2267jQsvvJCcnBz69etX58+pquXLl7P77rszbNgw8vLyAHj11Vc5/PDDyczMpH379pxzzjmsWbNmk/eRJEmSKgohcPXVVzNz5kzefvvtTfZdtmwZY8aMoV27dmRmZnLUUUexcOHCan2OPvpoMjIy6NWrF9OmTau27Mj777/PmDFj6N69O5mZmey1117cfvvtlJSUAPDSSy9x7LHHAtCrVy9CCPTs2ROovpRGr169uOyyy6rVevLJJzNo0KDy41WrVjFu3Dg6depEeno6Bx98MP/61782+byFhYVceuml9OjRg7S0NHbaaSdOOOEENmzYwLRp0xg/fnz5ZxhCKH/GiRMn0qFDB1577TUOPPBA0tPTy39/mDFjBv369SMtLY3u3btz9dVXU1RUtMk6Jk+eTHp6OjNnzgSgoKCAyy+/nO7du5OWlsa+++7L7NmzN3mPrWFwLUmStjkbA+vOnTsDcPzxx/Pcc88xZcoUpk+fTklJCd/73vdYvHgxAEuWLOGkk05iyJAhPP300zz88MOMHDmSVatW1Xj/e+65h913351jjjmmfImSESNGVOt3/PHHE0Lgz3/+c6X26dOn06lTJ773ve8BpYPE73//+wwcOJCZM2cyYcIEpk6dypVXXlnrM+bm5jJy5Eh22WUXHn/8cR577DF++MMflofkf/7zn2ndujVnn312eY0HHHBA+fWTJ09mxYoV/OEPf+DOO++s0+dU0+d82GGH0bt3b/7yl7+QmZnJP/7xD4YNG0bnzp157LHHuP3225k9ezZnnnlmrc8iSZIk1eTkk0+mT58+3HDDDbX2WbVqFYMGDWLhwoXce++9zJgxg3Xr1jFs2DDy8/OB0pnFo0aN4r333uP+++/ntttu484776wWEC9fvpy+fftyzz33MHv2bM455xwmTJjAzTffDMABBxzAlClTAHjiiSeYM2dOtbH+Rqecckp5KLzR2rVrmTVrFmPGjAFg/fr1DBs2jBdeeIHJkyfz5JNPkpOTw7Bhw/j8889rfeabbrqJhx9+mJ/97Gf89a9/5fbbb6d169YUFxczYsQILrnkEoDy3wPuueee8mvz8vIYO3YsP/rRj3j22WcZOHAgzz//PKNHj+aAAw7gqaeeYvz48UyZMoULLrig1homTZrEhAkTmDlzJqNGjQJK1x+fNm0aV111FU8//TQHHnggo0aN4q233qr1PlvDpUIkSdI2YeNsgKVLl/LjH/+YrKwshg0bxrPPPss//vEPXnrpJQ4//HAAhgwZQs+ePZk8eTL33Xcfb775JllZWUyePLn8fsccc0yt77XnnnvSsmVLcnJyNrmESJs2bRg+fDjTp0+vFNxOnz6dk046ieTkZGKMXHbZZZx++umVBpRpaWmcf/75XHnllbRv377avRctWsTq1av51a9+RVZWFgBHHnlk+fn999+flJQUunXrVmONXbp0Yfr06eXHdfmcKlq8eDFDhgzhwAMP5E9/+hMtWrQA4IorruDggw+udO+uXbsydOhQ3nnnHfbee+9aPy9JkiSpoqSkJK688krOPvtsJk2axG677Vatzy9/+UvWrVvHW2+9Rbt27QA45JBD6NmzJ/fffz/nn38+s2fP5j//+Q9z587lwAMPBGDgwIH07NmT3r17l99r6NChDB06FCgNuwcNGkReXh6/+c1vuPLKK8nOzqZv375A6Xh742zrmowZM4ZbbrmF119/vXw8/vTTT7Nhw4by5Qwfeugh3nnnHRYsWECfPn0AGDZsGH379uXWW2+t9PtJRXPnzuW0005j7Nix5W2nnHIKABkZGeV11fR7QH5+PrfddhvHHXdcedvYsWMZPHgwDzzwAADDhw8H4Morr+Saa66hW7dule5x1VVXcdddd/HMM8+U/+7wt7/9jVmzZlX6feLII49k0aJF3HDDDdVC/IbgjGtJkpTwvv76a1JTU0lNTaVv374sXbqU6dOn06VLF+bOnUvHjh3LB08ALVu2ZOTIkbz22msA9OvXj9WrVzN27Fief/75Bt3UcfTo0fztb3/j66+/BuCtt95i0aJFjB49GigNoJctW8Ypp5xCUVFR+WvIkCEUFBTwzjvv1Hjf3r1706pVK0477TSeeuqpasuRbE7VYL4un9NGCxc
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACdZklEQVR4nOzdeZzVVf348deZfQZmhn2RRRARN3IB0RKVWMIF9wWyXEvsl9rX3NK0RMssJcs1xL5KZiUuqSi4ZKlpYojfLMUVEEEURRAGmIVZzu+PO9xmZxgG5gKvZ4/7mPmcz/mcz/tzwXzft+eeE2KMSJIkSZIkSZKUKtLaOgBJkiRJkiRJkmqycC1JkiRJkiRJSikWriVJkiRJkiRJKcXCtSRJkiRJkiQppVi4liRJkiRJkiSlFAvXkiRJkiRJkqSU0maF6xDC3SGEz0IIbzZyPoQQbgkhzA8h/CeEsP/WjlGSJElS85njS5IkqbW05YzracDhTZw/AhhY/ZoI/GYrxCRJkiSp5aZhji9JkqRW0GaF6xjj34GVTXQ5Frg3JrwCdAgh9Nw60UmSJEnaVOb4kiRJai0ZbR1AE3oBS2ocf1Td9kndjiGEiSRmbNCuXbshu++++1YJUJIkSVvPa6+99nmMsWtbx6HNYo4vSZKkpKZy/FQuXDdbjHEqMBVg6NChce7cuW0ckSRJklpbCOHDto5BW485viRJ0vavqRy/Lde43pilQJ8ax72r2yRJkiRtm8zxJUmS1CypXLieAZxevfP4QcDqGGO9rxBKkiRJ2maY40uSJKlZ2myp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b/I5X3rpJQ455BAKCgooKChg33335cEHH0zGsWLFCq655ppkjBtmX4cQuOmmm7jwwgvp2rUrgwcPbvb7VNfSpUvZfffdGT16NMXFxQC8+OKLHHbYYeTl5dG5c2fOOecc1qxZ0+Q4kiRJUk0hBK688kpmzJjBG2+80WTfxYsXM2HCBDp16kReXh5jx47l3XffrdfniCOOIDc3l/79+zNt2rR6y4688847TJgwgT59+pCXl8dee+3Fr3/9a6qqqgB4/vnnOfroowHo378/IQT69esH1F9Ko3///lx66aX1Yj355JMZPnx48njlypVMnDiR7t27k5OTw1e+8hX++c9/Nvm85eXlXHLJJfTt25fs7Gx22mknjj/+eNavX8+0adO44IILku9hCCH5jJMmTaJLly689NJLHHDAAeTk5CQ/PzzwwAMMHjyY7Oxs+vTpw5VXXklFRUWTcdx4443k5OQwY8YMAEpLS7nsssvo06cP2dnZ7LPPPsyaNavJMTaHhWtJkrTN2VCw7tGjBwDHHXccTz/9NJMnT2b69OlUVVXx1a9+lfnz5wOwYMECTjrpJEaOHMnjjz/OH/7wB8aNG8fKlSsbHP+OO+5g991358gjj0wuUXLUUUfV63fccccRQuCRRx6p1T59+nS6d+/OV7/6VSCRJJ5wwgkMGzaMGTNmcPXVVzN16lSuuOKKRp+xqKiIcePGscsuu/Dwww/z0EMPcdpppyWL5I888giFhYV861vfSsa4//77J6+/8cYb+eSTT/j973/PLbfc0qz3qaH3+dBDD2XAgAE88cQT5OXl8Y9//IPRo0fTo0cPHnroIX79618za9YszjrrrEafRZIkSWrIySefzMCBA7nuuusa7bNy5UqGDx/Ou+++y5QpU3jggQdYt24do0ePpqSkBEjMLD7mmGN4++23ufvuu7npppu45ZZb6hWIly5dyqBBg7jjjjuYNWsW55xzDldffTW/+MUvANh///2ZPHkyAH/+85+ZPXt2vVx/g1NOOSVZFN5g7dq1zJw5kwkTJgBQVlbG6NGjefbZZ7nxxht59NFH6dq1K6NHj2bZsmWNPvP111/PH/7wB37yk5/wl7/8hV//+tcUFhZSWVnJUUcdxcUXXwyQ/Bxwxx13JK8tLi7mjDPO4Nvf/jZPPfUUw4YN45lnnmH8+PHsv//+PPbYY1xwwQVMnjyZ888/v9EYrr32Wq6++mpmzJjBMcccAyTWH582bRo//OEPefzxxznggAM45phjeP311xsdZ3O4VIgkSdombJgNsHDhQr773e+Sn5/P6NGjeeqpp/jHP/7B888/z2GHHQbAyJEj6devHzfeeCN33nkn//rXv8jPz+fGG29MjnfkkUc2eq8999yTdu3a0bVr1yaXEOnQoQOHH34406dPr1W4nT59OieddBLp6enEGLn00ks5/fTTayWU2dnZnHfeeVxxxRV07ty53tjvvfceq1ev5rbbbiM/Px+Ar33ta8nz++23HxkZGfTu3bvBGHv27Mn06dOTx815n2qaP38+I0eO5IADDuBPf/oTWVlZAFx++eV85StfqTV2r169GDVqFG+++SZ77713o++XJEmSVFNaWhpXXHEF3/rWt7j22mvZbbfd6vX51a9+xbp163j99dfp1KkTAAcffDD9+vXj7rvv5rzzzmPWrFn8+9//Zs6cORxwwAEADBs2jH79+jFgwIDkWKNGjWLUqFFAotg9fPhwiouLueuuu7jiiisoKChg0KBBQCLf3jDbuiETJkzghhtu4JVXXknm448//jjr169PLmd433338eabbzJv3jwGDhwIwOjRoxk0aBC//OUva30+qWnOnDmceuqpnHHGGcm2U045BYDc3NxkXA19DigpKeGmm27i2GOPTbadccYZjBgxgt/97ncAHH744QBcccUVXHXVVfTu3bvWGD/84Q+59dZbefLJJ5OfHf76178yc+bMWp8nvva1r/Hee+9x3XXX1SvitwZnXEuSpJS3YsUKMjMzyczMZNCgQSxcuJDp06fTs2dP5syZQ7du3ZLJE0C7du0YN24cL730EgCDBw9m9erVnHHGGTzzzDOtuqnj+PHj+etf/8qKFSsAeP3113nvvfcYP348kChAL168mFNOOYWKiorka+TIkZSWlvLmm282OO6AAQNo374
2021-05-31 16:33:55 +02:00
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
2021-05-31 20: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v2JYRAnz59gNpLafTt25fLL7+8Vq2nnnoqQ4cOrTxevXo1EyZMoGvXrmRkZHDooYfy97//fbP3W1xczGWXXUbv3r1JT09nl1124aSTTmLjxo3MmDGDiRMnVn6GIYTKe5w8eTKdO3fm9ddf5+CDDyYjI6MyN3vkkUcYOHAg6enp9OrVi6uvvpqSkpLN1jF16lQyMjKYNWsWAIWFhVxxxRX06tWL9PR09t9/f+bMmbPZMbaFwfUOYlNg3a1bNwBOPPFEnn/+eaZNm8bMmTMpKyvjG9/4BkuWLAFg6dKlnHLKKQwfPpxnnnmGhx56iDFjxrB69eo6x7/nnnvYc889Oe644yqXKBk9enStfieeeCIhBJ588slq7TNnzqRr16584xvfAMr/spx88skMGTKEWbNmMWnSJO677z6uuuqqeu8xLy+PMWPGsNtuu/H444/z2GOP8e1vf7syJH/yySdp164d3/nOdyprPOiggyqvnzp1Kp9++im/+93vuPPOOxv0OdX1OR9xxBH069ePZ599lqysLP76178ycuRIunXrxmOPPcbtt9/OnDlzOOecc+q9F0mSJEmSpJ3dqaeeSv/+/bnhhhvq7bN69WqGDh3KokWLmD59Oo888ggbNmxg5MiRFBQUAOUzi8eOHcs777zD/fffz2233cadd95ZKyBesWIFAwYM4J577mHOnDmcd955TJo0iZtvvhmAgw46iGnTpgHwxBNPMHfu3FoZ1yannXZaZSi8yfr165k9ezbjx48HoKioiJEjR/Liiy8ydepUnnrqKXJzcxk5ciSfffZZvfd800038dBDD/GTn/yEP/3pT9x+++20a9eO0tJSRo8ezaWXXgpQmX/dc889ldfm5+dz1lln8d3vfpfnnnuOIUOG8MILLzBu3DgOOuggnn76aSZOnMi0adO48MIL661hypQpTJo0iVmzZjF27FigfP3xGTNm8OMf/5hnnnmGgw8+mLFjx/Lmm2/WO862cKmQVmzTT0WWLVvG97//fbKzsxk5ciTPPfccf/3rX3n55Zc58sgjARg+fDh9+vRh6tSp3HvvvfzrX/8iOzubqVOnVo533HHH1ftee++9N23atCE3N3ezS4i0b9+eUaNGMXPmzGrB7cyZMznllFNITk4mxsjll1/OmWeeWe0vVnp6OhdccAFXXXUVnTp1qjX24sWLWbt2Lb/4xS/Izs4G4Oijj648f+CBB5KSkkLPnj3rrLF79+7MnDmz8rghn1NVS5YsYfjw4Rx88MH84Q9/IC0tDYArr7ySQw89tNrYPXr0YMSIEbz11lvsu+++9X5ekiRJkiRJO6ukpCSuuuoqvvOd7zBlyhT22GOPWn1+/vOfs2HDBt588006duwIwGGHHUafPn24//77ueCCC5gzZw7//ve/mTdvHgcffDAAQ4YMoU+fPvTr169yrBEjRjBixAigPOweOnQo+fn5/OpXv+Kqq64iJyeHAQMGAOU506bZ1nUZP348t9xyC2+88UZlDvXMM8+wcePGymV8H3zwQd566y0WLlxI//79ARg5ciQDBgzg1ltvrZbLVTVv3jzOOOMMzjrrrMq20047DYDMzMzKuurKvwoKCrjttts44YQTKtvOOusshg0bxm9/+1sARo0aBcBVV13FNddcQ8+ePauN8eMf/5i77rqLP/7xj5WZ2Z///Gdmz55dLUc7+uijWbx4MTfccEOtEL8pOOO6lfryyy9JTU0lNTWVAQMGsGzZMmbOnEn37t2ZN28eXbp0qfwmAmjTpg1jxozh9ddfB2DgwIGsXbuWs846ixdeeKFJN3UcN24cf/7zn/nyyy8BePPNN1m8eDHjxo0DygPo5cuXc9ppp1FSUlL5Gj58OIWFhbz11lt1jtuvXz/atm3LGWecwdNPP11rOZItqRnMN+Rz2mTRokUcccQ
2021-05-31 16:33:55 +02:00
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
2021-05-31 20:38:26 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACrQklEQVR4nOzdd5xV1b3//9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PPsyZM2eL99geBteSJKnZ2RxYd+nSBYDjjjuO5557jqlTpzJjxgxKSkr43ve+x+LFiwFYsmQJJ554IsOGDePpp5/m4YcfZvTo0axevbra+99zzz3stttuHH300WVLlIwaNapKv+OOO44QAn/6058qtM+YMYPOnTvzve99D0gMEr///e8zePBgZs2axcSJE5k2bRpXXXVVjc+4du1aRo8ezS677MLjjz/OY489xg9/+MOykPxPf/oTbdq04eyzzy6rcf/99y+7fsqUKXz22Wf8/ve/584776zV51Td53zooYfSp08f/vznP5Odnc3f//53RowYQZcuXXjssce4/fbbmTNnDmeeeWaNzyJJkiRV56STTqJfv37ceOONNfZZvXo1Q4YM4f333+fee+9l5syZbNiwgREjRpCfnw8kZhaPGTOGd999l/vvv5/bbruNO++8s0pAvGLFCvr3788999zDnDlzOOecc5g4cSK33HILAPvvvz9Tp04F4IknnmDu3LlVxvqbnXzyyWWh8Gbr169n9uzZjBs3DoCNGzcyYsQIXnjhBaZMmcKTTz5Jbm4uI0aM4PPPP6/xmW+++WYefvhhfvrTn/KXv/yF22+/nTZt2lBcXMyoUaO45JJLAMp+D7jnnnvKrs3Ly+P000/nRz/6Ec8++yyDBw/m+eefZ+zYsey///489dRTTJgwgalTp3LBBRfUWMPkyZOZOHEis2bNYsyYMUBi/fHp06dz9dVX8/TTT3PAAQcwZswY3nzzzRrvsz1cKkSSJDULm2cDLF26lB//+Me0bt2aESNG8Oyzz/L3v/+dl156icMOOwyAYcOG0atXL6ZMmcJ9993Hv/71L1q3bs2UKVPK7nf00UfX+F577LEHLVu2JDc3d4tLiLRt25aRI0cyY8aMCsHtjBkzOPHEE0lNTSXGyGWXXcZpp51WYUCZkZHB+eefz1VXXUWHDh2q3HvRokWsWbOGX/3qV7Ru3RqAI444ouz8fvvtR1paGt27d6+2xq5duzJjxoyy49p8TuUtXryYYcOGccABB/DHP/6RFi1aAHDllVdy0EEHVbh3t27dGD58OG+//TZ77bVXjZ+XJEmSVF5KSgpXXXUVZ599NpMnT2bXXXet0ueXv/wlGzZs4M0336R9+/YAHHzwwfTq1Yv777+f888/nzlz5vDvf/+befPmccABBwAwePBgevXqRZ8+fcruNXz4cIYPHw4kwu4hQ4aQl5fHb37zG6666ipycnLo378/kBhvb55tXZ1x48Zx66238vrrr5eNx59++mk2bdpUtpzhQw89xNtvv83ChQvp168fACNGjKB///784he/qPD7SXnz5s3j1FNP5fTTTy9rO/nkkwHIysoqq6u63wPy8/O57bbbOPbYY8vaTj/9dIYOHcoDDzwAwMiRIwG46qqruPbaa+nevXuFe1x99dXcddddPPPMM2W/O/z1r39l9uzZFX6fOOKII1i0aBE33nhjlRC/PjjjWpIkJb1Vq1aRnp5Oeno6/fv3Z+nSpcyYMYOuXbsyb948OnXqVDZ4AmjZsiWjR4/mtddeA2DAgAGsWbOG008/neeff75eN3UcO3Ysf/3rX1m1ahUAb775JosWLWLs2LFAIoBetmwZJ598MkVFRWWvYcOGUVBQwNtvv13tffv06UOrVq049dRTeeqpp6osR7I1lYP52nxOm73
2021-05-31 16:33:55 +02:00
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
2021-05-31 20:38:26 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAJ/CAYAAACQpkQPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACwoUlEQVR4nOzdeXxV1bn4/8/KnEDCGAYZBAFxwgmkVlEpoKIgzkL91bEVe6v061ytA0irtkKtQ7WI91q02oqzKFStrWOLBWxtHUFARXEARZkykGH9/khIMxNCSE7w876v80r22muv/ezzSr3rPKzzrBBjRJIkSZIkSZKkRJHU0gFIkiRJkiRJklSZiWtJkiRJkiRJUkIxcS1JkiRJkiRJSigmriVJkiRJkiRJCcXEtSRJkiRJkiQpoaS0dABNrXPnzrFP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NmkZaWVmM1xltvvUUIgeeee66i7YknnmDIkCFkZGTQrVs3LrvsMoqKiup9zldeeYVDDjmEnJwccnJy2HfffXnooYcq4vjyyy+59tprK2LcvPo6hMBNN93EBRdcQG5uLoMGDWrw+1TdypUr2W233Rg1ahR5eXkAvPzyyxx22GFkZWXRqVMnzjnnHNavX1/vOJIkSVJlIQSuvPJK5syZwxtvvFFv3xUrVjBhwgQ6duxIVlYWRx55JIsXL67R56ijjiIzM5O+ffsya9asGmVH3n33XSZMmECvXr3Iyspizz335Oabb6a0tBSAF154gWOOOQaAvn37EkKgT58+QM1SGn379uXSSy+tEevJJ5/MsGHDKo7XrFnDxIkT6dq1KxkZGRx00EH84x//qPd5i4qKuOSSS+jduzfp6enstNNOHH/88WzatIlZs2YxadKkivcwhFDxjFOmTKFz58688sorHHDAAWRkZFR8fnjwwQcZNGgQ6enp9OrViyuvvJLi4uJ645g2bRoZGRnMmTMHgIKCAi677DJ69epFeno6++yzD/Pmzat3jG1h4lqSJLU6mxPW3bp1A+C4447jmWeeYfr06cyePZvS0lK+853vsHTpUgCWLVvGSSedxIgRI3jyySe5//77GTt2LGvWrKl1/DvuuIPddtuNo48+uqJEyZgxY2r0O+644wgh8Nhjj1Vpnz17Nl27duU73/kOUDZJPOGEExg6dChz5sxh8uTJzJw5kyuuuKLOZ1y3bh1jx45ll1124ZFHHuHhhx/mtNNOq0iSP/bYY7Rr147vf//7FTHuv//+FddPmzaNTz/9lN///vfceuutDXqfanufDz30UPr168dTTz1FVlYWf/vb3xg1ahTdunXj4Ycf5uabb2bevHmcddZZdT6LJEmSVJuTTz6ZAQMGcN1119XZZ82aNQwbNozFixczY8YMHnzwQTZu3MioUaPIz88HylYWjxs3jnfeeYe7776bm266iVtvvbVGgnjlypUMHDiQO+64g3nz5nHOOecwefJkfvnLXwKw//77M336dAAeffRR5s+fX2Ouv9kpp5xSkRTebMOGDcydO5cJEyYAUFhYyKhRo3juueeYNm0ajz/+OLm5uYwaNYrPPvuszme+4YY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YcyePbsiaZ2Xl8f8+fNrPMuwYcNITU3ltdde26oYJUmSpO9973v07t2bG264odbzzz33HIcffjg5OTkV88/s7GwGDx5cUfZu4cKFdOvWrSJpDWWLKzaXGNysoKCAyZMn079/f9LT00lNTeXKK6/k/fff32LZjOr2228/dt111yoLOmbPns1hhx1G165dK2IfPHgwffv2rYgd4LDDDqu3ZN++++7LrFmzuPHGG/nPf/5DjLHBcYUQOOqooyqOS0pK+Oc//1ljb6Dx48dTWlrK/Pnzq7RfdNF
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACnY0lEQVR4nOzdeXhV1b3/8ffKnEDCPMkgiIgTtQqit+JQhuJAnRVq69iKbdX+rHWstaKttUVqq1aLeK9Sr21FbVUUHHvVimIRW1vFAQURRFFEGZNAhvX744RjJkISQs4Jvl998pC99trrfPd5ku3qJ/usHWKMSJIkSZIkSZKULjJSXYAkSZIkSZIkSdUZXEuSJEmSJEmS0orBtSRJkiRJkiQprRhcS5IkSZIkSZLSisG1JEmSJEmSJCmtGFxLkiRJkiRJktJKyoLrEMIdIYSPQwivbWF/CCHcFEJ4J4TwnxDCfq1doyRJkqTGc44vSZKklpLKO66nA4c3sP8IYFDV10Tg961QkyRJkqTmm45zfEmSJLWAlAXXMca/A5820OUY4K6Y8CLQMYTQq3WqkyRJktRUzvElSZLUUrJSXUADegPLqm2/X9X2Ye2OIYSJJO7YoF27dkN33333VilQkiRJrefll1/+JMbYLdV1aJs4x5ckSVJSQ3P8dA6uGy3GOA2YBjBs2LA4f/78FFckSZKklhZCeC/VNaj1OMeXJEna8TU0x0/lGtdb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MMO4+WXX+YPf/hDcomS6dOnAzWX0pg+fTo5OTl17kRcsGABIQSeeuqpZNtDDz3EsGHDyMvLo2fPnlxyySWUlZU1eJ5z5szh4IMPpqioiKKiIr785S9z3333JetYtWoVV199dbLGzXdfhxC44YYbuOCCC+jWrRtDhgxp9PtU2/Lly9l9990ZPXo0xcXFADz33HMceuihFBQU0KVLF84++2zWrVvX4DiSGhZC4IorrmDmzJm8+uqrDfZdunQpEyZMoHPnzhQUFDB27FjeeuutOn2OOOII8vPzGTBgANOnT6+z7Mibb77JhAkT6Nu3LwUFBey111789re/pbKyEoBnnnmGr3/96wAMGDCAEAL9+/cH6i6lMWDAAC6++OI6tZ500kmMGDEiuf3pp58yceJEevToQV5eHl/5ylf4xz/+0eD5lpWVcdFFF9GvXz9yc3PZaaedOO6449i0aRPTp0/n/PPPT76HIYTkOU6aNImuXbsyZ84c9t9/f/Ly8pLX0HvvvZchQ4aQm5tL3759ueKKKygvL2+wjuuvv568vDxmzpwJQGlpKZdccgl9+/YlNzeXffbZh9mzZzc4hiRJajyDa0mS1OZsDqx79uwJwLHHHsvjjz/OlClTmDFjBpWVlXz1q1/lnXfeAWDRokWceOKJjBw5kocffpg//vGPjBs3jk8//bTe8W+99VZ23313jjzyyOQSJUcddVSdfsceeywhBB544IEa7TNmzKBHjx589atfBRIByfHHH8/w4cOZOXMmV111FdOmTePyyy/f4jmuXbuWcePGscsuu/CXv/yF+++/n1NPPTUZkj/wwAN06NCBb3/728ka99tvv+Tx119/PR9++CH/+7//y0033dSo96m+9/mQQw5h4MCBPPLIIxQUFPD8888zevRoevbsyf33389vf/tbZs+ezZlnnrnFc5HUOCeddBKDBg3i2muv3WKfTz/9lBEjRvDWW28xdepU7r33XjZs2MDo0aMpKSkBEncWH3300bzxxhvccccd3HDDDdx00011AuLly5czePBgbr31VmbPns3ZZ5/NVVddxa9+9SsA9ttvP6ZMmQLAX//6V+bOnVvnerfZySefnAyFN1u/fj2zZs1iwoQJAGzcuJHRo0fz1FN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05-30 15:36:17 +02:00
"text/plain": [
2021-05-31 16:05:08 +02:00
"<Figure size 1800x720 with 2 Axes>"
2021-05-30 15:36:17 +02:00
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
2021-05-31 16:33:55 +02:00
"labels = [[{'age': {'60-69'}},{'hypertension': {'no'}},{'heart_disease': {'yes'}},{'bmi': {'obesity_1'}},{'gender': {'female'}},{'smoking_status': {'smokes'}}],\n",
" [{'age': {'70-79'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'correct'}},{'gender': {'male'}},{'smoking_status': {'never_smoked'}}],\n",
" [{'age': {'70-79'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'correct'}},{'gender': {'female'}},{'smoking_status': {'never_smoked'}}],\n",
2021-05-31 20:38:26 +02:00
" [{'age': {'60-69'}},{'hypertension': {'no'}},{'heart_disease': {'yes'}},{'bmi': {'obesity_2'}},{'avg_glucose_level': {'210-250'}},{'gender': {'female'}},{'smoking_status': {'smokes'}}],\n",
" [{'age': {'0-29'}},{'hypertension': {'no'}},{'heart_disease': {'no'}},{'bmi': {'correct'}},{'avg_glucose_level': {'130-170'}},{'gender': {'male'}},{'smoking_status': {'never_smoked'}}],\n",
" [{'age': {'80-89'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'extreme'}},{'avg_glucose_level': {'210-250'}},{'gender': {'male'}},{'smoking_status': {'smokes'}}]\n",
" \n",
2021-05-31 16:33:55 +02:00
" \n",
" ]\n",
"\n",
2021-05-31 18:56:34 +02:00
"name = 1\n",
2021-05-31 16:33:55 +02:00
"for i in labels:\n",
" naive_bayes = NaiveBayes(data_train, i, a_priori_prob)\n",
" posteriori, labels = naive_bayes.count_bayes()\n",
2021-05-31 18:56:34 +02:00
" plot_priori(labels,posteriori, str(name))\n",
" name = name + 1"
2021-05-30 15:36:17 +02:00
]
2021-05-31 16:33:55 +02:00
},
{
"cell_type": "code",
2021-05-31 20:38:26 +02:00
"execution_count": 135,
"id": "gothic-statistics",
2021-05-31 16:33:55 +02:00
"metadata": {},
"outputs": [],
2021-05-31 20:38:26 +02:00
"source": [
"import pandas as pd \n",
"import numpy as np\n",
"from sklearn.model_selection import train_test_split\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Wizualizacja\n",
"def autolabel(rects, values ,ax):\n",
" # Attach some text labels.\n",
" for (rect, value) in zip(rects, values):\n",
" ax.text(rect.get_x() + rect.get_width() / 2.,\n",
" rect.get_y() + rect.get_height() / 2.,\n",
" '%.3f'%value,\n",
" ha = 'center',\n",
" va = 'center',\n",
" fontsize= 15,\n",
" color ='black') \n",
"def plot_priori(labels, posteriori, name): \n",
" keys =[ r\"$\\bf{\" + (x.split('.',1)[0]).replace('_', ' ')+ \"}$\" + '\\n' + x.split('.',1)[1] for i in range(1) for j in range(len(labels[i])) for x in labels[i][j].keys()]\n",
" aprori = [list(x) for i in range(1) for j in range(len(labels[i])) for x in labels[i][j].values()]\n",
" yes_aprori = np.array(aprori)[:,0]\n",
" no_aprori = np.array(aprori)[:,1]\n",
" \n",
" width = 0.55\n",
"\n",
" fig = plt.figure(figsize=(25,10))\n",
" \n",
" ax1 = fig.add_subplot(121)\n",
" rec1 = ax1.bar(keys,yes_aprori,width, color ='lime', label= 'Positive stroke')\n",
" rec2 = ax1.bar(keys,no_aprori,width, color ='crimson', bottom = yes_aprori, label= 'Negative stroke')\n",
" ax1.set_yticks(np.arange(0, 1.1,0.1))\n",
" ax1.set_ylabel('Probability',fontsize=18)\n",
" ax1.set_xlabel('\\nFeatures',fontsize=18)\n",
" ax1.tick_params(axis='x', which='major', labelsize=12)\n",
" autolabel(rec1,yes_aprori, ax1)\n",
" autolabel(rec2,no_aprori, ax1)\n",
" ax1.legend(fontsize=15)\n",
" \n",
" ax2 = fig.add_subplot(122)\n",
" rec3 = ax2.bar(0, posteriori[1],capsize=1 ,color=['crimson'], label='Negative stroke')\n",
" rec4 = ax2.bar(1, posteriori[0], color=['lime'],label='Positive stroke')\n",
" ax2.set_ylabel('Probability',fontsize=18)\n",
" ax2.set_xlabel('\\nClasses',fontsize=18)\n",
" ax2.set_xticks([0,1])\n",
" ax2.set_yticks(np.arange(0, 1.1,0.1))\n",
" ax2.tick_params(axis='x', which='major', labelsize=15)\n",
" autolabel(rec3,[posteriori[1]], ax2)\n",
" autolabel(rec4,[posteriori[0]], ax2)\n",
" ax2.legend(fontsize=15)\n",
" \n",
"# plt.show()\n",
" plt.savefig(name + \".png\", dpi=100)\n",
"\n",
"\n",
"# Wczytanie i normalizacja danych\n",
"def NormalizeData(data):\n",
" for col in data.columns:\n",
" if data[col].dtype == object: \n",
" data[col] = data[col].str.lower()\n",
" if col == 'smoking_status':\n",
" data[col] = data[col].str.replace(\" \", \"_\")\n",
" if col == 'stroke':\n",
" data[col] = data[col].replace({1: 'yes'})\n",
" data[col] = data[col].replace({0: 'no'})\n",
" if col == 'hypertension':\n",
" data[col] = data[col].replace({1: 'yes'})\n",
" data[col] = data[col].replace({0: 'no'})\n",
" if col == 'heart_disease':\n",
" data[col] = data[col].replace({1: 'yes'})\n",
" data[col] = data[col].replace({0: 'no'})\n",
" if col == 'bmi':\n",
" bins = [19,25,30,35,40,90]\n",
" labels=['correct','overweight','obesity_1','obesity_2','extreme']\n",
" data[col] = pd.cut(data[col], bins, labels = labels,include_lowest = True)\n",
" if col == 'age':\n",
" bins = [0, 30, 40, 50, 60, 70, 80, 90]\n",
" labels = ['0-29', '30-39', '40-49', '50-59', '60-69', '70-79', '80-89',]\n",
" data[col] = pd.cut(data[col], bins, labels = labels,include_lowest = True)\n",
" if col == 'avg_glucose_level':\n",
" bins = [50,90,130,170,210,250,290]\n",
" labels = ['50-90', '90-130','130-170','170-210','210-250','250-290']\n",
" data[col] = pd.cut(data[col], bins, labels = labels,include_lowest = True)\n",
" data = data.dropna()\n",
" return data\n",
"\n",
"def count_a_priori_prob(dataset):\n",
" is_stroke_amount = len(dataset[dataset.stroke == 'yes'])\n",
" no_stroke_amount = len(dataset[dataset.stroke == 'no'])\n",
" data_length = len(dataset.stroke)\n",
" return {'yes': float(is_stroke_amount)/float(data_length), 'no': float(no_stroke_amount)/float(data_length)}\n",
"\n",
"def separate_labels_from_properties(X_train):\n",
"\n",
" labels = X_train.columns\n",
" labels_values = {}\n",
" for label in labels:\n",
" labels_values[label] = set(X_train[label])\n",
" \n",
" to_return = []\n",
" for x in labels:\n",
" to_return.append({x: labels_values[x]})\n",
"\n",
" return to_return\n",
"\n",
"data = pd.read_csv(\"healthcare-dataset-stroke-data.csv\")\n",
"data = NormalizeData(data)\n",
"\n",
"\n",
"# Rozdzielenie etykiet i cech\n",
"data = data[['gender', 'age', 'bmi','smoking_status','hypertension','heart_disease','avg_glucose_level','stroke']]\n",
"data = data[data.gender != 'other']\n",
"\n",
"\n",
"# Dane wejściowe - zbiór danych, wektor etykiet, wektor prawdopodobieństw a priori dla klas.\n",
"# Wygenerowanie wektora prawdopodobieństw a priori dla klas.\n",
"a_priori_prob = count_a_priori_prob(data_train)\n",
"labels = separate_labels_from_properties(X_train)\n",
"\n",
"class NaiveBayes():\n",
" def __init__(self, dataset, labels, a_priori_prob):\n",
" self.dataset = dataset\n",
" self.labels = labels\n",
" self.a_priori_prob = a_priori_prob\n",
" self.a_priori_features = {}\n",
" \n",
" def fit(self):\n",
" # init dict\n",
" for feature in list(set(data.iloc[:,:-1])):\n",
" self.a_priori_features[feature] = {}\n",
" \n",
" \n",
" for feature in list(set(data.iloc[:,:-1])):\n",
" for feature_value in np.unique(self.dataset[feature]):\n",
" # Oblicz ilość występowania danej cechy w zbiorze danych np. heart_disease.yes\n",
"\n",
" amount_label_value_yes_class = len(self.dataset.loc[(self.dataset['stroke'] == 'yes') & (self.dataset[feature] == feature_value)])\n",
" amount_label_value_no_class = len(self.dataset.loc[(self.dataset['stroke'] == 'no') & (self.dataset[feature] == feature_value)])\n",
" amount_yes_class = len(self.dataset.loc[(self.dataset['stroke'] == 'yes')])\n",
" amount_no_class = len(self.dataset.loc[(self.dataset['stroke'] == 'no')]) \n",
" # Obliczenie P(heart_disease.yes|'stroke'|), P(heart_disease.yes|'no stroke') itd. dla kazdej cechy.\n",
" # Zapisujemy do listy w formacie (cecha.wartość: prob stroke, cecha.wartość: prob no stroke)\n",
" self.a_priori_features[feature][feature_value + '.' + 'yes'] = amount_label_value_yes_class/amount_yes_class\n",
" self.a_priori_features[feature][feature_value + '.' + 'no'] = amount_label_value_no_class/amount_no_class\n",
" \n",
" def count_bayes(self,labels):\n",
" label_probs_return = []\n",
" posteriori_return = []\n",
" final_probs = {'top_yes': 0.0, 'top_no': 0.0, 'total': 0.0}\n",
" \n",
" # self.labels - Wartości etykiet które nas interesują, opcjonalnie podane sa wszystkie.\n",
" # [{'gender': {'female', 'male', 'other'}}, {'age': {'50-59', '40-49', '60-69', '70+', '18-29', '30-39'}}, {'ever_married': {'no', 'yes'}}, {'Residence_type': {'rural', 'urban'}}, {'bmi': {'high', 'mid', 'low'}}, {'smoking_status': {'unknown', 'smokes', 'never_smoked', 'formerly_smoked'}}, {'work_type': {'self_employed', 'private', 'never_worked', 'govt_job'}}, {'hypertension': {'no', 'yes'}}, {'heart_disease': {'no', 'yes'}}]\n",
" # Dla kazdej z klas - 'yes', 'no'\n",
" for idx, cls in enumerate(list(set(self.dataset['stroke']))):\n",
" label_probs = []\n",
" for label in labels:\n",
" label_name = list(label.keys())[0]\n",
" for label_value in label[label_name]:\n",
" # Oblicz ilość występowania danej cechy w zbiorze danych np. heart_disease.yes\n",
" label_probs.append({str(label_name + \".\" + label_value):(self.a_priori_features[label_name][label_value + '.' + 'yes'], self.a_priori_features[label_name][label_value + '.' + 'no'])})\n",
"\n",
" label_probs_return.append(label_probs)\n",
" # Obliczanie licznika wzoru Bayesa (mnozymy wartosci prob cech z prawdop apriori danej klasy):\n",
" top = 1\n",
" for label_prob in label_probs:\n",
" top *= list(label_prob.values())[0][idx]\n",
" top *= self.a_priori_prob[cls]\n",
"\n",
" final_probs[cls] = top\n",
" final_probs['total'] += top\n",
" \n",
" posteriori_return.append(final_probs['yes']/final_probs['total'])\n",
" posteriori_return.append(final_probs['no']/final_probs['total'])\n",
" return posteriori_return, label_probs_return\n",
"\n",
"labels = [{'age': {'70-79'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'correct'}},{'gender': {'male'}},{'smoking_status': {'smokes'}}]\n",
"naive_bayes = NaiveBayes(data, labels, a_priori_prob)\n",
"naive_bayes.fit()"
]
2021-05-31 16:33:55 +02:00
},
{
"cell_type": "code",
2021-05-31 20:38:26 +02:00
"execution_count": 138,
"id": "quiet-enclosure",
2021-05-31 16:33:55 +02:00
"metadata": {},
2021-05-31 20:38:26 +02:00
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACkbklEQVR4nOzdd3yX1f3//8fJIAMSZIQhQxAQFy6Q2haVAlYQRK0D9FdnK/ZTpR/3VpA6WqHWUS3Sfim12gqOKhYctXW2WMCPtooDAZXhAEEBSQIZ5/dHQpoJIWS8A497b7kl17nOdd6v6124efLkvM8VYoxIkiRJkiRJkpQokpq6AEmSJEmSJEmSyjO4liRJkiRJkiQlFINrSZIkSZIkSVJCMbiWJEmSJEmSJCUUg2tJkiRJkiRJUkIxuJYkSZIkSZIkJRSDa0mSJEn1IoQwPYSwOoTwdg3nQwjh7hDCkhDCf0IIhzV2jZIkSWoeDK4lSZIk1ZcZwPBtnB8B9Cn9Ggf8uhFqkiRJUjNkcC1JkiSpXsQYXwbWbaPLCcADscRrwB4hhM6NU50kSZKak5SmLqC+tW/fPvbo0aOpy5AkSVI9e/3117+IMeY0dR3aKV2AFeWOV5a2fVq5YwhhHCWrsmnZsmX/fffdt1EKlCRJUuPZ1hx/lwuue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lV5vpbnXbaaWWh8FZff/01c+bMYezYsQBs3ryZYcOG8fzzzzN58mSeeOIJcnJyGDZsGJ999lmN93zbbbfx0EMP8dOf/pS//vWv3HnnnbRu3ZqioiJGjhzJZZddBlD2e8B9991Xdm1ubi5nn302P/zhD3nmmWcYOHAgzz33HGPGjOGwww7jySefZPz48UyZMoWLLrqoxhomTZrEhAkTmD17NqNHjwZK9h+fMWMG1157LU899RSHH344o0eP5s0336xxnJ3hViGSJKlZ2LoaYNmyZfz4xz8mKyuLYcOG8cwzz/CPf/yDF198kaOPPhqAIUOG0KNHDyZPnsz999/PG2+8QVZWFpMnTy4b77jjjqvxtfbff39atmxJTk7ONrcQ2WOPPRg+fDgzZ86sENzOnDmTU045heTkZGKMXHHFFZx11lkVJpRpaWlceOGFXHPNNbRr167K2IsXL2b9+vX86le/IisrC4Dvfve7ZecPPfRQUlJS6Nq1a7U1du7cmZkzZ5Yd1+Z9Km/JkiUMGTKEww8/nD/96U+0aNECgKuvvppvfetbFcbu0qULQ4cO5e233+bAAw+s8f2SJEmSyktKSuKaa67hBz/4AZMmTWKfffap0ueXv/wlmzZt4s0336Rt27YAfPvb36ZHjx5Mnz6dCy+8kLlz5/Lvf/+b+fPnc/jhhwMwcOBAevToQa9evcrGGjp0KEOHDgVKwu5BgwaRm5vLb37zG6655hqys7Pp27cvUDLf3rraujpjx47l9ttv57XXXiubjz/11FNs2bKlbDvDBx98kLfffptFixbRp08fAIYNG0bfvn35xS9+UeH3k/Lmz5/PGWecwdlnn13WdtpppwGQkZFRVld1vwfk5eVxxx13cMIJJ5S1nX322QwePJjf//73AAwfPhyAa665huuvv56uXbtWGOPaa6/lnnvu4emnny773eFvf/sbc+bMqfD7xHe/+10WL17MLbfcUiXErw+uuJYkSQlv7dq1pKamkpqaSt++fVm2bBkzZ86kc+fOzJ8/nw4dOpRNngBatmzJqFGjePXVVwHo168f69ev5+yzz+a5556r14c6jhkzhr/97W+sXbsWgDfffJPFixczZswYoCSAXr58OaeddhqFhYVlX0OGDCE/P5+333672nF79epFq1atOOOMM3jyySerbEeyPZWD+dq8T1u
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACbsUlEQVR4nOzdeZzVVf348deZfQZm2AUcQBAR168piGa4sYQs7gtk5VZipfgzt9xFy0wkS1ND7Gvk10rUSlFwLTVNDDEtdwRUFEURkW1mYJbz++POTLMxDMMw9w68nt/HfTCfc87n3PfnSl/f8/bcc0KMEUmSJEmSJEmSUkVasgOQJEmSJEmSJKkmC9eSJEmSJEmSpJRi4VqSJEmSJEmSlFIsXEuSJEmSJEmSUoqFa0mSJEmSJElSSrFwLUmSJEmSJElKKUkrXIcQ7gohfBZCeH0j/SGEcEsIYWEI4T8hhP1aO0ZJkiRJTWeOL0mSpJaSzBXXM4AjGukfDQyofE0Eft0KMUmSJElqvhmY40uSJKkFJK1wHWP8O/BFI0OOBu6OCS8CHUMIPVsnOkmSJEmbyxxfkiRJLSUj2QE0ohD4sMb1R5Vtn9QdGEKYSGLFBu3atRu02267tUqAkiRJaj0vv/zy5zHGbsmOQ1vEHF+SJEnVGsvxU7lw3WQxxunAdIDBgwfH+fPnJzkiSZIktbQQwgfJjkGtxxxfkiRp29dYjp/MPa43ZSnQu8Z1r8o2SZIkSW2TOb4kSZKaJJUL17OAUypPHj8QWBVjrPcVQkmSJElthjm+JEmSmiRpW4WEEP4IHAZ0DSF8BFwNZALEGKcBc4AxwEKgCDg9OZFKkiRJagpzfEmSJLWUpBWuY4zf2ER/BM5upXAkSZIkbSFzfEmSJLWUVN4qRJIkSZIkSZK0HbJwLUmSJEmSJElKKUnbK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prrzU6dsmSJUyYMIHOnTuTl5fHqFGjeOedd+qNGT16NLm5ufTr148ZM2bU23bk7bffZsKECfTu3Zu8vDz23HNPfvnLX1JRUQHAM888w5FHHglAv379CCHQt29foP5WGv369eOiiy6qF+uJJ57I0KFDq6+/+OILJk6cSPfu3cnJyeGggw7in//8Z6PPW1payoUXXkifPn3Izs5mxx135Nhjj2XDhg3MmDGDSZMmVX+GIYTqZ5w8eTJdu3bl+eefZ//99ycnJ6f694f77ruPvffem+zsbHr37s3ll19OWVlZo3HceOON5OTkMGvWLABKSkq4+OKL6d27N9nZ2eyzzz7MmTOn0Tm2hIVrSZLU5lQVrHv06AHAMcccw+OPP87UqVOZOXMmFRUVHH744SxcuBCARYsWccIJJzBs2DAefvhhfv/73zNu3Di++OKLBue//fbb2W233RgzZkz1FiVjx46tN+6YY44hhMBf/vKXWu0zZ86ke/fuHH744UAiSTzuuOMYMmQIs2bN4uqrr2b69OlceumlG33G1atXM27cOHbeeWf+9Kc/8cADD/Dtb3+7ukj+l7/8hQ4dOvCd73ynOsb99tuv+v4bb7yRTz75hP/7v//jlltuadLn1NDnfMghh9C/f38eeeQR8vLy+Mc//sGIESPo0aMHDzzwAL/85S+ZM2cOp59++kafRZIkSWrIiSeeyIABA7juuus2OuaLL75g6NChvPPOO0ybNo377ruPdevWMWLECIqLi4HEyuKjjjqKt956i7vuuoubbrqJW265pV6BeOnSpQwcOJDbb7+dOXPmcOaZZ3L11Vdzww03ALDffvsxdepUAP785z8zd+7cerl+lZNOOqm6KFxl7dq1zJ49mwkTJgCwfv16RowYwVNPPcWNN97Igw8+SLdu3RgxYgTLli3b6DNff/31/P73v+fHP/4xTz75JL/85S/p0KED5eXljB07lgsuuACg+veA22+/vfreoqIiTj31VL773e/y2GOPMWTIEJ544gnGjx/Pfvvtx0MPPcSkSZOYOnUq55xzzkZjuPbaa7n66quZNWsWRx11FJDYf3zGjBlcdtllPPzww+y///4cddRRvPrqqxudZ0u4VYgkSWoTqlYDLF68mB/84Afk5+czYsQIHnvsMf7xj3/wzDPPcOihhwIwbNgw+vbty4033sgdd9zBK6+8Qn5+PjfeeGP1fGPGjNnoe+2xxx60a9eObt26NbqFSMeOHTniiCOYOXNmrcLtzJkzOeGEE0hPTyfGyEUXXcQpp5xSK6HMzs7m7LPP5tJLL6VLly715l6wYAGrVq3i1ltvJT8/H4Cvf/3r1f377rsvGRkZ9OrVq8EYe/bsycyZM6uvm/I51bRw4UKGDRvG/vvvzx//+EeysrIAuOSSSzjooINqzV1YWMjw4cN5/fXX2WuvvTb6eUmSJEk1paWlcemll/Kd73yHa6+9ll133bXemF/84hesW7eOV199lc6dOwPwta99jb59+3LXXXdx9tlnM2fOHP79738zb9489t9/fwCGDBlC37596d+/f/Vcw4cPZ/jw4UCi2D106FCKioq48847ufTSSykoKGDgwIFAIt+uWm3dkAkTJjBlyhRefPHF6nz84YcfZsOGDdXbGd5zzz28/vrrvPHGGwwYMACAESNGMHDgQH7+85/X+v2kpnnz5nHyySdz6qmnVreddNJJAOTm5lbH1dDvAcXFxdx0000cffTR1W2nnnoqhx12GL/73e8AOOKIIwC49NJLueKKK+jVq1etOS677DJ+9atf8eijj1b/7vDXv/6V2bNn1/p94utf/zoLFizguuuuq1fEbwmuuJYkSSlvxYoVZGZmkpmZycCBA1m8eDEzZ86kZ8+ezJs3jx122KE6eQJo164d48aN4/nnnwdg7733ZtWqVZx66qk88cQTLXqo4/jx4/nrX//KihUrAHj11VdZsGAB48ePBxIF6CVLlnDSSSdRVlZW/Ro2bBglJSW8/vrrDc7bv39/2rd
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAAL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TjrpJBYtWtSw70kI3HnnnYnjqVOn8uSTT1br17NnTy699NIGfe0tdfPNN/Piiy826JjJdH+SJEmSJEk1WZR3aJN8bYmN2dZRRx1V7dzJJ5/M4MGDt/Ld2HIffPABEydO5Ntvv63UPm3aNEIIrF27tmkKq2Du3LlMnDixQcdMpvvbyOC6mWrdujVz5sxhzpw5TJkyhTfffJOhQ4eybt26BnuNOXPmcMoppySOawuu//jHP/KTn/ykwV53a2yL4FqSJEmSJEkN77nnnmPevHlNXUYlH3zwAdddd1214HrEiBHMmTOH7Ozspimsgrlz53Ldddc1dRnbXFpTF6Atk5aWxkEHHQTAQQcdRI8ePTj00EOZPXt2pbB5a2wcf1P233//Bnm9xlRQUOATeCVJkiRJkppIu3bt6Nq1K9dff32NCyWTTV5eHnl5eU1dxmaJMbJ+/XoyMzObupQt4orr7UT//v0B+PjjjwH46quvGDt2LO3btyc7O5vBgwczf/78StfMnDmT/v3707JlS9q2bct3vvMdXnrppcT5iluFDB48mNdff53f//73iS1Kpk2bBlTeSmPatGm0aNGi2k+l3nnnHUIIPP/884m2p556igEDBpCZmUnnzp25/PLLKSoqqvM+X331VQ499FByc3PJzc1lv/3249FHH03U8fXXX3Pdddclaty4+jqEwC233MKFF15IXl4ee++9d73fp6qWLVvGbrvtxrBhw8jPzwfglVde4fDDDyc7O5v27dtz7rnnsmbNmjrHkSRJkiRJ2lGFELjqqquYOXMmb731Vp19lyxZwpgxY2jXrh3Z2dkcddRRLFiwoFqfo48+mqysLHr16sW0adOqbTvy/vvvM2bMGLp37052djZ77rknt956K6WlpQC8+OKLHHvssQD06tWLEAI9e/YEqm+l0atXLy677LJqtZ5yyikMGjQocbxy5UrGjRtHp06dyMzM5OCDD+af//xnnfdbVFTEpZdeSo8ePcjIyGCnnXbihBNOYMOGDUybNo3x48cn3sMQQuIeJ06cSIcOHXj11Vc58MADyczMTORmM2bMYO+99yYjI4Pu3btz1VVXUVxcXGcdkydPJjMzk5kzZwJQWFjI5ZdfTvfu3cnI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kyax6667Vuvz61//mnXr1vHmm2/Srl07AA455BB69uzJ/fffz/nnn8/s2bP517/+xdy5cznwwAMBGDhwID179qR3796JsYYOHcrQoUOBsrB70KBB5Ofnc99993HllVeSm5tLv379gLKcaeNq65qMGTOGm2++mddeey2RQz399NNs2LAhsY3vgw8+yNtvv80777xD3759ARg2bBj9+vXjV7/6VaVcrqK5c+dy+umnM3bs2ETbqaeeCkBWVlairpryr4KCAm655RaOO+64RNvYsWMZPHgwv//97wEYPnw4AFdeeSVXX3013bp1qzTGz372M+644w7+/Oc/JzKzv/71r8yaNatSjnbkkUfywQcfcP3111cL8RuCK66bqa+//pr09HTS09Pp168fixcvZvr06XTp0oW5c+fSsWPHxG8igJYtWzJy5EheffVVAPbee29WrVrF2LFjee655xr0oY6jR4/mr3/9K19//TUAb775Jh988AGjR48GygLoJUuWcOqpp1JcXJz4GjJkCIWFhbz99ts1jtu7d29atWrF6aefzlNPPVVtO5JNqRrM1+d92mjBggUcdthhDBo
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACtEElEQVR4nOzdd5hW1b2//3tNYQow1KFIEQTEhg0kRlEJoIIgdkF/sSaiJ0qOvStILIkQY4lGMV9CjCaCJYoBS0ysCQbwxKhYEFARbChKnYEp6/fHM0ymwjBMeQbv17nmYvbaa6/92RNysubNetYOMUYkSZIkSZIkSUoWKY1dgCRJkiRJkiRJZRlcS5IkSZIkSZKSisG1JEmSJEmSJCmpGFxLkiRJkiRJkpKKwbUkSZIkSZIkKakYXEuSJEmSJEmSkorBtSRJkqQ6EUKYFkL4MoTwdjXnQwjhzhDC4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fW6OdU1c/50EMPpVevXvzlL38hOzubf/zjHwwbNoxOnTrx6KOPcvvttzNnzhzOOuusap9FkiRJqspJJ51Enz59uOmmm6rts2rVKgYNGsT777/Pvffey8yZM1m/fj3Dhg0jLy8PSKwsHj16NO+++y7Tpk3jtttu484776wUEK9YsYK+fftyzz33MGfOHM455xwmTJjAL37xCwD2339/pkyZAsDjjz/O3LlzK831Nzv55JNLQ+HN1q1bx+zZsxk7diwAGzduZNiwYTz//PNMnjyZJ554gtzcXIYNG8bnn39e7TPfcsstPPTQQ/zsZz/jr3/9K7fffjutWrWiqKiIkSNHcskllwCU/h5wzz33lF67YcMGzjjjDH784x/zzDPPMHDgQJ577jnGjBnD/vvvz5NPPsn48eOZMmUKF1xwQbU1TJo0iQkTJjBr1ixGjx4NJPYfnz59OldffTVPPfUUBxxwAKNHj+aNN96odpzt4VYhkiSpSdi8GmDp0qX85Cc/oWXLlgwbNoxnnnmGf/zjH7z44oscdthhAAwZMoQePXowefJk7rvvPv7973/TsmVLJk+eXDreUUcdVe299thjD5o3b05ubu4WtxBp3bo1w4cPZ8aMGeWC2xkzZnDiiSeSmppKjJHLLruM008/vdyEMiMjg/PPP5+rrrqKdu3aVRp70aJFrF69ml//+te0bNkSgCOOOKL0/H777UdaWhpdu3atssbOnTszY8aM0uOa/JzKWrx4MUOGDOGAAw7gT3/6E82aNQPgyiuv5KCDDio3dpcuXRg6dChvv/02e+21V7U/L0mSJKmslJQUrrrqKn70ox8xadIkdt1110p9fvWrX7F+/XreeOMN2rZtC8DBBx9Mjx49mDZtGueffz5z5szhP//5D/PmzeOAAw4AYODAgfTo0YNevXqVjjV06FCGDh0KJMLuQYMGsWHDBu6//36uuuoqcnJy6Nu3L5CYb29ebV2VsWPHcuutt/Laa6+VzsefeuopNm3aVLqd4YMPPsjbb7/NwoUL6dOnDwDDhg2jb9++/PKXvyz3+0lZ8+bN49RTT+WMM84obTv55JMByMrKKq2rqt8D8vLyuO222zjmmGNK28444wwGDx7M73//ewCGDx8OwFVXXcW1115L165dy41x9dVXc9ddd/H000+X/u7wt7/9jdmzZ5f7feKII45g0aJF3HTTTZVC/LrgimtJkpT0vv76a9LT00lPT6dv374sXbqUGTNm0LlzZ+bNm0eHDh1KJ08AzZs3Z9SoUbz66qsA9OvXj9WrV3PGGWfw3HPP1elLHceMGcPf/vY3vv76awDeeOMNFi1axJgxY4BEAL1s2TJOPvlkCgsLS7+GDBlCfn4+b7/9dpXj9urVixYtWnDqqafy5JNPVtqOZGsqBvM1+Tlt9v7
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAJ/CAYAAACQpkQPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACw70lEQVR4nOzdeXxV1b3//9fKnEASpjDIIIiIojiBaC0qBVQQirOg3+vYiv1V6HWu1gGkVVul1rnW3ktpr7biVEXBobaOLRawtXUEARXFARRlSgIZ1u+PhNOMEEJITvD1vI/zMHvttdf57POg3JU366wdYoxIkiRJkiRJkpQsUlq6AEmSJEmSJEmSqjK4liRJkiRJkiQlFYNrSZIkSZIkSVJSMbiWJEmSJEmSJCUVg2tJkiRJkiRJUlJJa+kCmlqnTp1i7969W7oMSZIkNbFXX3318xhjQUvXoebnHF+SJGnntKU5/k4XXPfu3ZuFCxe2dBmSJElqYiGED1q6BrUM5/iSJEk7py3N8d0qRJIkSZIkSZKUVAyuJUmSJEmSJElJxeBakiRJkiRJkpRUDK4lSZIkSZIkSUnF4FqSJEmSJEmSlFQMriVJkiRJkiRJSSWtpQuQJEk71tq1a1m5ciUlJSUtXYpUr/T0dDp37kxeXl5LlyJJkpT0nOOrNdjeOb7BtSRJO7G1a9fy2Wef0b17d7KzswkhtHRJUi0xRo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1tuuYXy8nIAnn/+eb797W8D0KdPH0II9O7dG6i9lUafPn249NJLa9V68sknM3To0MTx6tWrmThxIl26dCErK4tDDz2Uv//971u835KSEi655BJ69epFZmYmu+yyC8cffzybNm1i5syZTJ48OfEZhhAS9zh16lQ6derEyy+/zEEHHURWVlbi94cHHniAgQMHkpmZSc+ePbnyyispLS3dYh033XQTWVlZzJ49G4Di4mIuu+wyevbsSWZmJvvttx9z587d4hjbw+BakiS1OpsD665duwJw3HHH8fTTTzN9+nRmzZpFeXk53/rWt1iyZAkAS5cu5aSTTmL48OE8/vjj3HfffYwdO5bVq1fXOf5dd93FnnvuyTHHHJPYomTMmDG1+h133HGEEPjjH/9YrX3WrFl06dKFb33rW0DFJPGEE05gyJAhzJ49mylTpnDPPfdwxRVX1HuPa9euZezYsey22248/PDDPPTQQ5x++umJkPyPf/wj+fn5fOc730nUeOCBByauv+mmm/jkk0/4v//7P2677bYGfU51fc6HH344ffv25YknniAnJ4e//vWvjBw5kq5du/LQQw9xyy23MHfuXM4+++x670WSJEmqy8knn0y/fv247rrr6u2zevVqhg4dyqJFi7j77rt54IEH2LBhAyNHjqSoqAioWFk8btw43n77bWbMmMHNN9/MbbfdVisgXrFiBf379+euu+5i7ty5nHvuuUyZMoWf/exnABx44IFMnz4dgEceeYR58+bVmutvdsoppyRC4c3Wr1/PnDlzmDBhAgAbN25k5MiRPPvss9x00008+uijFBQUMHLkSD799NN67/mGG27gvvvu48c//jF/+tOfuOWWW8jPz6esrIwxY8Zw8cUXAyR+D7jrrrsS1xYWFnLmmWfy3e9+l6eeeoohQ4bwzDPPMH78eA488EAee+wxJk+ezPTp05k0aVK9NUybNo0pU6Ywe/Zsxo0bB1TsPz5z5kx+9KMf8fjjj3PQQQcxbtw4XnvttXrH2R5uFSJJklqFzasBli1bxve//31yc3MZOXIkTz31FH/96195/vnnOeKIIwAYPnw4vXv35qabbuJXv/oV//znP8nNzeWmm25KjHfMMcfU+14DBgygTZs2FBQUbHELkXbt2jFq1ChmzZpVLbidNWsWJ510EqmpqcQYufTSSznjjDOqTSgzMzM5//zzueKKK+jYsWOtsRcvXsyaNWu44447yM3NBeCoo45KnD/ggANIS0ujR48eddbYrVs3Zs2alThuyOdU1ZIlSxg+fDgHHXQQf/jDH8jIyADg8ssv59BDD602dvfu3RkxYgRvvPEG++yzT72flyRJklRVSkoKV1xxBd/5zneYNm0ae+yxR60+v/jFL9iwYQOvvfYaHTp0AOCb3/wmvXv3ZsaMGZx//vnMnTuXf/3rX8yfP5+DDjoIgCFDhtC7d2/69u2bGGvEiBGMGDECqAi7hw4dSmFhIb/+9a+54ooryMvLo3///kDFfHvzauu6TJgwgRtvvJFXXnklMR9//PHH2bRpU2I7w3vvvZc33niDN998k379+gEwcuRI+vfvz89//vNqv59UNX/+fE477TTOPPPMRNspp5wCQHZ2dqKuun4PKCoq4uabb+bYY49NtJ155pkMGzaM3/72twCMGjUKgCuuuIKrrrqKHj16VBvjRz/6EbfffjtPPvlk4neHP//5z8yZM6fa7xNHHXUUixcv5rrrrqsV4jcFV1xLkqSk98UXX5Cenk56ejr9+/dn2bJlzJo1i27dujF//nw6d+6cmDwBtGnThrFjx/Lyyy8DMHDgQNasWcOZZ57JM88806QPdRw/fjx//vOf+eKLLwB47bXXWLx4MePHjwcqAujly5dzyimnUFpamngNHz6c4uJi3njjjTrH7du3L23btuW0007jscceq7UdydbUDOYb8jlttmjRIg4//HCGDh3KrFmzEqF1YWEh8+bNq3UvQ4cOJT09nVdffXWbapQkSZL+67/+i169enHDDTfUef7ZZ5/lyCOPJC8vLzH/zM3NZdCgQYlt7xYsWEDXrl0ToTVULK7YvMXgZsXFxUyZMoXdd9+dzMxM0tPTufLKK3nvvfe2um1GTQcccAB77LFHtQUds2bN4ogjjqBLly6J2gcNGkSfPn0StQMcccQRW9yyb//992fmzJnceOON/Pvf/ybG2OC6QgiMHj06cVxWVsY//vGPWs8GGj9+POXl5cybN69a+0U
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABa4AAAKDCAYAAADy9p1tAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACooklEQVR4nOzdeZyVZf3/8dc1+wzMDKuALIKIuPE1BdEUl1hCxdwVslxLrJR+ZmqaqaCZiWRpakh9jcxKXFJRcO2r5oIhlrmLggiiKIKsMwOzXL8/zjDOxjAzDHPO4Ovp4zyY+7qv+z6f+zzg7uo917nuEGNEkiRJkiRJkqRUkZbsAiRJkiRJkiRJqs7gWpIkSZIkSZKUUgyuJUmSJEmSJEkpxeBakiRJkiRJkpRSDK4lSZIkSZIkSSnF4FqSJEmSJEmSlFKSFlyHEG4PIXwaQnh9M/tDCOGmEMJ7IYRXQwj7tnaNkiRJkhrPMb4kSZJaSjJnXE8HDm9g/xHAgMrXeOB3rVCTJEmSpOabjmN8SZIktYCkBdcxxn8CKxvocgxwR0x4EegQQujROtVJkiRJairH+JIkSWopGckuoAE9gSXVtj+sbPu4dscQwngSMzZo167d4N12261VCpQkSVLrefnllz+LMXZNdh3aKo7xJUmSVKWhMX4qB9eNFmOcBkwDGDJkSJw3b16SK5IkSVJLCyF8kOwa1Hoc40uSJG3/GhrjJ3ON6y1ZCvSutt2rsk2SJElS2+QYX5IkSY2SysH1TOC0yiePHwCsjjHW+QqhJEmSpDbDMb4kSZIaJWlLhYQQ/gYcBnQJIXwIXAlkAsQYpwKzgSOB94Ai4MzkVCpJkiSpMRzjS5IkqaUkLbiOMX5zC/sjcG4rlSNJkiRpKznGlyRJUktJ5aVCJEmSJEmSJElfQgbXkiRJkiRJkqSUkrSlQiRJUutYs2YNn376KaWlpckuRdqszMxMdthhBwoKCpJditog73NqC7zPSZLUNAbXkiRtx9asWcMnn3xCz549yc3NJYSQ7JKk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dh69+5NXl4ee+65J7/5zW+oqKgA4Omnn+Yb3/gGAP369SOEQN++fYG6S2n069ePiy66qE6tJ510EsOGDavaXrlyJePHj6dbt27k5ORw4IEH8q9//avB6y0tLeXCCy+kT58+ZGdns+OOO3LcccexceNGpk+fzoQJE6o+wxBC1TVOnDiRLl268Nxzz7HffvuRk5NTdQ+9++67GTRoENnZ2fTu3ZvLLruMsrKyBuu4/vrrycnJYebMmQCUlJRw8cUX07t3b7Kzs9l7772ZPXt2g+eQJEmNZ3AtSZLanE2Bdffu3QE49thjeeyxx5gyZQozZsygoqKCr33ta7z33nsALFiwgBNPPJHhw4fz0EMP8Ze//IWjjjqKlStX1nv+W2+9ld12240jjzyyaomSMWPG1Ol37LHHEkLg/vvvr9E+Y8YMunXrxte+9jUgEZAcf/zxDB06lJkzZ3LllVcybdo0Lr300s1e45o1azjqqKPYeeedue+++7j33ns59dRTq0Ly+++/n8LCQr7zne9U1bjvvvtWHX/99dfz8ccf8+c//5mbbrqpUZ9TfZ/zIYccQv/+/Xn44YfJy8vj+eefZ+TIkXTv3p17772X3/zmN8yePZszzzxzs9ciqXFOOukkBgwYwDXXXLPZPitXrmTYsGG88847TJ06lbvvvpv169czcuRIiouLgcTM4qOPPpq33nqL22+/nRtuuIGbbrqpTkC8dOlSBg4cyK233srs2bM5++yzufLKK7nuuusA2HfffZkyZQoAf//735kzZ06d+90mJ598clUovMm6deuYNWsW48aNA2DDhg2MHDmSJ598kuuvv54HHniArl27MnLkSJYtW7bZa7722mv5y1/+wtVXX80TTzzBb37zGwoLCykvL2fMmDH8+Mc/Bqi6F956661VxxYVFXH66afz3e9+l0cffZShQ4fy+OOPM3bsWPbdd18efPBBJkyYwJQpUzjvvPM2W8NVV13FlVdeycyZMzn66KOBxPrj06dP56c//SkPPfQQ++23H0cffTSvvPLKZs8jSZIaz6VCJElSm7BpJtzChQv5wQ9+QH5+PiNHjuTRRx/l+eef5+mnn+bQQw8FYPjw4fTt25frr7+e2267jf/85z/k5+dz/fXXV53vyCOP3Ox77bHHHrRr146uXbs2uIRIhw4dOPzww5kxY0aN4HbGjBmceOKJpKenE2Pkoosu4rTTTqsRpmRnZ3Puuedy6aWX0rlz5zrnnj9/PqtXr+bmm28mPz8fgK9//etV+/fZZx8yMjLo1atXvTX26NGDGTNmVG035nOq7r333mP48OHst99+/O1vfyMrKwuASy65hAMPPLDGuXv27MmIESN4/fXX2WuvvTb7eUlqWFpaGpdeeinf+c53uOqqq9h1113r9Pn1r3/N+vXreeWVV+jUqRMABx10EH379uX222/n3HPPZfbs2fz3v/9l7ty57LfffgAMHTqUvn370r9//6pzjRgxghEjRgCJsHvYsGEUFRXx+9//nksvvZSCggIGDhwIJO45m2Zb12fcuHFMnjyZF198seqe9NBDD7Fx48aqJZ3uvPNOXn/9dd544w0GDBgAwMiRIxk4cCC/+tWvatyjq5s7dy6nnHIKp59+elXbySefDEBubm5VXfXdC4uLi7nhhhs45phjqtpOP/10DjvsMP70pz8BcPjhhwNw6aWX8rOf/YxevXrVOMdPf/pTfvvb3/LII49U3T//8Y9/MGvWrBr31K9//evMnz+fa665pk6IL0mSms4Z15IkKeWtWLGCzMxMMjMzGThwIAsXLmTGjBn06NGDuXPnssMOO1QFBwDt2rXjqKOO4rnnngNg0KBBrF69mtNPP53HH3+8RR/qOHbsWP7xj3+wYsUKAF555RXmz5/P2LFjgUQAvXjxYk4++WTKysqqXsOHD6ekpITXX3+93vP
"text/plain": [
"<Figure size 1800x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"labels = [[{'age': {'60-69'}},{'hypertension': {'no'}},{'heart_disease': {'yes'}},{'bmi': {'obesity_1'}},{'gender': {'female'}},{'smoking_status': {'smokes'}}],\n",
" [{'age': {'70-79'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'obesity_2'}},{'gender': {'male'}},{'smoking_status': {'smokes'}}],\n",
" [{'age': {'70-79'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'correct'}},{'gender': {'female'}},{'smoking_status': {'never_smoked'}}],\n",
" [{'age': {'60-69'}},{'hypertension': {'no'}},{'heart_disease': {'yes'}},{'bmi': {'obesity_2'}},{'avg_glucose_level': {'210-250'}},{'gender': {'female'}},{'smoking_status': {'smokes'}}],\n",
" [{'age': {'0-29'}},{'hypertension': {'no'}},{'heart_disease': {'no'}},{'bmi': {'correct'}},{'avg_glucose_level': {'130-170'}},{'gender': {'male'}},{'smoking_status': {'never_smoked'}}],\n",
" [{'age': {'80-89'}},{'hypertension': {'yes'}},{'heart_disease': {'yes'}},{'bmi': {'extreme'}},{'avg_glucose_level': {'210-250'}},{'gender': {'male'}},{'smoking_status': {'smokes'}}]\n",
" \n",
" \n",
" ]\n",
"\n",
"name = 1\n",
"for i in labels:\n",
" posteriori, labels = naive_bayes.count_bayes(i)\n",
" plot_priori(labels,posteriori, str(name))\n",
" name = name + 1"
]
2021-05-30 15:36:17 +02:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}