Machine Learning
КНЕУ::ІІТЕ
2023-03-07
Середнє \(\left[\color{#e64173}{y_0} - \hat{\color{#20B2AA}{f}}\!\left( \color{#e64173}{x_0} \right) \right]^2\) для спостережень \(\left( \color{#e64173}{y_0},\, \color{#e64173}{x_0} \right)\) на нашій тестовій вибірці.
Елемент, який знаходиться в центрі нашої уваги, це (у тестовій вибірці) помилка передбачення \[\color{#FFA500}{\mathbf{y}}_i - \hat{\color{#20B2AA}{f}}\!\left( \color{#6A5ACD}{x}_i \right) = \color{#FFA500}{\mathbf{y}}_i - \hat{\color{#FFA500}{\mathbf{y}}}_i\] різниця між міткою \(\left( \color{#FFA500}{\mathbf{y}} \right)\) та її прогнозом \(\left( \hat{\color{#FFA500}{\mathbf{y}}} \right)\).
Відстань (тобто невід’ємне значення) між справжнім значенням і його прогнозом часто називають loss.
Loss функції агрегують та кількісно визначають похибки.
L1 функція втрат: \(\sum_i \big| y_i - \hat{y}_i \big|\) MAE: \(\dfrac{1}{n}\sum_i \big| y_i - \hat{y}_i \big|\)
L2 функція втрат: \(\sum_i \left( y_i - \hat{y}_i \right)^2\) MSE: \(\dfrac{1}{n} \sum_i \left( y_i - \hat{y}_i \right)^2\)
Зверніть увагу, що обидві функції накладають припущення.
Обидві припускають, що переоцінка однаково погана, як і недооцінка.
Обидві припускають, що помилки однаково шкідливі для всіх \((i)\).
Вони відрізняються у своїх припущеннях щодо величини помилок.
Дуже простий одновимірний набір даних \(\left(\mathbf{y},\, \mathbf{x} \right)\)
… на якому ми виконуємо просту лінійну регресію.
Кожна точка \(\left( y_i,\, x_i \right)\) пов’язана з loss (помилка).
Функція втрат L1 зважує всі помилки однаково: \(\sum_i \big| y_i - \hat{y}_i \big|\)
Функція втрат L2 зважує похибки: \(\sum_i \left( y_i - \hat{y}_i \right)^2\)
Так у чому ж справа?
Ми зіткнулися з компромісом:
ускладнити модель для кращого навчання моделі
ризикуємо перенавчити модель
Ми можемо побачити ці компроміси в нашому test MSE (але не в training MSE).
Навчальна вибірка і сплайни моделей
Попередній приклад має досить нелінійну залежність.
Q Що відбувається, коли істина фактично лінійна?
Навчальна вибірка і сплайни моделей
Зрозуміло, що ми не хочемо перенавчити модель на навчальній вибірці.
Здається, наша тестова вибірка може допомогти.
Q Як щодо наступної процедури?
навчіть модель \(\hat{\color{#20B2AA}{f}}\) на навчальній вибірці
використовуйте тестові дані, щоб “налаштувати” гнучкість моделі
повторюйте кроки 1–2, поки не знайдемо оптимальний рівень гнучкості
Це прямий шлях до перенавчання моделі.
Цей компроміс, до якого ми постійно повертаємося, має офіційну назву:
компроміс зміщення-дисперсії.
Variance: \(\hat{\color{#20B2AA}{f}}\) змінюється в залежності від навчальних вибірок
Якщо нові навчальні вибірки кардинально змінить \(\hat{\color{#20B2AA}{f}}\), тоді у нас буде багато невизначеності щодо \(\color{#20B2AA}{f}\) (і , загалом, \(\hat{\color{#20B2AA}{f}} \not\approx \color{#20B2AA}{f}\)).
Більш гнучкі моделі зазвичай додають дисперсії до \(\color{#20B2AA}{f}\).
Bias: Помилка, яка виникає через неточне оцінювання \(\color{#20B2AA}{f}\).
Більш гнучкі моделі краще пристосовані для опису складних зв’язків \(\left( \color{#20B2AA}{f} \right)\), зменшуючи зміщення. (Реальне життя рідко буває лінійним.)
Простіші (менш гнучкі) моделі зазвичай збільшують зміщення.
Очікуване значення test MSE можна записати \[ \begin{align} \mathop{E}\left[ \left(\color{#FFA500}{\mathbf{y}}_0 - \hat{\color{#20B2AA}{f}}\!(\color{#6A5ACD}{\mathbf{X}}_0) \right)^2 \right] = \underbrace{\mathop{\text{Var}} \left( \hat{\color{#20B2AA}{f}}\!(\color{#6A5ACD}{\mathbf{X}}_0) \right)}_{(1)} + \underbrace{\left[ \text{Bias}\left( \hat{\color{#20B2AA}{f}}\!(\color{#6A5ACD}{\mathbf{X}}_0) \right) \right]^2}_{(2)} + \underbrace{\mathop{\text{Var}} \left( \varepsilon \right)}_{(3)} \end{align} \]
Q1 Що говорить нам ця формула?
Q2 Як гнучкість моделі враховується у цій формулі?
Q3 Що ця формула говорить про мінімізацію test MSE?
A2 Загалом, гнучкість моделі збільшується (1) і зменшується (2).
A3 Рівень зміни дисперсії та зміщення призведе до оптимальної гнучкості.
Ми часто бачимо U-подібні криві test MSE.
U-подібний test MSE по відношенню до гнучкість моделі
Компроміс зміщення та дисперсії є ключем до розуміння багатьох концепцій машинного навчання.
Функції втрати та ефективність моделі
Перенавчання та гнучкість моделі
Навчання та тестування (і перехресна перевірка)
Поки що ми зосереджувалися на проблемах регресії; як щодо класифікації?
З категоріальними змінними MSE не працює, наприклад,
Очевидно, що нам потрібен інший спосіб визначення ефективності моделі.
Найпоширеніший підхід - це…
Training error rate Частка прогнозів навчання, які ми робимо неправильно. \[ \begin{align} \dfrac{1}{n} \sum_{i=1}^{n} \mathbb{I}\!\left( \color{#FFA500}{y}_i \neq \hat{\color{#FFA500} {y}}_i \right) \end{align} \] де \(\mathbb{I}\!\left( \color{#FFA500}{y}_i \neq \hat{\color{#FFA500}{y}}_i \right)\) є індикаторною функцією, яка дорівнює 1, коли наш прогноз помилковий.
Test error rate Частка прогнозів тесту, які ми помиляємося.
НБК як класифікатор, який класифікує спостереження його найбільш ймовірним групам, враховуючи значення його предикторів, тобто,
Класифікатор Байєса мінімізує test error rate.
\(\mathop{\text{Pr}}\left(\mathbf{y}=j|\mathbf{X}=x_0\right)\) — це ймовірність того, що випадкова величина \(\mathbf{y}\) дорівнює \(j\), при змінній \(\mathbf{X} = x_0\).
Приклад
Тоді класифікатор Байєса каже, що ми повинні передбачити «чорничний кекс».
Межа прийняття рішення Байєса між класами A і B
Тепер вибірка…
… і наша вибірка дає нам оцінку межі прийняття рішення.
А новий зразок дає нам ще одину оцінку межі прийняття рішення.
Один непараметричний спосіб оцінити ці невідомі умовні ймовірності: K-найближчих сусідів (KNN).
K-найближчі сусіди (KNN) просто призначає категорію на основі K найближчих сусідів (їх значення).
Використовуючи KNN для перевірки спостереження \(\color{#6A5ACD}{\mathbf{x_0}}\), ми обчислюємо частку спостережень, клас яких дорівнює \(j\),
\[ \begin{align} \hat{\mathop{\text{Pr}}}\left(\mathbf{y} = j | \mathbf{X} = \color{#6A5ACD}{\mathbf{x_0}}\right) = \dfrac{1}{K} \sum_{i \in \mathcal{N}_0} \mathop{\mathbb{I}}\left( \color{#FFA500}{\mathbf{y}}_i = j \right) \end{align} \]
Ці частки є нашими оцінками для невідомих умовних ймовірностей.
Потім ми призначаємо спостереження \(\color{#6A5ACD}{\mathbf{x_0}}\) класу з найвищою ймовірністю.
KNN у дії
Ліворуч: K=3 оцінка для “x”. Праворуч: Межі рішень KNN.
Вибір K дуже важливий
Межі прийняття рішень: Bayes, K=1 і K=60
.b[KNN error rates], при збільшенні K
species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | year |
---|---|---|---|---|---|---|---|
Adelie | Torgersen | 39.1 | 18.7 | 181 | 3750 | male | 2007 |
Adelie | Torgersen | 39.5 | 17.4 | 186 | 3800 | female | 2007 |
Adelie | Torgersen | 40.3 | 18 | 195 | 3250 | female | 2007 |
Adelie | Torgersen | 36.7 | 19.3 | 193 | 3450 | female | 2007 |
Adelie | Torgersen | 39.3 | 20.6 | 190 | 3650 | male | 2007 |
Adelie | Torgersen | 38.9 | 17.8 | 181 | 3625 | female | 2007 |
Adelie | Torgersen | 39.2 | 19.6 | 195 | 4675 | male | 2007 |
Adelie | Torgersen | 41.1 | 17.6 | 182 | 3200 | female | 2007 |
Adelie | Torgersen | 38.6 | 21.2 | 191 | 3800 | male | 2007 |
Adelie | Torgersen | 34.6 | 21.1 | 198 | 4400 | male | 2007 |
Adelie | Torgersen | 36.6 | 17.8 | 185 | 3700 | female | 2007 |
Adelie | Torgersen | 38.7 | 19 | 195 | 3450 | female | 2007 |
Adelie | Torgersen | 42.5 | 20.7 | 197 | 4500 | male | 2007 |
Adelie | Torgersen | 34.4 | 18.4 | 184 | 3325 | female | 2007 |
Adelie | Torgersen | 46 | 21.5 | 194 | 4200 | male | 2007 |
Adelie | Biscoe | 37.8 | 18.3 | 174 | 3400 | female | 2007 |
Adelie | Biscoe | 37.7 | 18.7 | 180 | 3600 | male | 2007 |
Adelie | Biscoe | 35.9 | 19.2 | 189 | 3800 | female | 2007 |
Adelie | Biscoe | 38.2 | 18.1 | 185 | 3950 | male | 2007 |
Adelie | Biscoe | 38.8 | 17.2 | 180 | 3800 | male | 2007 |
Adelie | Biscoe | 35.3 | 18.9 | 187 | 3800 | female | 2007 |
Adelie | Biscoe | 40.6 | 18.6 | 183 | 3550 | male | 2007 |
Adelie | Biscoe | 40.5 | 17.9 | 187 | 3200 | female | 2007 |
Adelie | Biscoe | 37.9 | 18.6 | 172 | 3150 | female | 2007 |
Adelie | Biscoe | 40.5 | 18.9 | 180 | 3950 | male | 2007 |
Adelie | Dream | 39.5 | 16.7 | 178 | 3250 | female | 2007 |
Adelie | Dream | 37.2 | 18.1 | 178 | 3900 | male | 2007 |
Adelie | Dream | 39.5 | 17.8 | 188 | 3300 | female | 2007 |
Adelie | Dream | 40.9 | 18.9 | 184 | 3900 | male | 2007 |
Adelie | Dream | 36.4 | 17 | 195 | 3325 | female | 2007 |
Adelie | Dream | 39.2 | 21.1 | 196 | 4150 | male | 2007 |
Adelie | Dream | 38.8 | 20 | 190 | 3950 | male | 2007 |
Adelie | Dream | 42.2 | 18.5 | 180 | 3550 | female | 2007 |
Adelie | Dream | 37.6 | 19.3 | 181 | 3300 | female | 2007 |
Adelie | Dream | 39.8 | 19.1 | 184 | 4650 | male | 2007 |
Adelie | Dream | 36.5 | 18 | 182 | 3150 | female | 2007 |
Adelie | Dream | 40.8 | 18.4 | 195 | 3900 | male | 2007 |
Adelie | Dream | 36 | 18.5 | 186 | 3100 | female | 2007 |
Adelie | Dream | 44.1 | 19.7 | 196 | 4400 | male | 2007 |
Adelie | Dream | 37 | 16.9 | 185 | 3000 | female | 2007 |
Adelie | Dream | 39.6 | 18.8 | 190 | 4600 | male | 2007 |
Adelie | Dream | 41.1 | 19 | 182 | 3425 | male | 2007 |
Adelie | Dream | 36 | 17.9 | 190 | 3450 | female | 2007 |
Adelie | Dream | 42.3 | 21.2 | 191 | 4150 | male | 2007 |
Adelie | Biscoe | 39.6 | 17.7 | 186 | 3500 | female | 2008 |
Adelie | Biscoe | 40.1 | 18.9 | 188 | 4300 | male | 2008 |
Adelie | Biscoe | 35 | 17.9 | 190 | 3450 | female | 2008 |
Adelie | Biscoe | 42 | 19.5 | 200 | 4050 | male | 2008 |
Adelie | Biscoe | 34.5 | 18.1 | 187 | 2900 | female | 2008 |
Adelie | Biscoe | 41.4 | 18.6 | 191 | 3700 | male | 2008 |
Adelie | Biscoe | 39 | 17.5 | 186 | 3550 | female | 2008 |
Adelie | Biscoe | 40.6 | 18.8 | 193 | 3800 | male | 2008 |
Adelie | Biscoe | 36.5 | 16.6 | 181 | 2850 | female | 2008 |
Adelie | Biscoe | 37.6 | 19.1 | 194 | 3750 | male | 2008 |
Adelie | Biscoe | 35.7 | 16.9 | 185 | 3150 | female | 2008 |
Adelie | Biscoe | 41.3 | 21.1 | 195 | 4400 | male | 2008 |
Adelie | Biscoe | 37.6 | 17 | 185 | 3600 | female | 2008 |
Adelie | Biscoe | 41.1 | 18.2 | 192 | 4050 | male | 2008 |
Adelie | Biscoe | 36.4 | 17.1 | 184 | 2850 | female | 2008 |
Adelie | Biscoe | 41.6 | 18 | 192 | 3950 | male | 2008 |
Adelie | Biscoe | 35.5 | 16.2 | 195 | 3350 | female | 2008 |
Adelie | Biscoe | 41.1 | 19.1 | 188 | 4100 | male | 2008 |
Adelie | Torgersen | 35.9 | 16.6 | 190 | 3050 | female | 2008 |
Adelie | Torgersen | 41.8 | 19.4 | 198 | 4450 | male | 2008 |
Adelie | Torgersen | 33.5 | 19 | 190 | 3600 | female | 2008 |
Adelie | Torgersen | 39.7 | 18.4 | 190 | 3900 | male | 2008 |
Adelie | Torgersen | 39.6 | 17.2 | 196 | 3550 | female | 2008 |
Adelie | Torgersen | 45.8 | 18.9 | 197 | 4150 | male | 2008 |
Adelie | Torgersen | 35.5 | 17.5 | 190 | 3700 | female | 2008 |
Adelie | Torgersen | 42.8 | 18.5 | 195 | 4250 | male | 2008 |
Adelie | Torgersen | 40.9 | 16.8 | 191 | 3700 | female | 2008 |
Adelie | Torgersen | 37.2 | 19.4 | 184 | 3900 | male | 2008 |
Adelie | Torgersen | 36.2 | 16.1 | 187 | 3550 | female | 2008 |
Adelie | Torgersen | 42.1 | 19.1 | 195 | 4000 | male | 2008 |
Adelie | Torgersen | 34.6 | 17.2 | 189 | 3200 | female | 2008 |
Adelie | Torgersen | 42.9 | 17.6 | 196 | 4700 | male | 2008 |
Adelie | Torgersen | 36.7 | 18.8 | 187 | 3800 | female | 2008 |
Adelie | Torgersen | 35.1 | 19.4 | 193 | 4200 | male | 2008 |
Adelie | Dream | 37.3 | 17.8 | 191 | 3350 | female | 2008 |
Adelie | Dream | 41.3 | 20.3 | 194 | 3550 | male | 2008 |
Adelie | Dream | 36.3 | 19.5 | 190 | 3800 | male | 2008 |
Adelie | Dream | 36.9 | 18.6 | 189 | 3500 | female | 2008 |
Adelie | Dream | 38.3 | 19.2 | 189 | 3950 | male | 2008 |
Adelie | Dream | 38.9 | 18.8 | 190 | 3600 | female | 2008 |
Adelie | Dream | 35.7 | 18 | 202 | 3550 | female | 2008 |
Adelie | Dream | 41.1 | 18.1 | 205 | 4300 | male | 2008 |
Adelie | Dream | 34 | 17.1 | 185 | 3400 | female | 2008 |
Adelie | Dream | 39.6 | 18.1 | 186 | 4450 | male | 2008 |
Adelie | Dream | 36.2 | 17.3 | 187 | 3300 | female | 2008 |
Adelie | Dream | 40.8 | 18.9 | 208 | 4300 | male | 2008 |
Adelie | Dream | 38.1 | 18.6 | 190 | 3700 | female | 2008 |
Adelie | Dream | 40.3 | 18.5 | 196 | 4350 | male | 2008 |
Adelie | Dream | 33.1 | 16.1 | 178 | 2900 | female | 2008 |
Adelie | Dream | 43.2 | 18.5 | 192 | 4100 | male | 2008 |
Adelie | Biscoe | 35 | 17.9 | 192 | 3725 | female | 2009 |
Adelie | Biscoe | 41 | 20 | 203 | 4725 | male | 2009 |
Adelie | Biscoe | 37.7 | 16 | 183 | 3075 | female | 2009 |
Adelie | Biscoe | 37.8 | 20 | 190 | 4250 | male | 2009 |
Adelie | Biscoe | 37.9 | 18.6 | 193 | 2925 | female | 2009 |
Adelie | Biscoe | 39.7 | 18.9 | 184 | 3550 | male | 2009 |
Adelie | Biscoe | 38.6 | 17.2 | 199 | 3750 | female | 2009 |
Adelie | Biscoe | 38.2 | 20 | 190 | 3900 | male | 2009 |
Adelie | Biscoe | 38.1 | 17 | 181 | 3175 | female | 2009 |
Adelie | Biscoe | 43.2 | 19 | 197 | 4775 | male | 2009 |
Adelie | Biscoe | 38.1 | 16.5 | 198 | 3825 | female | 2009 |
Adelie | Biscoe | 45.6 | 20.3 | 191 | 4600 | male | 2009 |
Adelie | Biscoe | 39.7 | 17.7 | 193 | 3200 | female | 2009 |
Adelie | Biscoe | 42.2 | 19.5 | 197 | 4275 | male | 2009 |
Adelie | Biscoe | 39.6 | 20.7 | 191 | 3900 | female | 2009 |
Adelie | Biscoe | 42.7 | 18.3 | 196 | 4075 | male | 2009 |
Adelie | Torgersen | 38.6 | 17 | 188 | 2900 | female | 2009 |
Adelie | Torgersen | 37.3 | 20.5 | 199 | 3775 | male | 2009 |
Adelie | Torgersen | 35.7 | 17 | 189 | 3350 | female | 2009 |
Adelie | Torgersen | 41.1 | 18.6 | 189 | 3325 | male | 2009 |
Adelie | Torgersen | 36.2 | 17.2 | 187 | 3150 | female | 2009 |
Adelie | Torgersen | 37.7 | 19.8 | 198 | 3500 | male | 2009 |
Adelie | Torgersen | 40.2 | 17 | 176 | 3450 | female | 2009 |
Adelie | Torgersen | 41.4 | 18.5 | 202 | 3875 | male | 2009 |
Adelie | Torgersen | 35.2 | 15.9 | 186 | 3050 | female | 2009 |
Adelie | Torgersen | 40.6 | 19 | 199 | 4000 | male | 2009 |
Adelie | Torgersen | 38.8 | 17.6 | 191 | 3275 | female | 2009 |
Adelie | Torgersen | 41.5 | 18.3 | 195 | 4300 | male | 2009 |
Adelie | Torgersen | 39 | 17.1 | 191 | 3050 | female | 2009 |
Adelie | Torgersen | 44.1 | 18 | 210 | 4000 | male | 2009 |
Adelie | Torgersen | 38.5 | 17.9 | 190 | 3325 | female | 2009 |
Adelie | Torgersen | 43.1 | 19.2 | 197 | 3500 | male | 2009 |
Adelie | Dream | 36.8 | 18.5 | 193 | 3500 | female | 2009 |
Adelie | Dream | 37.5 | 18.5 | 199 | 4475 | male | 2009 |
Adelie | Dream | 38.1 | 17.6 | 187 | 3425 | female | 2009 |
Adelie | Dream | 41.1 | 17.5 | 190 | 3900 | male | 2009 |
Adelie | Dream | 35.6 | 17.5 | 191 | 3175 | female | 2009 |
Adelie | Dream | 40.2 | 20.1 | 200 | 3975 | male | 2009 |
Adelie | Dream | 37 | 16.5 | 185 | 3400 | female | 2009 |
Adelie | Dream | 39.7 | 17.9 | 193 | 4250 | male | 2009 |
Adelie | Dream | 40.2 | 17.1 | 193 | 3400 | female | 2009 |
Adelie | Dream | 40.6 | 17.2 | 187 | 3475 | male | 2009 |
Adelie | Dream | 32.1 | 15.5 | 188 | 3050 | female | 2009 |
Adelie | Dream | 40.7 | 17 | 190 | 3725 | male | 2009 |
Adelie | Dream | 37.3 | 16.8 | 192 | 3000 | female | 2009 |
Adelie | Dream | 39 | 18.7 | 185 | 3650 | male | 2009 |
Adelie | Dream | 39.2 | 18.6 | 190 | 4250 | male | 2009 |
Adelie | Dream | 36.6 | 18.4 | 184 | 3475 | female | 2009 |
Adelie | Dream | 36 | 17.8 | 195 | 3450 | female | 2009 |
Adelie | Dream | 37.8 | 18.1 | 193 | 3750 | male | 2009 |
Adelie | Dream | 36 | 17.1 | 187 | 3700 | female | 2009 |
Adelie | Dream | 41.5 | 18.5 | 201 | 4000 | male | 2009 |
Gentoo | Biscoe | 46.1 | 13.2 | 211 | 4500 | female | 2007 |
Gentoo | Biscoe | 50 | 16.3 | 230 | 5700 | male | 2007 |
Gentoo | Biscoe | 48.7 | 14.1 | 210 | 4450 | female | 2007 |
Gentoo | Biscoe | 50 | 15.2 | 218 | 5700 | male | 2007 |
Gentoo | Biscoe | 47.6 | 14.5 | 215 | 5400 | male | 2007 |
Gentoo | Biscoe | 46.5 | 13.5 | 210 | 4550 | female | 2007 |
Gentoo | Biscoe | 45.4 | 14.6 | 211 | 4800 | female | 2007 |
Gentoo | Biscoe | 46.7 | 15.3 | 219 | 5200 | male | 2007 |
Gentoo | Biscoe | 43.3 | 13.4 | 209 | 4400 | female | 2007 |
Gentoo | Biscoe | 46.8 | 15.4 | 215 | 5150 | male | 2007 |
Gentoo | Biscoe | 40.9 | 13.7 | 214 | 4650 | female | 2007 |
Gentoo | Biscoe | 49 | 16.1 | 216 | 5550 | male | 2007 |
Gentoo | Biscoe | 45.5 | 13.7 | 214 | 4650 | female | 2007 |
Gentoo | Biscoe | 48.4 | 14.6 | 213 | 5850 | male | 2007 |
Gentoo | Biscoe | 45.8 | 14.6 | 210 | 4200 | female | 2007 |
Gentoo | Biscoe | 49.3 | 15.7 | 217 | 5850 | male | 2007 |
Gentoo | Biscoe | 42 | 13.5 | 210 | 4150 | female | 2007 |
Gentoo | Biscoe | 49.2 | 15.2 | 221 | 6300 | male | 2007 |
Gentoo | Biscoe | 46.2 | 14.5 | 209 | 4800 | female | 2007 |
Gentoo | Biscoe | 48.7 | 15.1 | 222 | 5350 | male | 2007 |
Gentoo | Biscoe | 50.2 | 14.3 | 218 | 5700 | male | 2007 |
Gentoo | Biscoe | 45.1 | 14.5 | 215 | 5000 | female | 2007 |
Gentoo | Biscoe | 46.5 | 14.5 | 213 | 4400 | female | 2007 |
Gentoo | Biscoe | 46.3 | 15.8 | 215 | 5050 | male | 2007 |
Gentoo | Biscoe | 42.9 | 13.1 | 215 | 5000 | female | 2007 |
Gentoo | Biscoe | 46.1 | 15.1 | 215 | 5100 | male | 2007 |
Gentoo | Biscoe | 47.8 | 15 | 215 | 5650 | male | 2007 |
Gentoo | Biscoe | 48.2 | 14.3 | 210 | 4600 | female | 2007 |
Gentoo | Biscoe | 50 | 15.3 | 220 | 5550 | male | 2007 |
Gentoo | Biscoe | 47.3 | 15.3 | 222 | 5250 | male | 2007 |
Gentoo | Biscoe | 42.8 | 14.2 | 209 | 4700 | female | 2007 |
Gentoo | Biscoe | 45.1 | 14.5 | 207 | 5050 | female | 2007 |
Gentoo | Biscoe | 59.6 | 17 | 230 | 6050 | male | 2007 |
Gentoo | Biscoe | 49.1 | 14.8 | 220 | 5150 | female | 2008 |
Gentoo | Biscoe | 48.4 | 16.3 | 220 | 5400 | male | 2008 |
Gentoo | Biscoe | 42.6 | 13.7 | 213 | 4950 | female | 2008 |
Gentoo | Biscoe | 44.4 | 17.3 | 219 | 5250 | male | 2008 |
Gentoo | Biscoe | 44 | 13.6 | 208 | 4350 | female | 2008 |
Gentoo | Biscoe | 48.7 | 15.7 | 208 | 5350 | male | 2008 |
Gentoo | Biscoe | 42.7 | 13.7 | 208 | 3950 | female | 2008 |
Gentoo | Biscoe | 49.6 | 16 | 225 | 5700 | male | 2008 |
Gentoo | Biscoe | 45.3 | 13.7 | 210 | 4300 | female | 2008 |
Gentoo | Biscoe | 49.6 | 15 | 216 | 4750 | male | 2008 |
Gentoo | Biscoe | 50.5 | 15.9 | 222 | 5550 | male | 2008 |
Gentoo | Biscoe | 43.6 | 13.9 | 217 | 4900 | female | 2008 |
Gentoo | Biscoe | 45.5 | 13.9 | 210 | 4200 | female | 2008 |
Gentoo | Biscoe | 50.5 | 15.9 | 225 | 5400 | male | 2008 |
Gentoo | Biscoe | 44.9 | 13.3 | 213 | 5100 | female | 2008 |
Gentoo | Biscoe | 45.2 | 15.8 | 215 | 5300 | male | 2008 |
Gentoo | Biscoe | 46.6 | 14.2 | 210 | 4850 | female | 2008 |
Gentoo | Biscoe | 48.5 | 14.1 | 220 | 5300 | male | 2008 |
Gentoo | Biscoe | 45.1 | 14.4 | 210 | 4400 | female | 2008 |
Gentoo | Biscoe | 50.1 | 15 | 225 | 5000 | male | 2008 |
Gentoo | Biscoe | 46.5 | 14.4 | 217 | 4900 | female | 2008 |
Gentoo | Biscoe | 45 | 15.4 | 220 | 5050 | male | 2008 |
Gentoo | Biscoe | 43.8 | 13.9 | 208 | 4300 | female | 2008 |
Gentoo | Biscoe | 45.5 | 15 | 220 | 5000 | male | 2008 |
Gentoo | Biscoe | 43.2 | 14.5 | 208 | 4450 | female | 2008 |
Gentoo | Biscoe | 50.4 | 15.3 | 224 | 5550 | male | 2008 |
Gentoo | Biscoe | 45.3 | 13.8 | 208 | 4200 | female | 2008 |
Gentoo | Biscoe | 46.2 | 14.9 | 221 | 5300 | male | 2008 |
Gentoo | Biscoe | 45.7 | 13.9 | 214 | 4400 | female | 2008 |
Gentoo | Biscoe | 54.3 | 15.7 | 231 | 5650 | male | 2008 |
Gentoo | Biscoe | 45.8 | 14.2 | 219 | 4700 | female | 2008 |
Gentoo | Biscoe | 49.8 | 16.8 | 230 | 5700 | male | 2008 |
Gentoo | Biscoe | 49.5 | 16.2 | 229 | 5800 | male | 2008 |
Gentoo | Biscoe | 43.5 | 14.2 | 220 | 4700 | female | 2008 |
Gentoo | Biscoe | 50.7 | 15 | 223 | 5550 | male | 2008 |
Gentoo | Biscoe | 47.7 | 15 | 216 | 4750 | female | 2008 |
Gentoo | Biscoe | 46.4 | 15.6 | 221 | 5000 | male | 2008 |
Gentoo | Biscoe | 48.2 | 15.6 | 221 | 5100 | male | 2008 |
Gentoo | Biscoe | 46.5 | 14.8 | 217 | 5200 | female | 2008 |
Gentoo | Biscoe | 46.4 | 15 | 216 | 4700 | female | 2008 |
Gentoo | Biscoe | 48.6 | 16 | 230 | 5800 | male | 2008 |
Gentoo | Biscoe | 47.5 | 14.2 | 209 | 4600 | female | 2008 |
Gentoo | Biscoe | 51.1 | 16.3 | 220 | 6000 | male | 2008 |
Gentoo | Biscoe | 45.2 | 13.8 | 215 | 4750 | female | 2008 |
Gentoo | Biscoe | 45.2 | 16.4 | 223 | 5950 | male | 2008 |
Gentoo | Biscoe | 49.1 | 14.5 | 212 | 4625 | female | 2009 |
Gentoo | Biscoe | 52.5 | 15.6 | 221 | 5450 | male | 2009 |
Gentoo | Biscoe | 47.4 | 14.6 | 212 | 4725 | female | 2009 |
Gentoo | Biscoe | 50 | 15.9 | 224 | 5350 | male | 2009 |
Gentoo | Biscoe | 44.9 | 13.8 | 212 | 4750 | female | 2009 |
Gentoo | Biscoe | 50.8 | 17.3 | 228 | 5600 | male | 2009 |
Gentoo | Biscoe | 43.4 | 14.4 | 218 | 4600 | female | 2009 |
Gentoo | Biscoe | 51.3 | 14.2 | 218 | 5300 | male | 2009 |
Gentoo | Biscoe | 47.5 | 14 | 212 | 4875 | female | 2009 |
Gentoo | Biscoe | 52.1 | 17 | 230 | 5550 | male | 2009 |
Gentoo | Biscoe | 47.5 | 15 | 218 | 4950 | female | 2009 |
Gentoo | Biscoe | 52.2 | 17.1 | 228 | 5400 | male | 2009 |
Gentoo | Biscoe | 45.5 | 14.5 | 212 | 4750 | female | 2009 |
Gentoo | Biscoe | 49.5 | 16.1 | 224 | 5650 | male | 2009 |
Gentoo | Biscoe | 44.5 | 14.7 | 214 | 4850 | female | 2009 |
Gentoo | Biscoe | 50.8 | 15.7 | 226 | 5200 | male | 2009 |
Gentoo | Biscoe | 49.4 | 15.8 | 216 | 4925 | male | 2009 |
Gentoo | Biscoe | 46.9 | 14.6 | 222 | 4875 | female | 2009 |
Gentoo | Biscoe | 48.4 | 14.4 | 203 | 4625 | female | 2009 |
Gentoo | Biscoe | 51.1 | 16.5 | 225 | 5250 | male | 2009 |
Gentoo | Biscoe | 48.5 | 15 | 219 | 4850 | female | 2009 |
Gentoo | Biscoe | 55.9 | 17 | 228 | 5600 | male | 2009 |
Gentoo | Biscoe | 47.2 | 15.5 | 215 | 4975 | female | 2009 |
Gentoo | Biscoe | 49.1 | 15 | 228 | 5500 | male | 2009 |
Gentoo | Biscoe | 46.8 | 16.1 | 215 | 5500 | male | 2009 |
Gentoo | Biscoe | 41.7 | 14.7 | 210 | 4700 | female | 2009 |
Gentoo | Biscoe | 53.4 | 15.8 | 219 | 5500 | male | 2009 |
Gentoo | Biscoe | 43.3 | 14 | 208 | 4575 | female | 2009 |
Gentoo | Biscoe | 48.1 | 15.1 | 209 | 5500 | male | 2009 |
Gentoo | Biscoe | 50.5 | 15.2 | 216 | 5000 | female | 2009 |
Gentoo | Biscoe | 49.8 | 15.9 | 229 | 5950 | male | 2009 |
Gentoo | Biscoe | 43.5 | 15.2 | 213 | 4650 | female | 2009 |
Gentoo | Biscoe | 51.5 | 16.3 | 230 | 5500 | male | 2009 |
Gentoo | Biscoe | 46.2 | 14.1 | 217 | 4375 | female | 2009 |
Gentoo | Biscoe | 55.1 | 16 | 230 | 5850 | male | 2009 |
Gentoo | Biscoe | 48.8 | 16.2 | 222 | 6000 | male | 2009 |
Gentoo | Biscoe | 47.2 | 13.7 | 214 | 4925 | female | 2009 |
Gentoo | Biscoe | 46.8 | 14.3 | 215 | 4850 | female | 2009 |
Gentoo | Biscoe | 50.4 | 15.7 | 222 | 5750 | male | 2009 |
Gentoo | Biscoe | 45.2 | 14.8 | 212 | 5200 | female | 2009 |
Gentoo | Biscoe | 49.9 | 16.1 | 213 | 5400 | male | 2009 |
Chinstrap | Dream | 46.5 | 17.9 | 192 | 3500 | female | 2007 |
Chinstrap | Dream | 50 | 19.5 | 196 | 3900 | male | 2007 |
Chinstrap | Dream | 51.3 | 19.2 | 193 | 3650 | male | 2007 |
Chinstrap | Dream | 45.4 | 18.7 | 188 | 3525 | female | 2007 |
Chinstrap | Dream | 52.7 | 19.8 | 197 | 3725 | male | 2007 |
Chinstrap | Dream | 45.2 | 17.8 | 198 | 3950 | female | 2007 |
Chinstrap | Dream | 46.1 | 18.2 | 178 | 3250 | female | 2007 |
Chinstrap | Dream | 51.3 | 18.2 | 197 | 3750 | male | 2007 |
Chinstrap | Dream | 46 | 18.9 | 195 | 4150 | female | 2007 |
Chinstrap | Dream | 51.3 | 19.9 | 198 | 3700 | male | 2007 |
Chinstrap | Dream | 46.6 | 17.8 | 193 | 3800 | female | 2007 |
Chinstrap | Dream | 51.7 | 20.3 | 194 | 3775 | male | 2007 |
Chinstrap | Dream | 47 | 17.3 | 185 | 3700 | female | 2007 |
Chinstrap | Dream | 52 | 18.1 | 201 | 4050 | male | 2007 |
Chinstrap | Dream | 45.9 | 17.1 | 190 | 3575 | female | 2007 |
Chinstrap | Dream | 50.5 | 19.6 | 201 | 4050 | male | 2007 |
Chinstrap | Dream | 50.3 | 20 | 197 | 3300 | male | 2007 |
Chinstrap | Dream | 58 | 17.8 | 181 | 3700 | female | 2007 |
Chinstrap | Dream | 46.4 | 18.6 | 190 | 3450 | female | 2007 |
Chinstrap | Dream | 49.2 | 18.2 | 195 | 4400 | male | 2007 |
Chinstrap | Dream | 42.4 | 17.3 | 181 | 3600 | female | 2007 |
Chinstrap | Dream | 48.5 | 17.5 | 191 | 3400 | male | 2007 |
Chinstrap | Dream | 43.2 | 16.6 | 187 | 2900 | female | 2007 |
Chinstrap | Dream | 50.6 | 19.4 | 193 | 3800 | male | 2007 |
Chinstrap | Dream | 46.7 | 17.9 | 195 | 3300 | female | 2007 |
Chinstrap | Dream | 52 | 19 | 197 | 4150 | male | 2007 |
Chinstrap | Dream | 50.5 | 18.4 | 200 | 3400 | female | 2008 |
Chinstrap | Dream | 49.5 | 19 | 200 | 3800 | male | 2008 |
Chinstrap | Dream | 46.4 | 17.8 | 191 | 3700 | female | 2008 |
Chinstrap | Dream | 52.8 | 20 | 205 | 4550 | male | 2008 |
Chinstrap | Dream | 40.9 | 16.6 | 187 | 3200 | female | 2008 |
Chinstrap | Dream | 54.2 | 20.8 | 201 | 4300 | male | 2008 |
Chinstrap | Dream | 42.5 | 16.7 | 187 | 3350 | female | 2008 |
Chinstrap | Dream | 51 | 18.8 | 203 | 4100 | male | 2008 |
Chinstrap | Dream | 49.7 | 18.6 | 195 | 3600 | male | 2008 |
Chinstrap | Dream | 47.5 | 16.8 | 199 | 3900 | female | 2008 |
Chinstrap | Dream | 47.6 | 18.3 | 195 | 3850 | female | 2008 |
Chinstrap | Dream | 52 | 20.7 | 210 | 4800 | male | 2008 |
Chinstrap | Dream | 46.9 | 16.6 | 192 | 2700 | female | 2008 |
Chinstrap | Dream | 53.5 | 19.9 | 205 | 4500 | male | 2008 |
Chinstrap | Dream | 49 | 19.5 | 210 | 3950 | male | 2008 |
Chinstrap | Dream | 46.2 | 17.5 | 187 | 3650 | female | 2008 |
Chinstrap | Dream | 50.9 | 19.1 | 196 | 3550 | male | 2008 |
Chinstrap | Dream | 45.5 | 17 | 196 | 3500 | female | 2008 |
Chinstrap | Dream | 50.9 | 17.9 | 196 | 3675 | female | 2009 |
Chinstrap | Dream | 50.8 | 18.5 | 201 | 4450 | male | 2009 |
Chinstrap | Dream | 50.1 | 17.9 | 190 | 3400 | female | 2009 |
Chinstrap | Dream | 49 | 19.6 | 212 | 4300 | male | 2009 |
Chinstrap | Dream | 51.5 | 18.7 | 187 | 3250 | male | 2009 |
Chinstrap | Dream | 49.8 | 17.3 | 198 | 3675 | female | 2009 |
Chinstrap | Dream | 48.1 | 16.4 | 199 | 3325 | female | 2009 |
Chinstrap | Dream | 51.4 | 19 | 201 | 3950 | male | 2009 |
Chinstrap | Dream | 45.7 | 17.3 | 193 | 3600 | female | 2009 |
Chinstrap | Dream | 50.7 | 19.7 | 203 | 4050 | male | 2009 |
Chinstrap | Dream | 42.5 | 17.3 | 187 | 3350 | female | 2009 |
Chinstrap | Dream | 52.2 | 18.8 | 197 | 3450 | male | 2009 |
Chinstrap | Dream | 45.2 | 16.6 | 191 | 3250 | female | 2009 |
Chinstrap | Dream | 49.3 | 19.9 | 203 | 4050 | male | 2009 |
Chinstrap | Dream | 50.2 | 18.8 | 202 | 3800 | male | 2009 |
Chinstrap | Dream | 45.6 | 19.4 | 194 | 3525 | female | 2009 |
Chinstrap | Dream | 51.9 | 19.5 | 206 | 3950 | male | 2009 |
Chinstrap | Dream | 46.8 | 16.5 | 189 | 3650 | female | 2009 |
Chinstrap | Dream | 45.7 | 17 | 195 | 3650 | female | 2009 |
Chinstrap | Dream | 55.8 | 19.8 | 207 | 4000 | male | 2009 |
Chinstrap | Dream | 43.5 | 18.1 | 202 | 3400 | female | 2009 |
Chinstrap | Dream | 49.6 | 18.2 | 193 | 3775 | male | 2009 |
Chinstrap | Dream | 50.8 | 19 | 210 | 4100 | male | 2009 |
Chinstrap | Dream | 50.2 | 18.7 | 198 | 3775 | female | 2009 |
<Training/Testing/Total>
<266/67/333>
Linear Regression Model Specification (regression)
Computational engine: lm
parsnip model object
Call:
stats::lm(formula = body_mass_g ~ flipper_length_mm, data = data)
Coefficients:
(Intercept) flipper_length_mm
-5888.93 50.16
Call:
stats::lm(formula = body_mass_g ~ flipper_length_mm, data = data)
Coefficients:
(Intercept) flipper_length_mm
-5888.93 50.16
Call:
stats::lm(formula = body_mass_g ~ flipper_length_mm, data = data)
Residuals:
Min 1Q Median 3Q Max
-1042.47 -246.76 -7.01 241.80 1102.79
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5888.930 338.487 -17.40 <2e-16 ***
flipper_length_mm 50.164 1.682 29.82 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 382.1 on 264 degrees of freedom
Multiple R-squared: 0.771, Adjusted R-squared: 0.7702
F-statistic: 888.9 on 1 and 264 DF, p-value: < 2.2e-16
term | estimate | std.error | statistic | p.value |
---|---|---|---|---|
(Intercept) | -5.89e+03 | 338 | -17.4 | 1.09e-45 |
flipper_length_mm | 50.2 | 1.68 | 29.8 | 1.74e-86 |
.metric | .estimator | .estimate |
---|---|---|
rmse | standard | 436 |
.pred |
---|
3.89e+03 |
3.79e+03 |
3.69e+03 |
3.39e+03 |
3.99e+03 |
3.84e+03 |
body_mass_g | .pred |
---|---|
4625 | 4.29e+03 |
3300 | 3.99e+03 |
4150 | 3.69e+03 |
5400 | 5.4e+03 |
3900 | 3.34e+03 |
2900 | 3.49e+03 |
3400 | 3.39e+03 |
3900 | 3.34e+03 |
5300 | 5.2e+03 |
3500 | 3.44e+03 |
6000 | 5.25e+03 |
5950 | 5.3e+03 |
3650 | 3.59e+03 |
3575 | 3.64e+03 |
3050 | 3.54e+03 |
4300 | 4.75e+03 |
5350 | 5.25e+03 |
4400 | 4.8e+03 |
4875 | 5.25e+03 |
3600 | 3.19e+03 |
4550 | 4.39e+03 |
3725 | 3.74e+03 |
3650 | 3.89e+03 |
3600 | 3.89e+03 |
5250 | 5.25e+03 |
3325 | 3.89e+03 |
3550 | 3.14e+03 |
4250 | 3.89e+03 |
4850 | 4.65e+03 |
4400 | 4.65e+03 |
3300 | 3.89e+03 |
3000 | 3.39e+03 |
4550 | 4.65e+03 |
3700 | 3.69e+03 |
5850 | 4.8e+03 |
4300 | 3.54e+03 |
4075 | 3.94e+03 |
5100 | 4.9e+03 |
5350 | 5.35e+03 |
3700 | 3.49e+03 |
4100 | 4.29e+03 |
3250 | 3.69e+03 |
4925 | 4.95e+03 |
5200 | 5e+03 |
3325 | 3.59e+03 |
3450 | 3.64e+03 |
5000 | 4.9e+03 |
3275 | 3.69e+03 |
3200 | 3.79e+03 |
4300 | 4.65e+03 |
4400 | 4.85e+03 |
4300 | 3.89e+03 |
4450 | 4.04e+03 |
5300 | 4.9e+03 |
5800 | 5.6e+03 |
3800 | 3.14e+03 |
5400 | 5.15e+03 |
5500 | 5.1e+03 |
3550 | 3.49e+03 |
3950 | 4.65e+03 |
3800 | 4.14e+03 |
3950 | 4.19e+03 |
3800 | 3.64e+03 |
5500 | 4.6e+03 |
3600 | 3.79e+03 |
5050 | 5.15e+03 |
3600 | 3.39e+03 |
3800 | 3.59e+03 |
4400 | 3.89e+03 |
3050 | 3.44e+03 |
5300 | 5.05e+03 |
3550 | 3.94e+03 |
3900 | 4.09e+03 |
5100 | 4.8e+03 |
4200 | 4.65e+03 |
4750 | 4.95e+03 |
3450 | 3.89e+03 |
3825 | 4.04e+03 |
5300 | 5.15e+03 |
5650 | 5.7e+03 |
2850 | 3.19e+03 |
3650 | 3.39e+03 |
3950 | 4.04e+03 |
3900 | 3.64e+03 |
4350 | 4.55e+03 |
3350 | 3.69e+03 |
3700 | 4.04e+03 |
4700 | 5.1e+03 |
3950 | 3.64e+03 |
4925 | 4.85e+03 |
5050 | 4.9e+03 |
5600 | 5.55e+03 |
3500 | 3.99e+03 |
4500 | 4.39e+03 |
5000 | 4.9e+03 |
3550 | 3.34e+03 |
3675 | 3.94e+03 |
3700 | 3.69e+03 |
3650 | 3.64e+03 |
5500 | 5.65e+03 |
5650 | 5.35e+03 |
3550 | 3.84e+03 |
4950 | 4.8e+03 |
4150 | 3.94e+03 |
3725 | 3.64e+03 |
3150 | 2.74e+03 |
4150 | 3.89e+03 |
4100 | 4.65e+03 |
3700 | 3.64e+03 |
3900 | 3.69e+03 |
4150 | 3.99e+03 |
3300 | 3.54e+03 |
3900 | 3.64e+03 |
4850 | 4.9e+03 |
3400 | 3.79e+03 |
3100 | 3.44e+03 |
3700 | 3.64e+03 |
5200 | 5.1e+03 |
3475 | 3.34e+03 |
4150 | 4.65e+03 |
4650 | 4.8e+03 |
5150 | 5.15e+03 |
4750 | 4.95e+03 |
3950 | 3.14e+03 |
3400 | 2.84e+03 |
3500 | 4.04e+03 |
4600 | 4.6e+03 |
4950 | 5.05e+03 |
3450 | 3.89e+03 |
3350 | 3.49e+03 |
3800 | 4.24e+03 |
5100 | 5.2e+03 |
6000 | 5.15e+03 |
2850 | 3.34e+03 |
3325 | 3.34e+03 |
3350 | 3.89e+03 |
4750 | 4.75e+03 |
3175 | 3.69e+03 |
3750 | 3.99e+03 |
3550 | 4.24e+03 |
4200 | 4.65e+03 |
6300 | 5.2e+03 |
3000 | 3.74e+03 |
3200 | 3.24e+03 |
3325 | 4.09e+03 |
3150 | 3.39e+03 |
3500 | 3.59e+03 |
5700 | 5.4e+03 |
4400 | 4.6e+03 |
3700 | 3.69e+03 |
3425 | 3.24e+03 |
4600 | 3.64e+03 |
3200 | 3.59e+03 |
4300 | 4.19e+03 |
4050 | 4.19e+03 |
3550 | 3.29e+03 |
4050 | 4.29e+03 |
5550 | 5.35e+03 |
5150 | 4.9e+03 |
4600 | 4.65e+03 |
5000 | 5.15e+03 |
4650 | 4.85e+03 |
3900 | 3.94e+03 |
3400 | 4.24e+03 |
2925 | 3.79e+03 |
2700 | 3.74e+03 |
3800 | 3.79e+03 |
4850 | 5.1e+03 |
4350 | 3.94e+03 |
3950 | 3.59e+03 |
3525 | 3.54e+03 |
5700 | 5.05e+03 |
3950 | 4.44e+03 |
4400 | 4.04e+03 |
5200 | 4.75e+03 |
3350 | 3.59e+03 |
4600 | 3.69e+03 |
3550 | 3.44e+03 |
4700 | 4.65e+03 |
3325 | 3.64e+03 |
3750 | 3.79e+03 |
5500 | 4.9e+03 |
3975 | 4.14e+03 |
5500 | 5.55e+03 |
3800 | 3.44e+03 |
4700 | 4.6e+03 |
4700 | 4.95e+03 |
3800 | 3.79e+03 |
3775 | 4.09e+03 |
4250 | 3.79e+03 |
3700 | 3.19e+03 |
5600 | 5.55e+03 |
4050 | 4.14e+03 |
3250 | 3.04e+03 |
4575 | 4.55e+03 |
3650 | 3.49e+03 |
3150 | 3.24e+03 |
4775 | 3.99e+03 |
5000 | 5.4e+03 |
4800 | 4.65e+03 |
3350 | 3.49e+03 |
3775 | 3.79e+03 |
4400 | 3.94e+03 |
4475 | 4.09e+03 |
4250 | 3.64e+03 |
4750 | 4.75e+03 |
5850 | 5e+03 |
4050 | 4.29e+03 |
5400 | 5.55e+03 |
3525 | 3.84e+03 |
3450 | 3.64e+03 |
4625 | 4.75e+03 |
3200 | 3.49e+03 |
4150 | 3.99e+03 |
4100 | 3.54e+03 |
5700 | 5.65e+03 |
3800 | 3.49e+03 |
3900 | 3.04e+03 |
4675 | 3.89e+03 |
3400 | 3.39e+03 |
3600 | 3.64e+03 |
5200 | 5.45e+03 |
4850 | 4.85e+03 |
4300 | 4.55e+03 |
5550 | 5.15e+03 |
4100 | 3.74e+03 |
5550 | 5.3e+03 |
3450 | 3.99e+03 |
3475 | 3.49e+03 |
2900 | 3.04e+03 |
4650 | 4.85e+03 |
3400 | 3.64e+03 |
3050 | 3.69e+03 |
3150 | 3.49e+03 |
3650 | 3.79e+03 |
5800 | 5.65e+03 |
4200 | 4.55e+03 |
4700 | 5.15e+03 |
4800 | 4.7e+03 |
4450 | 4.55e+03 |
4050 | 3.74e+03 |
3600 | 3.14e+03 |
4275 | 3.99e+03 |
3200 | 3.49e+03 |
3625 | 3.19e+03 |
3900 | 3.64e+03 |
4750 | 4.9e+03 |
3950 | 3.74e+03 |
3750 | 3.19e+03 |
3550 | 3.94e+03 |
2900 | 3.49e+03 |
5000 | 5.2e+03 |
3750 | 3.84e+03 |
4900 | 5e+03 |
3500 | 3.79e+03 |
3675 | 4.04e+03 |
3075 | 3.29e+03 |
4000 | 4.09e+03 |
5400 | 4.9e+03 |
3450 | 3.64e+03 |
5000 | 4.95e+03 |
4600 | 5.05e+03 |
3700 | 3.39e+03 |
5650 | 4.9e+03 |
3750 | 4.09e+03 |
3900 | 3.89e+03 |
library(discrim)
nb_spec <- naive_Bayes() %>%
set_mode("classification") %>%
set_engine("klaR") %>%
set_args(usekernel = FALSE)
nb_spec
Naive Bayes Model Specification (classification)
Engine-Specific Arguments:
usekernel = FALSE
Computational engine: klaR
parsnip model object
$apriori
grouping
Adelie Chinstrap Gentoo
0.4398496 0.2067669 0.3533835
$tables
$tables$island
var
grouping Biscoe Dream Torgersen
Adelie 0.3247863 0.3931624 0.2820513
Chinstrap 0.0000000 1.0000000 0.0000000
Gentoo 1.0000000 0.0000000 0.0000000
$tables$bill_length_mm
[,1] [,2]
Adelie 38.66667 2.653332
Chinstrap 48.51273 3.404140
Gentoo 47.26596 2.843085
$tables$bill_depth_mm
[,1] [,2]
Adelie 18.29658 1.2007133
Chinstrap 18.38909 1.1825385
Gentoo 14.91809 0.9249194
$tables$flipper_length_mm
[,1] [,2]
Adelie 189.8462 6.083635
Chinstrap 195.6727 7.557323
Gentoo 217.1489 6.225092
$tables$body_mass_g
[,1] [,2]
Adelie 3675.641 439.9189
Chinstrap 3723.182 389.2019
Gentoo 5071.809 483.4802
$tables$sex
var
grouping female male
Adelie 0.5128205 0.4871795
Chinstrap 0.5272727 0.4727273
Gentoo 0.5000000 0.5000000
$tables$year
[,1] [,2]
Adelie 2008.085 0.8048629
Chinstrap 2008.000 0.8606630
Gentoo 2008.053 0.7671624
$levels
[1] "Adelie" "Chinstrap" "Gentoo"
$call
NaiveBayes.default(x = ~maybe_data_frame(x), grouping = ~y, usekernel = ~FALSE)
$x
island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
1 Biscoe 48.4 14.4 203 4625 female
2 Dream 50.3 20.0 197 3300 male
3 Dream 42.3 21.2 191 4150 male
4 Biscoe 50.5 15.9 225 5400 male
5 Dream 40.9 18.9 184 3900 male
6 Biscoe 34.5 18.1 187 2900 female
7 Dream 37.0 16.5 185 3400 female
8 Torgersen 37.2 19.4 184 3900 male
9 Biscoe 46.2 14.9 221 5300 male
10 Biscoe 39.6 17.7 186 3500 female
11 Biscoe 48.8 16.2 222 6000 male
12 Biscoe 45.2 16.4 223 5950 male
13 Dream 46.8 16.5 189 3650 female
14 Dream 45.9 17.1 190 3575 female
15 Dream 32.1 15.5 188 3050 female
16 Dream 49.0 19.6 212 4300 male
17 Biscoe 48.7 15.1 222 5350 male
18 Biscoe 46.5 14.5 213 4400 female
19 Biscoe 46.9 14.6 222 4875 female
20 Dream 42.4 17.3 181 3600 female
21 Dream 52.8 20.0 205 4550 male
22 Biscoe 35.0 17.9 192 3725 female
23 Dream 45.7 17.0 195 3650 female
24 Dream 49.7 18.6 195 3600 male
25 Biscoe 47.3 15.3 222 5250 male
26 Dream 36.4 17.0 195 3325 female
27 Dream 42.2 18.5 180 3550 female
28 Torgersen 42.8 18.5 195 4250 male
29 Biscoe 46.6 14.2 210 4850 female
30 Biscoe 45.1 14.4 210 4400 female
31 Dream 46.7 17.9 195 3300 female
32 Dream 37.0 16.9 185 3000 female
33 Biscoe 46.5 13.5 210 4550 female
34 Torgersen 40.9 16.8 191 3700 female
35 Biscoe 48.4 14.6 213 5850 male
36 Biscoe 40.1 18.9 188 4300 male
37 Biscoe 42.7 18.3 196 4075 male
38 Biscoe 46.1 15.1 215 5100 male
39 Biscoe 50.0 15.9 224 5350 male
40 Dream 36.0 17.1 187 3700 female
41 Dream 51.0 18.8 203 4100 male
42 Dream 45.2 16.6 191 3250 female
43 Biscoe 49.4 15.8 216 4925 male
44 Biscoe 46.5 14.8 217 5200 female
45 Torgersen 41.1 18.6 189 3325 male
46 Dream 46.4 18.6 190 3450 female
47 Biscoe 42.9 13.1 215 5000 female
48 Torgersen 38.8 17.6 191 3275 female
49 Biscoe 39.7 17.7 193 3200 female
50 Biscoe 45.3 13.7 210 4300 female
51 Biscoe 45.7 13.9 214 4400 female
52 Torgersen 41.5 18.3 195 4300 male
53 Torgersen 41.8 19.4 198 4450 male
54 Biscoe 45.2 15.8 215 5300 male
55 Biscoe 49.5 16.2 229 5800 male
56 Biscoe 38.8 17.2 180 3800 male
57 Biscoe 48.4 16.3 220 5400 male
58 Biscoe 53.4 15.8 219 5500 male
59 Torgersen 36.2 16.1 187 3550 female
60 Dream 49.0 19.5 210 3950 male
61 Dream 49.5 19.0 200 3800 male
62 Dream 51.4 19.0 201 3950 male
63 Dream 36.3 19.5 190 3800 male
64 Biscoe 48.1 15.1 209 5500 male
65 Dream 45.7 17.3 193 3600 female
66 Biscoe 45.0 15.4 220 5050 male
67 Biscoe 37.6 17.0 185 3600 female
68 Biscoe 35.9 19.2 189 3800 female
69 Biscoe 41.3 21.1 195 4400 male
70 Torgersen 35.2 15.9 186 3050 female
71 Biscoe 51.3 14.2 218 5300 male
72 Torgersen 39.6 17.2 196 3550 female
73 Dream 47.5 16.8 199 3900 female
74 Biscoe 44.9 13.3 213 5100 female
75 Biscoe 45.5 13.9 210 4200 female
76 Biscoe 47.7 15.0 216 4750 female
77 Torgersen 38.7 19.0 195 3450 female
78 Biscoe 38.1 16.5 198 3825 female
79 Biscoe 48.5 14.1 220 5300 male
80 Biscoe 54.3 15.7 231 5650 male
81 Biscoe 36.5 16.6 181 2850 female
82 Dream 39.0 18.7 185 3650 male
83 Dream 45.2 17.8 198 3950 female
84 Biscoe 38.2 20.0 190 3900 male
85 Biscoe 44.0 13.6 208 4350 female
86 Dream 37.3 17.8 191 3350 female
87 Dream 51.3 19.9 198 3700 male
88 Biscoe 45.8 14.2 219 4700 female
89 Dream 38.8 20.0 190 3950 male
90 Biscoe 47.2 13.7 214 4925 female
91 Biscoe 46.3 15.8 215 5050 male
92 Biscoe 55.9 17.0 228 5600 male
93 Torgersen 43.1 19.2 197 3500 male
94 Dream 53.5 19.9 205 4500 male
95 Biscoe 45.1 14.5 215 5000 female
96 Biscoe 39.7 18.9 184 3550 male
97 Dream 50.9 17.9 196 3675 female
98 Dream 46.4 17.8 191 3700 female
99 Torgersen 39.3 20.6 190 3650 male
100 Biscoe 51.5 16.3 230 5500 male
101 Biscoe 49.5 16.1 224 5650 male
102 Dream 41.3 20.3 194 3550 male
103 Biscoe 42.6 13.7 213 4950 female
104 Dream 39.2 21.1 196 4150 male
105 Dream 40.7 17.0 190 3725 male
106 Biscoe 37.9 18.6 172 3150 female
107 Dream 46.0 18.9 195 4150 female
108 Dream 50.8 19.0 210 4100 male
109 Dream 38.1 18.6 190 3700 female
110 Biscoe 39.6 20.7 191 3900 female
111 Dream 52.0 19.0 197 4150 male
112 Dream 39.5 17.8 188 3300 female
113 Torgersen 39.7 18.4 190 3900 male
114 Biscoe 46.8 14.3 215 4850 female
115 Dream 40.2 17.1 193 3400 female
116 Dream 36.0 18.5 186 3100 female
117 Torgersen 35.5 17.5 190 3700 female
118 Biscoe 46.7 15.3 219 5200 male
119 Dream 36.6 18.4 184 3475 female
120 Biscoe 42.0 13.5 210 4150 female
121 Biscoe 43.5 15.2 213 4650 female
122 Biscoe 49.1 14.8 220 5150 female
123 Biscoe 49.6 15.0 216 4750 male
124 Biscoe 40.5 18.9 180 3950 male
125 Biscoe 37.8 18.3 174 3400 female
126 Torgersen 37.7 19.8 198 3500 male
127 Biscoe 47.5 14.2 209 4600 female
128 Biscoe 47.5 15.0 218 4950 female
129 Dream 36.0 17.8 195 3450 female
130 Dream 42.5 17.3 187 3350 female
131 Dream 50.2 18.8 202 3800 male
132 Biscoe 48.2 15.6 221 5100 male
133 Biscoe 51.1 16.3 220 6000 male
134 Biscoe 36.4 17.1 184 2850 female
135 Torgersen 34.4 18.4 184 3325 female
136 Biscoe 35.5 16.2 195 3350 female
137 Biscoe 44.9 13.8 212 4750 female
138 Dream 35.6 17.5 191 3175 female
139 Dream 51.3 18.2 197 3750 male
140 Dream 35.7 18.0 202 3550 female
141 Biscoe 45.8 14.6 210 4200 female
142 Biscoe 49.2 15.2 221 6300 male
143 Dream 37.3 16.8 192 3000 female
144 Torgersen 41.1 17.6 182 3200 female
145 Dream 48.1 16.4 199 3325 female
146 Biscoe 35.7 16.9 185 3150 female
147 Dream 36.9 18.6 189 3500 female
148 Biscoe 49.6 16.0 225 5700 male
149 Biscoe 43.3 13.4 209 4400 female
150 Biscoe 41.4 18.6 191 3700 male
151 Dream 41.1 19.0 182 3425 male
152 Dream 39.6 18.8 190 4600 male
153 Torgersen 34.6 17.2 189 3200 female
154 Dream 54.2 20.8 201 4300 male
155 Dream 50.5 19.6 201 4050 male
156 Biscoe 40.6 18.6 183 3550 male
157 Dream 49.3 19.9 203 4050 male
158 Biscoe 50.4 15.3 224 5550 male
159 Biscoe 46.8 15.4 215 5150 male
160 Biscoe 48.2 14.3 210 4600 female
161 Biscoe 45.5 15.0 220 5000 male
162 Biscoe 40.9 13.7 214 4650 female
163 Dream 50.0 19.5 196 3900 male
164 Dream 43.5 18.1 202 3400 female
165 Biscoe 37.9 18.6 193 2925 female
166 Dream 46.9 16.6 192 2700 female
167 Dream 46.6 17.8 193 3800 female
168 Biscoe 48.5 15.0 219 4850 female
169 Dream 40.3 18.5 196 4350 male
170 Dream 38.3 19.2 189 3950 male
171 Dream 45.4 18.7 188 3525 female
172 Biscoe 50.2 14.3 218 5700 male
173 Dream 51.9 19.5 206 3950 male
174 Torgersen 34.6 21.1 198 4400 male
175 Biscoe 45.2 14.8 212 5200 female
176 Torgersen 35.7 17.0 189 3350 female
177 Biscoe 45.6 20.3 191 4600 male
178 Biscoe 39.0 17.5 186 3550 female
179 Biscoe 41.7 14.7 210 4700 female
180 Torgersen 38.5 17.9 190 3325 female
181 Dream 37.8 18.1 193 3750 male
182 Biscoe 46.8 16.1 215 5500 male
183 Dream 40.2 20.1 200 3975 male
184 Biscoe 49.1 15.0 228 5500 male
185 Torgersen 39.5 17.4 186 3800 female
186 Biscoe 42.8 14.2 209 4700 female
187 Biscoe 46.4 15.0 216 4700 female
188 Dream 50.6 19.4 193 3800 male
189 Torgersen 37.3 20.5 199 3775 male
190 Dream 39.7 17.9 193 4250 male
191 Dream 58.0 17.8 181 3700 female
192 Biscoe 50.8 17.3 228 5600 male
193 Biscoe 42.0 19.5 200 4050 male
194 Dream 46.1 18.2 178 3250 female
195 Biscoe 43.3 14.0 208 4575 female
196 Dream 46.2 17.5 187 3650 female
197 Dream 36.5 18.0 182 3150 female
198 Biscoe 43.2 19.0 197 4775 male
199 Biscoe 50.1 15.0 225 5000 male
200 Dream 52.0 20.7 210 4800 male
201 Dream 42.5 16.7 187 3350 female
202 Dream 49.6 18.2 193 3775 male
203 Dream 44.1 19.7 196 4400 male
204 Dream 37.5 18.5 199 4475 male
205 Dream 39.2 18.6 190 4250 male
206 Biscoe 45.5 14.5 212 4750 female
207 Biscoe 49.3 15.7 217 5850 male
208 Dream 50.7 19.7 203 4050 male
209 Biscoe 52.2 17.1 228 5400 male
210 Dream 45.6 19.4 194 3525 female
211 Dream 36.0 17.9 190 3450 female
212 Biscoe 49.1 14.5 212 4625 female
213 Dream 40.9 16.6 187 3200 female
214 Torgersen 45.8 18.9 197 4150 male
215 Biscoe 41.1 19.1 188 4100 male
216 Biscoe 49.8 16.8 230 5700 male
217 Torgersen 36.7 18.8 187 3800 female
218 Dream 37.2 18.1 178 3900 male
219 Torgersen 39.2 19.6 195 4675 male
220 Dream 34.0 17.1 185 3400 female
221 Torgersen 33.5 19.0 190 3600 female
222 Biscoe 50.8 15.7 226 5200 male
223 Biscoe 44.5 14.7 214 4850 female
224 Dream 40.8 18.9 208 4300 male
225 Biscoe 50.0 15.3 220 5550 male
226 Dream 43.2 18.5 192 4100 male
227 Biscoe 50.7 15.0 223 5550 male
228 Dream 52.2 18.8 197 3450 male
229 Dream 40.6 17.2 187 3475 male
230 Dream 33.1 16.1 178 2900 female
231 Biscoe 45.5 13.7 214 4650 female
232 Dream 50.1 17.9 190 3400 female
233 Torgersen 39.0 17.1 191 3050 female
234 Torgersen 36.2 17.2 187 3150 female
235 Dream 51.3 19.2 193 3650 male
236 Biscoe 48.6 16.0 230 5800 male
237 Biscoe 45.3 13.8 208 4200 female
238 Biscoe 43.5 14.2 220 4700 female
239 Biscoe 45.4 14.6 211 4800 female
240 Biscoe 43.2 14.5 208 4450 female
241 Biscoe 41.1 18.2 192 4050 male
242 Biscoe 37.7 18.7 180 3600 male
243 Biscoe 42.2 19.5 197 4275 male
244 Biscoe 40.5 17.9 187 3200 female
245 Torgersen 38.9 17.8 181 3625 female
246 Dream 41.1 17.5 190 3900 male
247 Biscoe 45.2 13.8 215 4750 female
248 Biscoe 41.6 18.0 192 3950 male
249 Torgersen 39.1 18.7 181 3750 male
250 Dream 50.9 19.1 196 3550 male
251 Dream 43.2 16.6 187 2900 female
252 Biscoe 46.4 15.6 221 5000 male
253 Biscoe 37.6 19.1 194 3750 male
254 Biscoe 46.5 14.4 217 4900 female
255 Dream 36.8 18.5 193 3500 female
256 Dream 49.8 17.3 198 3675 female
257 Biscoe 37.7 16.0 183 3075 female
258 Torgersen 40.6 19.0 199 4000 male
259 Biscoe 47.6 14.5 215 5400 male
260 Biscoe 35.0 17.9 190 3450 female
261 Biscoe 50.5 15.2 216 5000 female
262 Biscoe 43.4 14.4 218 4600 female
263 Dream 47.0 17.3 185 3700 female
264 Biscoe 47.8 15.0 215 5650 male
265 Biscoe 38.6 17.2 199 3750 female
266 Dream 40.8 18.4 195 3900 male
year
1 2009
2 2007
3 2007
4 2008
5 2007
6 2008
7 2009
8 2008
9 2008
10 2008
11 2009
12 2008
13 2009
14 2007
15 2009
16 2009
17 2007
18 2007
19 2009
20 2007
21 2008
22 2009
23 2009
24 2008
25 2007
26 2007
27 2007
28 2008
29 2008
30 2008
31 2007
32 2007
33 2007
34 2008
35 2007
36 2008
37 2009
38 2007
39 2009
40 2009
41 2008
42 2009
43 2009
44 2008
45 2009
46 2007
47 2007
48 2009
49 2009
50 2008
51 2008
52 2009
53 2008
54 2008
55 2008
56 2007
57 2008
58 2009
59 2008
60 2008
61 2008
62 2009
63 2008
64 2009
65 2009
66 2008
67 2008
68 2007
69 2008
70 2009
71 2009
72 2008
73 2008
74 2008
75 2008
76 2008
77 2007
78 2009
79 2008
80 2008
81 2008
82 2009
83 2007
84 2009
85 2008
86 2008
87 2007
88 2008
89 2007
90 2009
91 2007
92 2009
93 2009
94 2008
95 2007
96 2009
97 2009
98 2008
99 2007
100 2009
101 2009
102 2008
103 2008
104 2007
105 2009
106 2007
107 2007
108 2009
109 2008
110 2009
111 2007
112 2007
113 2008
114 2009
115 2009
116 2007
117 2008
118 2007
119 2009
120 2007
121 2009
122 2008
123 2008
124 2007
125 2007
126 2009
127 2008
128 2009
129 2009
130 2009
131 2009
132 2008
133 2008
134 2008
135 2007
136 2008
137 2009
138 2009
139 2007
140 2008
141 2007
142 2007
143 2009
144 2007
145 2009
146 2008
147 2008
148 2008
149 2007
150 2008
151 2007
152 2007
153 2008
154 2008
155 2007
156 2007
157 2009
158 2008
159 2007
160 2007
161 2008
162 2007
163 2007
164 2009
165 2009
166 2008
167 2007
168 2009
169 2008
170 2008
171 2007
172 2007
173 2009
174 2007
175 2009
176 2009
177 2009
178 2008
179 2009
180 2009
181 2009
182 2009
183 2009
184 2009
185 2007
186 2007
187 2008
188 2007
189 2009
190 2009
191 2007
192 2009
193 2008
194 2007
195 2009
196 2008
197 2007
198 2009
199 2008
200 2008
201 2008
202 2009
203 2007
204 2009
205 2009
206 2009
207 2007
208 2009
209 2009
210 2009
211 2007
212 2009
213 2008
214 2008
215 2008
216 2008
217 2008
218 2007
219 2007
220 2008
221 2008
222 2009
223 2009
224 2008
225 2007
226 2008
227 2008
228 2009
229 2009
230 2008
231 2007
232 2009
233 2009
234 2009
235 2007
236 2008
237 2008
238 2008
239 2007
240 2008
241 2008
242 2007
243 2009
244 2007
245 2007
246 2009
247 2008
248 2008
249 2007
250 2008
251 2007
252 2008
253 2008
254 2008
255 2009
256 2009
257 2009
258 2009
259 2007
260 2008
261 2009
262 2009
263 2007
264 2007
265 2009
266 2007
$usekernel
[1] FALSE
$varnames
[1] "island" "bill_length_mm" "bill_depth_mm"
[4] "flipper_length_mm" "body_mass_g" "sex"
[7] "year"
attr(,"class")
[1] "NaiveBayes"
Truth
Prediction Adelie Chinstrap Gentoo
Adelie 28 0 0
Chinstrap 1 13 0
Gentoo 0 0 25
knn_spec <- nearest_neighbor(neighbors = 3) %>%
set_mode("classification") %>%
set_engine("kknn")
knn_fit <- knn_spec %>%
fit(species ~ ., data = train)
knn_fit
parsnip model object
Call:
kknn::train.kknn(formula = species ~ ., data = data, ks = min_rows(3, data, 5))
Type of response variable: nominal
Minimal misclassification: 0.01879699
Best kernel: optimal
Best k: 3
Truth
Prediction Adelie Chinstrap Gentoo
Adelie 29 0 0
Chinstrap 0 13 0
Gentoo 0 0 25