{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyNCMx3gFGgtYT3Mqr8vbphC",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "markdown",
"source": [
"## Import required Packages"
],
"metadata": {
"id": "mE9kPDgOUTu4"
}
},
{
"cell_type": "code",
"source": [
"!pip install catboost\n",
"!pip install xgboost\n",
"!pip install lightgbm"
],
"metadata": {
"id": "hmsQw_oqU2mH"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"id": "uDZSZSxjUQRs"
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from sklearn.model_selection import train_test_split\n",
"from catboost import CatBoostClassifier, Pool\n",
"from sklearn.metrics import confusion_matrix, classification_report\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"from sklearn.metrics import confusion_matrix as cm\n",
"import xgboost as xgb\n",
"import lightgbm as lgb"
]
},
{
"cell_type": "markdown",
"source": [
"## Load the Dataset"
],
"metadata": {
"id": "vIf6o9eWUUoI"
}
},
{
"cell_type": "code",
"source": [
"# Load the dataset\n",
"url = \"https://archive.ics.uci.edu/ml/machine-learning-databases/zoo/zoo.data\"\n",
"names = ['animal_name', 'hair', 'feathers', 'eggs', 'milk', 'airborne', 'aquatic', 'predator', 'toothed', 'backbone', 'breathes', 'venomous', 'fins', 'legs', 'tail', 'domestic', 'catsize', 'class_type']\n",
"df = pd.read_csv(url, names=names)\n",
"\n",
"df.head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "8iTmdd34UUwj",
"outputId": "b33ad36a-b9b1-4ed3-a607-9405e7172dc6"
},
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" animal_name hair feathers eggs milk airborne aquatic predator \\\n",
"0 aardvark 1 0 0 1 0 0 1 \n",
"1 antelope 1 0 0 1 0 0 0 \n",
"2 bass 0 0 1 0 0 1 1 \n",
"3 bear 1 0 0 1 0 0 1 \n",
"4 boar 1 0 0 1 0 0 1 \n",
"\n",
" toothed backbone breathes venomous fins legs tail domestic catsize \\\n",
"0 1 1 1 0 0 4 0 0 1 \n",
"1 1 1 1 0 0 4 1 0 1 \n",
"2 1 1 0 0 1 0 1 0 0 \n",
"3 1 1 1 0 0 4 0 0 1 \n",
"4 1 1 1 0 0 4 1 0 1 \n",
"\n",
" class_type \n",
"0 1 \n",
"1 1 \n",
"2 4 \n",
"3 1 \n",
"4 1 "
],
"text/html": [
"\n",
"
| \n", " | animal_name | \n", "hair | \n", "feathers | \n", "eggs | \n", "milk | \n", "airborne | \n", "aquatic | \n", "predator | \n", "toothed | \n", "backbone | \n", "breathes | \n", "venomous | \n", "fins | \n", "legs | \n", "tail | \n", "domestic | \n", "catsize | \n", "class_type | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "aardvark | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "4 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "
| 1 | \n", "antelope | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "4 | \n", "1 | \n", "0 | \n", "1 | \n", "1 | \n", "
| 2 | \n", "bass | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "4 | \n", "
| 3 | \n", "bear | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "4 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "
| 4 | \n", "boar | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "0 | \n", "0 | \n", "1 | \n", "1 | \n", "1 | \n", "1 | \n", "0 | \n", "0 | \n", "4 | \n", "1 | \n", "0 | \n", "1 | \n", "1 | \n", "