{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "# Outlier-Sensitive Predictor" ], "metadata": { "id": "pUdgDToFZPsM" } }, { "cell_type": "code", "execution_count": 7, "metadata": { "id": "L96SNQ8HVI7m" }, "outputs": [], "source": [ "# imports\n", "import tensorflow as tf\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from sklearn.preprocessing import StandardScaler\n", "from imblearn.over_sampling import RandomOverSampler\n", "import seaborn as sns\n", "from sklearn.model_selection import train_test_split" ] }, { "cell_type": "code", "source": [ "# using drive to load our dataset\n", "from google.colab import drive\n", "drive.mount('/content/drive')" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Ea3adROCVORJ", "outputId": "337c92a7-9d72-4e6c-c4de-94c07507d1a1" }, "execution_count": 2, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Mounted at /content/drive\n" ] } ] }, { "cell_type": "code", "source": [ "df = pd.read_csv(\"/content/drive/MyDrive/dataset/heart.csv\") # loading\n", "del df['trestbps'], df['fbs'], df['restecg'], df['thalach'], df['exang'], df['slope'],df['oldpeak']\n", "df" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "id": "5XYS8syqVREm", "outputId": "d0c6e728-4ea8-420f-dfd1-7a823bb7de9b" }, "execution_count": 26, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " age sex cp chol ca thal target\n", "0 63 1 3 233 0 1 1\n", "1 37 1 2 250 0 2 1\n", "2 41 0 1 204 0 2 1\n", "3 56 1 1 236 0 2 1\n", "4 57 0 0 354 0 2 1\n", ".. ... ... .. ... .. ... ...\n", "298 57 0 0 241 0 3 0\n", "299 45 1 3 264 0 3 0\n", "300 68 1 0 193 2 3 0\n", "301 57 1 0 131 1 3 0\n", "302 57 0 1 236 1 2 0\n", "\n", "[303 rows x 7 columns]" ], "text/html": [ "\n", "
\n", " | age | \n", "sex | \n", "cp | \n", "chol | \n", "ca | \n", "thal | \n", "target | \n", "
---|---|---|---|---|---|---|---|
0 | \n", "63 | \n", "1 | \n", "3 | \n", "233 | \n", "0 | \n", "1 | \n", "1 | \n", "
1 | \n", "37 | \n", "1 | \n", "2 | \n", "250 | \n", "0 | \n", "2 | \n", "1 | \n", "
2 | \n", "41 | \n", "0 | \n", "1 | \n", "204 | \n", "0 | \n", "2 | \n", "1 | \n", "
3 | \n", "56 | \n", "1 | \n", "1 | \n", "236 | \n", "0 | \n", "2 | \n", "1 | \n", "
4 | \n", "57 | \n", "0 | \n", "0 | \n", "354 | \n", "0 | \n", "2 | \n", "1 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
298 | \n", "57 | \n", "0 | \n", "0 | \n", "241 | \n", "0 | \n", "3 | \n", "0 | \n", "
299 | \n", "45 | \n", "1 | \n", "3 | \n", "264 | \n", "0 | \n", "3 | \n", "0 | \n", "
300 | \n", "68 | \n", "1 | \n", "0 | \n", "193 | \n", "2 | \n", "3 | \n", "0 | \n", "
301 | \n", "57 | \n", "1 | \n", "0 | \n", "131 | \n", "1 | \n", "3 | \n", "0 | \n", "
302 | \n", "57 | \n", "0 | \n", "1 | \n", "236 | \n", "1 | \n", "2 | \n", "0 | \n", "
303 rows × 7 columns
\n", "RandomForestClassifier(n_estimators=1000, random_state=1)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
RandomForestClassifier(n_estimators=1000, random_state=1)