{ "cells": [ { "cell_type": "markdown", "metadata": { "colab_type": "text", "heading_collapsed": true, "id": "8BXPT2QxR4HS" }, "source": [ "# Initial:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T11:51:25.588559Z", "start_time": "2019-04-01T11:51:25.583554Z" }, "colab": {}, "colab_type": "code", "hidden": true, "id": "U7wPOcLxRvER" }, "outputs": [], "source": [ "#!pip -q install --upgrade --ignore-installed numpy pandas scipy sklearn seaborn\n", "#!pip install SWMat" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T11:51:39.653345Z", "start_time": "2019-04-01T11:51:26.196067Z" }, "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "colab_type": "code", "hidden": true, "id": "E_eBhdamcZXQ", "outputId": "b91153dd-82ec-4716-faea-62166683b416" }, "outputs": [ { "data": { "text/plain": [ "'0.9.0'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import seaborn as sns\n", "sns.__version__" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "heading_collapsed": true, "id": "TXA9nIqsSEMl" }, "source": [ "# Import:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T11:51:39.748053Z", "start_time": "2019-04-01T11:51:39.661342Z" }, "hidden": true, "scrolled": true }, "outputs": [], "source": [ "import sys\n", "\n", "sys.path.append('../SWMat/')\n", "from SWMat import SWMat" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T11:51:39.834940Z", "start_time": "2019-04-01T11:51:39.752918Z" }, "colab": {}, "colab_type": "code", "hidden": true, "id": "_K0qWMSfRmGn" }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import seaborn as sns" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T11:51:39.939935Z", "start_time": "2019-04-01T11:51:39.842945Z" }, "colab": {}, "colab_type": "code", "hidden": true, "id": "yqoC3mbQSq8W" }, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T11:51:40.041915Z", "start_time": "2019-04-01T11:51:39.944939Z" }, "colab": {}, "colab_type": "code", "hidden": true, "id": "GhzvNRV-gkyl" }, "outputs": [], "source": [ "import warnings\n", "warnings.filterwarnings(\"ignore\")" ] }, { "cell_type": "markdown", "metadata": { "colab_type": "text", "heading_collapsed": true, "id": "RczOEDHbSHI8" }, "source": [ "# Dataset:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T14:12:21.901999Z", "start_time": "2019-04-01T14:12:16.288364Z" }, "colab": {}, "colab_type": "code", "hidden": true, "id": "TzHCJnDgSGpf" }, "outputs": [], "source": [ "from sklearn.datasets import california_housing\n", "\n", "data = california_housing.fetch_california_housing()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T14:12:21.936018Z", "start_time": "2019-04-01T14:12:21.907004Z" }, "colab": { "base_uri": "https://localhost:8080/", "height": 54 }, "colab_type": "code", "hidden": true, "id": "_eeVmmIlSyI1", "outputId": "e7bdfe4a-2707-4520-fe59-8a3ae50314df", "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "dict_keys(['data', 'target', 'feature_names', 'DESCR'])" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.keys()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T14:12:22.108088Z", "start_time": "2019-04-01T14:12:21.942016Z" }, "colab": { "base_uri": "https://localhost:8080/", "height": 726 }, "colab_type": "code", "hidden": true, "id": "R_NWMuZ9igtz", "outputId": "2e6fa981-08c7-477b-b338-d60aaa3480ec" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ ".. _california_housing_dataset:\n", "\n", "California Housing dataset\n", "--------------------------\n", "\n", "**Data Set Characteristics:**\n", "\n", " :Number of Instances: 20640\n", "\n", " :Number of Attributes: 8 numeric, predictive attributes and the target\n", "\n", " :Attribute Information:\n", " - MedInc median income in block\n", " - HouseAge median house age in block\n", " - AveRooms average number of rooms\n", " - AveBedrms average number of bedrooms\n", " - Population block population\n", " - AveOccup average house occupancy\n", " - Latitude house block latitude\n", " - Longitude house block longitude\n", "\n", " :Missing Attribute Values: None\n", "\n", "This dataset was obtained from the StatLib repository.\n", "http://lib.stat.cmu.edu/datasets/\n", "\n", "The target variable is the median house value for California districts.\n", "\n", "This dataset was derived from the 1990 U.S. census, using one row per census\n", "block group. A block group is the smallest geographical unit for which the U.S.\n", "Census Bureau publishes sample data (a block group typically has a population\n", "of 600 to 3,000 people).\n", "\n", "It can be downloaded/loaded using the\n", ":func:`sklearn.datasets.fetch_california_housing` function.\n", "\n", ".. topic:: References\n", "\n", " - Pace, R. Kelley and Ronald Barry, Sparse Spatial Autoregressions,\n", " Statistics and Probability Letters, 33 (1997) 291-297\n", "\n" ] } ], "source": [ "print(data['DESCR'])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T14:12:22.229113Z", "start_time": "2019-04-01T14:12:22.118092Z" }, "colab": {}, "colab_type": "code", "hidden": true, "id": "MYjH7k3aSQ58" }, "outputs": [], "source": [ "X = data['data']\n", "y = data['target']\n", "columns = data['feature_names']" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "ExecuteTime": { "end_time": "2019-04-01T14:12:22.953818Z", "start_time": "2019-04-01T14:12:22.235117Z" }, "colab": { "base_uri": "https://localhost:8080/", "height": 215 }, "colab_type": "code", "hidden": true, "id": "zDPAU7s-SlcJ", "outputId": "30668ef6-b4c0-448b-dd8c-a53300fbc716" }, "outputs": [ { "data": { "text/html": [ "
\n", " | MedInc | \n", "HouseAge | \n", "AveRooms | \n", "AveBedrms | \n", "Population | \n", "AveOccup | \n", "Latitude | \n", "Longitude | \n", "target | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "8.3252 | \n", "41.0 | \n", "6.984127 | \n", "1.023810 | \n", "322.0 | \n", "2.555556 | \n", "37.88 | \n", "-122.23 | \n", "4.526 | \n", "
1 | \n", "8.3014 | \n", "21.0 | \n", "6.238137 | \n", "0.971880 | \n", "2401.0 | \n", "2.109842 | \n", "37.86 | \n", "-122.22 | \n", "3.585 | \n", "
2 | \n", "7.2574 | \n", "52.0 | \n", "8.288136 | \n", "1.073446 | \n", "496.0 | \n", "2.802260 | \n", "37.85 | \n", "-122.24 | \n", "3.521 | \n", "
3 | \n", "5.6431 | \n", "52.0 | \n", "5.817352 | \n", "1.073059 | \n", "558.0 | \n", "2.547945 | \n", "37.85 | \n", "-122.25 | \n", "3.413 | \n", "
4 | \n", "3.8462 | \n", "52.0 | \n", "6.281853 | \n", "1.081081 | \n", "565.0 | \n", "2.181467 | \n", "37.85 | \n", "-122.25 | \n", "3.422 | \n", "