ames-housing/02_descriptive_visualizations.ipynb

4991 lines
3.6 MiB
Text
Raw Normal View History

2021-05-25 08:22:14 +02:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Descriptive Visualizations\n",
"\n",
"The purpose of this notebook is to visually examine the nominal features, discard the useless ones among them, and create new factor variables.\n",
"\n",
"The \"main\" plot used in this notebook is *Gr Liv Area* vs. *SalePrice* as the overall living area is the most correlated predictor (which is also very intuitive). Many of the nominal variables change the slopes of the regression lines for sub-groups of data points significantly."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## \"Housekeeping\""
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"\n",
"from sklearn.ensemble import IsolationForest\n",
"\n",
"from utils import (\n",
" ALL_COLUMNS,\n",
" NOMINAL_VARIABLES,\n",
" TARGET_VARIABLES,\n",
" load_clean_data,\n",
" encode_ordinals,\n",
" print_column_list,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
2024-07-10 01:31:28 +02:00
"random_state = np.random.RandomState(42)"
2021-05-25 08:22:14 +02:00
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
2024-07-10 01:31:28 +02:00
"source": [
"pd.set_option(\"display.max_columns\", 120)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
2021-05-25 08:22:14 +02:00
"source": [
"sns.set_style(\"white\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load the Data\n"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 5,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df = load_clean_data(\"data/data_clean_with_transformations.csv\")"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 6,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2898, 86)"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 6,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 7,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>1st Flr SF</th>\n",
" <th>1st Flr SF (box-cox-0)</th>\n",
" <th>2nd Flr SF</th>\n",
" <th>3Ssn Porch</th>\n",
" <th>Alley</th>\n",
" <th>Bedroom AbvGr</th>\n",
" <th>Bldg Type</th>\n",
" <th>Bsmt Cond</th>\n",
" <th>Bsmt Exposure</th>\n",
" <th>Bsmt Full Bath</th>\n",
" <th>Bsmt Half Bath</th>\n",
" <th>Bsmt Qual</th>\n",
" <th>Bsmt Unf SF</th>\n",
" <th>BsmtFin SF 1</th>\n",
" <th>BsmtFin SF 2</th>\n",
" <th>BsmtFin Type 1</th>\n",
" <th>BsmtFin Type 2</th>\n",
" <th>Central Air</th>\n",
" <th>Condition 1</th>\n",
" <th>Condition 2</th>\n",
" <th>Electrical</th>\n",
" <th>Enclosed Porch</th>\n",
" <th>Exter Cond</th>\n",
" <th>Exter Qual</th>\n",
" <th>Exterior 1st</th>\n",
" <th>Exterior 2nd</th>\n",
" <th>Fence</th>\n",
" <th>Fireplace Qu</th>\n",
" <th>Fireplaces</th>\n",
" <th>Foundation</th>\n",
" <th>Full Bath</th>\n",
" <th>Functional</th>\n",
" <th>Garage Area</th>\n",
" <th>Garage Cars</th>\n",
" <th>Garage Cond</th>\n",
" <th>Garage Finish</th>\n",
" <th>Garage Qual</th>\n",
" <th>Garage Type</th>\n",
" <th>Gr Liv Area</th>\n",
" <th>Gr Liv Area (box-cox-0)</th>\n",
" <th>Half Bath</th>\n",
" <th>Heating</th>\n",
" <th>Heating QC</th>\n",
" <th>House Style</th>\n",
" <th>Kitchen AbvGr</th>\n",
" <th>Kitchen Qual</th>\n",
" <th>Land Contour</th>\n",
" <th>Land Slope</th>\n",
" <th>Lot Area</th>\n",
" <th>Lot Area (box-cox-0.1)</th>\n",
" <th>Lot Config</th>\n",
" <th>Lot Shape</th>\n",
" <th>Low Qual Fin SF</th>\n",
" <th>MS SubClass</th>\n",
" <th>MS Zoning</th>\n",
" <th>Mas Vnr Area</th>\n",
" <th>Mas Vnr Type</th>\n",
" <th>Misc Feature</th>\n",
" <th>Misc Val</th>\n",
" <th>Mo Sold</th>\n",
" <th>Neighborhood</th>\n",
" <th>Open Porch SF</th>\n",
" <th>Overall Cond</th>\n",
" <th>Overall Qual</th>\n",
" <th>Paved Drive</th>\n",
" <th>Pool Area</th>\n",
" <th>Pool QC</th>\n",
" <th>Roof Matl</th>\n",
" <th>Roof Style</th>\n",
" <th>Sale Condition</th>\n",
" <th>Sale Type</th>\n",
" <th>Screen Porch</th>\n",
" <th>Street</th>\n",
" <th>TotRms AbvGrd</th>\n",
" <th>Total Bath</th>\n",
" <th>Total Bsmt SF</th>\n",
" <th>Total Porch SF</th>\n",
" <th>Total SF</th>\n",
" <th>Total SF (box-cox-0.2)</th>\n",
" <th>Utilities</th>\n",
" <th>Wood Deck SF</th>\n",
" <th>Year Built</th>\n",
" <th>Year Remod/Add</th>\n",
" <th>Yr Sold</th>\n",
" <th>SalePrice</th>\n",
" <th>SalePrice (box-cox-0)</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>1656.0</td>\n",
" <td>7.412160</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>3</td>\n",
" <td>1Fam</td>\n",
" <td>Gd</td>\n",
" <td>Gd</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>441.0</td>\n",
" <td>639.0</td>\n",
" <td>0.0</td>\n",
" <td>BLQ</td>\n",
" <td>Unf</td>\n",
" <td>Y</td>\n",
" <td>Norm</td>\n",
" <td>Norm</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>TA</td>\n",
" <td>TA</td>\n",
" <td>BrkFace</td>\n",
" <td>Plywood</td>\n",
" <td>NA</td>\n",
" <td>Gd</td>\n",
" <td>2</td>\n",
" <td>CBlock</td>\n",
" <td>1</td>\n",
" <td>Typ</td>\n",
" <td>528.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>Fin</td>\n",
" <td>TA</td>\n",
" <td>Attchd</td>\n",
" <td>1656.0</td>\n",
" <td>7.412160</td>\n",
" <td>0</td>\n",
" <td>GasA</td>\n",
" <td>Fa</td>\n",
" <td>1Story</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Lvl</td>\n",
" <td>Gtl</td>\n",
" <td>31770.0</td>\n",
" <td>18.196923</td>\n",
" <td>Corner</td>\n",
" <td>IR1</td>\n",
" <td>0.0</td>\n",
" <td>020</td>\n",
" <td>RL</td>\n",
" <td>112.0</td>\n",
" <td>Stone</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>5</td>\n",
" <td>Names</td>\n",
" <td>62.0</td>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>P</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>CompShg</td>\n",
" <td>Hip</td>\n",
" <td>Normal</td>\n",
" <td>WD</td>\n",
" <td>0.0</td>\n",
" <td>Pave</td>\n",
" <td>7</td>\n",
" <td>2.0</td>\n",
" <td>1080.0</td>\n",
" <td>272.0</td>\n",
" <td>2736.0</td>\n",
" <td>19.344072</td>\n",
" <td>AllPub</td>\n",
" <td>210.0</td>\n",
" <td>1960</td>\n",
" <td>1960</td>\n",
" <td>2010</td>\n",
" <td>215000.0</td>\n",
" <td>12.278393</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>896.0</td>\n",
" <td>6.797940</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>2</td>\n",
" <td>1Fam</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>270.0</td>\n",
" <td>468.0</td>\n",
" <td>144.0</td>\n",
" <td>Rec</td>\n",
" <td>LwQ</td>\n",
" <td>Y</td>\n",
" <td>Feedr</td>\n",
" <td>Norm</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>TA</td>\n",
" <td>TA</td>\n",
" <td>VinylSd</td>\n",
" <td>VinylSd</td>\n",
" <td>MnPrv</td>\n",
" <td>NA</td>\n",
" <td>0</td>\n",
" <td>CBlock</td>\n",
" <td>1</td>\n",
" <td>Typ</td>\n",
" <td>730.0</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Unf</td>\n",
" <td>TA</td>\n",
" <td>Attchd</td>\n",
" <td>896.0</td>\n",
" <td>6.797940</td>\n",
" <td>0</td>\n",
" <td>GasA</td>\n",
" <td>TA</td>\n",
" <td>1Story</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Lvl</td>\n",
" <td>Gtl</td>\n",
" <td>11622.0</td>\n",
" <td>15.499290</td>\n",
" <td>Inside</td>\n",
" <td>Reg</td>\n",
" <td>0.0</td>\n",
" <td>020</td>\n",
" <td>RH</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>6</td>\n",
" <td>Names</td>\n",
" <td>0.0</td>\n",
" <td>6</td>\n",
" <td>5</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>CompShg</td>\n",
" <td>Gable</td>\n",
" <td>Normal</td>\n",
" <td>WD</td>\n",
" <td>120.0</td>\n",
" <td>Pave</td>\n",
" <td>5</td>\n",
" <td>1.0</td>\n",
" <td>882.0</td>\n",
" <td>260.0</td>\n",
" <td>1778.0</td>\n",
" <td>17.333478</td>\n",
" <td>AllPub</td>\n",
" <td>140.0</td>\n",
" <td>1961</td>\n",
" <td>1961</td>\n",
" <td>2010</td>\n",
" <td>105000.0</td>\n",
" <td>11.561716</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>1329.0</td>\n",
" <td>7.192182</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>3</td>\n",
" <td>1Fam</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>406.0</td>\n",
" <td>923.0</td>\n",
" <td>0.0</td>\n",
" <td>ALQ</td>\n",
" <td>Unf</td>\n",
" <td>Y</td>\n",
" <td>Norm</td>\n",
" <td>Norm</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>TA</td>\n",
" <td>TA</td>\n",
" <td>Wd Sdng</td>\n",
" <td>Wd Sdng</td>\n",
" <td>NA</td>\n",
" <td>NA</td>\n",
" <td>0</td>\n",
" <td>CBlock</td>\n",
" <td>1</td>\n",
" <td>Typ</td>\n",
" <td>312.0</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Unf</td>\n",
" <td>TA</td>\n",
" <td>Attchd</td>\n",
" <td>1329.0</td>\n",
" <td>7.192182</td>\n",
" <td>1</td>\n",
" <td>GasA</td>\n",
" <td>TA</td>\n",
" <td>1Story</td>\n",
" <td>1</td>\n",
" <td>Gd</td>\n",
" <td>Lvl</td>\n",
" <td>Gtl</td>\n",
" <td>14267.0</td>\n",
" <td>16.027549</td>\n",
" <td>Corner</td>\n",
" <td>IR1</td>\n",
" <td>0.0</td>\n",
" <td>020</td>\n",
" <td>RL</td>\n",
" <td>108.0</td>\n",
" <td>BrkFace</td>\n",
" <td>Gar2</td>\n",
" <td>12500.0</td>\n",
" <td>6</td>\n",
" <td>Names</td>\n",
" <td>36.0</td>\n",
" <td>6</td>\n",
" <td>6</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>CompShg</td>\n",
" <td>Hip</td>\n",
" <td>Normal</td>\n",
" <td>WD</td>\n",
" <td>0.0</td>\n",
" <td>Pave</td>\n",
" <td>6</td>\n",
" <td>1.5</td>\n",
" <td>1329.0</td>\n",
" <td>429.0</td>\n",
" <td>2658.0</td>\n",
" <td>19.203658</td>\n",
" <td>AllPub</td>\n",
" <td>393.0</td>\n",
" <td>1958</td>\n",
" <td>1958</td>\n",
" <td>2010</td>\n",
" <td>172000.0</td>\n",
" <td>12.055250</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>2110.0</td>\n",
" <td>7.654443</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>3</td>\n",
" <td>1Fam</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>1045.0</td>\n",
" <td>1065.0</td>\n",
" <td>0.0</td>\n",
" <td>ALQ</td>\n",
" <td>Unf</td>\n",
" <td>Y</td>\n",
" <td>Norm</td>\n",
" <td>Norm</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>TA</td>\n",
" <td>Gd</td>\n",
" <td>BrkFace</td>\n",
" <td>BrkFace</td>\n",
" <td>NA</td>\n",
" <td>TA</td>\n",
" <td>2</td>\n",
" <td>CBlock</td>\n",
" <td>2</td>\n",
" <td>Typ</td>\n",
" <td>522.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>Fin</td>\n",
" <td>TA</td>\n",
" <td>Attchd</td>\n",
" <td>2110.0</td>\n",
" <td>7.654443</td>\n",
" <td>1</td>\n",
" <td>GasA</td>\n",
" <td>Ex</td>\n",
" <td>1Story</td>\n",
" <td>1</td>\n",
" <td>Ex</td>\n",
" <td>Lvl</td>\n",
" <td>Gtl</td>\n",
" <td>11160.0</td>\n",
" <td>15.396064</td>\n",
" <td>Corner</td>\n",
" <td>Reg</td>\n",
" <td>0.0</td>\n",
" <td>020</td>\n",
" <td>RL</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>4</td>\n",
" <td>Names</td>\n",
" <td>0.0</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>CompShg</td>\n",
" <td>Hip</td>\n",
" <td>Normal</td>\n",
" <td>WD</td>\n",
" <td>0.0</td>\n",
" <td>Pave</td>\n",
" <td>8</td>\n",
" <td>3.5</td>\n",
" <td>2110.0</td>\n",
" <td>0.0</td>\n",
" <td>4220.0</td>\n",
" <td>21.548042</td>\n",
" <td>AllPub</td>\n",
" <td>0.0</td>\n",
" <td>1968</td>\n",
" <td>1968</td>\n",
" <td>2010</td>\n",
" <td>244000.0</td>\n",
" <td>12.404924</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>928.0</td>\n",
" <td>6.833032</td>\n",
" <td>701.0</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>3</td>\n",
" <td>1Fam</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Gd</td>\n",
" <td>137.0</td>\n",
" <td>791.0</td>\n",
" <td>0.0</td>\n",
" <td>GLQ</td>\n",
" <td>Unf</td>\n",
" <td>Y</td>\n",
" <td>Norm</td>\n",
" <td>Norm</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>TA</td>\n",
" <td>TA</td>\n",
" <td>VinylSd</td>\n",
" <td>VinylSd</td>\n",
" <td>MnPrv</td>\n",
" <td>TA</td>\n",
" <td>1</td>\n",
" <td>PConc</td>\n",
" <td>2</td>\n",
" <td>Typ</td>\n",
" <td>482.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>Fin</td>\n",
" <td>TA</td>\n",
" <td>Attchd</td>\n",
" <td>1629.0</td>\n",
" <td>7.395722</td>\n",
" <td>1</td>\n",
" <td>GasA</td>\n",
" <td>Gd</td>\n",
" <td>2Story</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Lvl</td>\n",
" <td>Gtl</td>\n",
" <td>13830.0</td>\n",
" <td>15.946705</td>\n",
" <td>Inside</td>\n",
" <td>IR1</td>\n",
" <td>0.0</td>\n",
" <td>060</td>\n",
" <td>RL</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>3</td>\n",
" <td>Gilbert</td>\n",
" <td>34.0</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>CompShg</td>\n",
" <td>Gable</td>\n",
" <td>Normal</td>\n",
" <td>WD</td>\n",
" <td>0.0</td>\n",
" <td>Pave</td>\n",
" <td>6</td>\n",
" <td>2.5</td>\n",
" <td>928.0</td>\n",
" <td>246.0</td>\n",
" <td>2557.0</td>\n",
" <td>19.016856</td>\n",
" <td>AllPub</td>\n",
" <td>212.0</td>\n",
" <td>1997</td>\n",
" <td>1998</td>\n",
" <td>2010</td>\n",
" <td>189900.0</td>\n",
" <td>12.154253</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 1st Flr SF 1st Flr SF (box-cox-0) 2nd Flr SF 3Ssn Porch \\\n",
"Order PID \n",
"1 526301100 1656.0 7.412160 0.0 0.0 \n",
"2 526350040 896.0 6.797940 0.0 0.0 \n",
"3 526351010 1329.0 7.192182 0.0 0.0 \n",
"4 526353030 2110.0 7.654443 0.0 0.0 \n",
"5 527105010 928.0 6.833032 701.0 0.0 \n",
"\n",
" Alley Bedroom AbvGr Bldg Type Bsmt Cond Bsmt Exposure \\\n",
"Order PID \n",
"1 526301100 NA 3 1Fam Gd Gd \n",
"2 526350040 NA 2 1Fam TA No \n",
"3 526351010 NA 3 1Fam TA No \n",
"4 526353030 NA 3 1Fam TA No \n",
"5 527105010 NA 3 1Fam TA No \n",
"\n",
" Bsmt Full Bath Bsmt Half Bath Bsmt Qual Bsmt Unf SF \\\n",
"Order PID \n",
"1 526301100 1 0 TA 441.0 \n",
"2 526350040 0 0 TA 270.0 \n",
"3 526351010 0 0 TA 406.0 \n",
"4 526353030 1 0 TA 1045.0 \n",
"5 527105010 0 0 Gd 137.0 \n",
"\n",
" BsmtFin SF 1 BsmtFin SF 2 BsmtFin Type 1 BsmtFin Type 2 \\\n",
"Order PID \n",
"1 526301100 639.0 0.0 BLQ Unf \n",
"2 526350040 468.0 144.0 Rec LwQ \n",
"3 526351010 923.0 0.0 ALQ Unf \n",
"4 526353030 1065.0 0.0 ALQ Unf \n",
"5 527105010 791.0 0.0 GLQ Unf \n",
"\n",
" Central Air Condition 1 Condition 2 Electrical \\\n",
"Order PID \n",
"1 526301100 Y Norm Norm SBrkr \n",
"2 526350040 Y Feedr Norm SBrkr \n",
"3 526351010 Y Norm Norm SBrkr \n",
"4 526353030 Y Norm Norm SBrkr \n",
"5 527105010 Y Norm Norm SBrkr \n",
"\n",
" Enclosed Porch Exter Cond Exter Qual Exterior 1st \\\n",
"Order PID \n",
"1 526301100 0.0 TA TA BrkFace \n",
"2 526350040 0.0 TA TA VinylSd \n",
"3 526351010 0.0 TA TA Wd Sdng \n",
"4 526353030 0.0 TA Gd BrkFace \n",
"5 527105010 0.0 TA TA VinylSd \n",
"\n",
" Exterior 2nd Fence Fireplace Qu Fireplaces Foundation \\\n",
"Order PID \n",
"1 526301100 Plywood NA Gd 2 CBlock \n",
"2 526350040 VinylSd MnPrv NA 0 CBlock \n",
"3 526351010 Wd Sdng NA NA 0 CBlock \n",
"4 526353030 BrkFace NA TA 2 CBlock \n",
"5 527105010 VinylSd MnPrv TA 1 PConc \n",
"\n",
" Full Bath Functional Garage Area Garage Cars Garage Cond \\\n",
"Order PID \n",
"1 526301100 1 Typ 528.0 2 TA \n",
"2 526350040 1 Typ 730.0 1 TA \n",
"3 526351010 1 Typ 312.0 1 TA \n",
"4 526353030 2 Typ 522.0 2 TA \n",
"5 527105010 2 Typ 482.0 2 TA \n",
"\n",
" Garage Finish Garage Qual Garage Type Gr Liv Area \\\n",
"Order PID \n",
"1 526301100 Fin TA Attchd 1656.0 \n",
"2 526350040 Unf TA Attchd 896.0 \n",
"3 526351010 Unf TA Attchd 1329.0 \n",
"4 526353030 Fin TA Attchd 2110.0 \n",
"5 527105010 Fin TA Attchd 1629.0 \n",
"\n",
" Gr Liv Area (box-cox-0) Half Bath Heating Heating QC \\\n",
"Order PID \n",
"1 526301100 7.412160 0 GasA Fa \n",
"2 526350040 6.797940 0 GasA TA \n",
"3 526351010 7.192182 1 GasA TA \n",
"4 526353030 7.654443 1 GasA Ex \n",
"5 527105010 7.395722 1 GasA Gd \n",
"\n",
" House Style Kitchen AbvGr Kitchen Qual Land Contour \\\n",
"Order PID \n",
"1 526301100 1Story 1 TA Lvl \n",
"2 526350040 1Story 1 TA Lvl \n",
"3 526351010 1Story 1 Gd Lvl \n",
"4 526353030 1Story 1 Ex Lvl \n",
"5 527105010 2Story 1 TA Lvl \n",
"\n",
" Land Slope Lot Area Lot Area (box-cox-0.1) Lot Config \\\n",
"Order PID \n",
"1 526301100 Gtl 31770.0 18.196923 Corner \n",
"2 526350040 Gtl 11622.0 15.499290 Inside \n",
"3 526351010 Gtl 14267.0 16.027549 Corner \n",
"4 526353030 Gtl 11160.0 15.396064 Corner \n",
"5 527105010 Gtl 13830.0 15.946705 Inside \n",
"\n",
" Lot Shape Low Qual Fin SF MS SubClass MS Zoning \\\n",
"Order PID \n",
"1 526301100 IR1 0.0 020 RL \n",
"2 526350040 Reg 0.0 020 RH \n",
"3 526351010 IR1 0.0 020 RL \n",
"4 526353030 Reg 0.0 020 RL \n",
"5 527105010 IR1 0.0 060 RL \n",
"\n",
" Mas Vnr Area Mas Vnr Type Misc Feature Misc Val Mo Sold \\\n",
"Order PID \n",
"1 526301100 112.0 Stone NA 0.0 5 \n",
"2 526350040 0.0 None NA 0.0 6 \n",
"3 526351010 108.0 BrkFace Gar2 12500.0 6 \n",
"4 526353030 0.0 None NA 0.0 4 \n",
"5 527105010 0.0 None NA 0.0 3 \n",
"\n",
" Neighborhood Open Porch SF Overall Cond Overall Qual \\\n",
"Order PID \n",
"1 526301100 Names 62.0 5 6 \n",
"2 526350040 Names 0.0 6 5 \n",
"3 526351010 Names 36.0 6 6 \n",
"4 526353030 Names 0.0 5 7 \n",
"5 527105010 Gilbert 34.0 5 5 \n",
"\n",
" Paved Drive Pool Area Pool QC Roof Matl Roof Style \\\n",
"Order PID \n",
"1 526301100 P 0.0 NA CompShg Hip \n",
"2 526350040 Y 0.0 NA CompShg Gable \n",
"3 526351010 Y 0.0 NA CompShg Hip \n",
"4 526353030 Y 0.0 NA CompShg Hip \n",
"5 527105010 Y 0.0 NA CompShg Gable \n",
"\n",
" Sale Condition Sale Type Screen Porch Street TotRms AbvGrd \\\n",
"Order PID \n",
"1 526301100 Normal WD 0.0 Pave 7 \n",
"2 526350040 Normal WD 120.0 Pave 5 \n",
"3 526351010 Normal WD 0.0 Pave 6 \n",
"4 526353030 Normal WD 0.0 Pave 8 \n",
"5 527105010 Normal WD 0.0 Pave 6 \n",
"\n",
" Total Bath Total Bsmt SF Total Porch SF Total SF \\\n",
"Order PID \n",
"1 526301100 2.0 1080.0 272.0 2736.0 \n",
"2 526350040 1.0 882.0 260.0 1778.0 \n",
"3 526351010 1.5 1329.0 429.0 2658.0 \n",
"4 526353030 3.5 2110.0 0.0 4220.0 \n",
"5 527105010 2.5 928.0 246.0 2557.0 \n",
"\n",
" Total SF (box-cox-0.2) Utilities Wood Deck SF Year Built \\\n",
"Order PID \n",
"1 526301100 19.344072 AllPub 210.0 1960 \n",
"2 526350040 17.333478 AllPub 140.0 1961 \n",
"3 526351010 19.203658 AllPub 393.0 1958 \n",
"4 526353030 21.548042 AllPub 0.0 1968 \n",
"5 527105010 19.016856 AllPub 212.0 1997 \n",
"\n",
" Year Remod/Add Yr Sold SalePrice SalePrice (box-cox-0) \n",
"Order PID \n",
"1 526301100 1960 2010 215000.0 12.278393 \n",
"2 526350040 1961 2010 105000.0 11.561716 \n",
"3 526351010 1958 2010 172000.0 12.055250 \n",
"4 526353030 1968 2010 244000.0 12.404924 \n",
"5 527105010 1998 2010 189900.0 12.154253 "
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 7,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Newly created variables are collected in the *new_variables* list."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 8,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables = []"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Derived Characteristics\n",
"\n",
"Certain characteristics of a house are assumed to have a \"binary\" influence on the sales price. For example, the existence of a pool could be an important predictor while the exact size of the pool can be deemed not so important.\n",
"\n",
"The below cell creates boolean factor variables out of a set of numeric variables."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 9,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"derived_variables = {\n",
" \"has 2nd Flr\": \"2nd Flr SF\",\n",
" \"has Bsmt\": \"Total Bsmt SF\",\n",
" \"has Fireplace\": \"Fireplaces\",\n",
" \"has Garage\": \"Garage Area\",\n",
" \"has Pool\": \"Pool Area\",\n",
" \"has Porch\": \"Total Porch SF\",\n",
"}\n",
"# Factorize numeric columns.\n",
"for factor_column, column in derived_variables.items():\n",
" df[factor_column] = df[column].apply(lambda x: 1 if x > 0 else 0)\n",
"derived_variables = list(derived_variables.keys())"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 10,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.extend(derived_variables)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 11,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>has 2nd Flr</th>\n",
" <th>has Bsmt</th>\n",
" <th>has Fireplace</th>\n",
" <th>has Garage</th>\n",
" <th>has Pool</th>\n",
" <th>has Porch</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" has 2nd Flr has Bsmt has Fireplace has Garage has Pool \\\n",
"Order PID \n",
"1 526301100 0 1 1 1 0 \n",
"2 526350040 0 1 0 1 0 \n",
"3 526351010 0 1 0 1 0 \n",
"4 526353030 0 1 1 1 0 \n",
"5 527105010 1 1 1 1 0 \n",
"\n",
" has Porch \n",
"Order PID \n",
"1 526301100 1 \n",
"2 526350040 1 \n",
"3 526351010 1 \n",
"4 526353030 0 \n",
"5 527105010 1 "
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 11,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[derived_variables].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2nd Floors\n",
"\n",
"A second floor may have a positive effect on the sales price. However, having a second floor correlates with overall living space. The individual effect is therefore not as clear as it seems in the plot below."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 12,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAA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xyntNLE0h3HmfrH/nM6Y5WXl4fJZMLb29vmvLe39wU5sdGiQZWXlxe+vr7Wj2XLltGqVSt69OhBUVERCxcu5Pnnn6d3797ExcXx5ptvsmXLFrZu3QrAypUrSUpK4t133yU2Npb+/fvz+OOPM2/ePCorKwGYP38+ISEhPP/880RFRTFq1CgGDRrE7NmzreM41dRiU8YihBBCXMrySo0s35dlc+7vfVnklRpbaEQXngsmp6qyspIffviBESNGoNFo2LlzJ0aj0WbKLyoqiqCgIGsgs3XrVtq2bYuPj4/1msTERIqLi0lKSrJe07t3b5tnJSYmWu/RlKnFpoxFCCGEuJR5OunpH+1rc25AtC+eTvpz90xPT3Q6XYOk9JycHJvf/ReKCyao+uOPPygqKmLYsGEAZGdno9frcXNzs7nO29ubrKws6zX1v6k1x6e6pri4mPLy8iZNLTZlLEIIIcSlzF6v48mr2jK4QwBOBh2DOwTwxFVtsdfrztkzDQYD7du3Z82aNdZzZrOZNWvW0Llz53P23DNl19IDqLFw4UL69euHv79/Sw9FCCGEEI1o6+/Kf26JJ6/UiKeT/pwGVDXGjBnDhAkTiIuLo2PHjsy
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"has 2nd Flr\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Basements\n",
"\n",
"Nearly all houses in Ames, IA, have a basement. Therefore, *has Bsmt* is most likely not an important predictor."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 13,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGli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w77//vtU17OwsqVazE3rB92IwGMjNzeVao6JKURRFUUqLRwB41LI+17hXxezlKrF3715MJhNjxowhJCSEunXrEhUVVWRd9erVeeihh/j000/z67NKg3l4ccG6qapVq9K7d2+mTJnC2LFj+emnn67ovdjZ2V0TkaXpP0VRFEUpLa6+0H82rJ4M53ZBm8ehyX0VvatypXbt2mRlZTFnzhy6devGtm3bmDdvntWa9957j65du1KnTh0SExPZtGkTgYGBl7xueno60dHRAMTGxvL555/j4OCQX8f18ccf07RpU+rXr09mZiarV6++7DUvR40aNVi3bh1Hjx7F09MTNzc3q2hXeaGiSlEURVHKQo1W8OB3kJECLl4VvZtyp1GjRrz22mt89dVXfPTRR7Rp04aXXnqJ0aNH56/Jzc3lnXfe4dy5c7i6utKlSxdee+21S153/vz5+dEsDw8PGjZsyJdffkm9evUAiSp99NFHnDlzBkdHR1q3bs1HH310Re+lf//+bN68mb59+5Kamsp3331H+/btr+iaxWEwmZOnylUnOTmZ1q1bs23bNlxdXSt6O4qiKMpNTHp6OseOHaNu3bo4OjpW9Hauey71eZX0+1trqhRFURRFUcoBFVWKoiiKoijlgIoqRVEURVGUckBFlaIoiqIoSjmgokpRFEVRFKUcUFGlKIqiKIpSDqioUhRFURRFKQdUVCmKoiiKopQDKqoURVEURVHKARVViqIoiqLckMydO5du3brRrFkz+vXrx65duyp0PyqqFEVRFEW54Vi2bBmTJk3i2WefZfHixTRq1IihQ4cSGxtbYXtSUaUoiqIoyhWTkZXDuYR0MrJyrsn9Zs6cSf/+/enbty9BQUGMHz8eR0dHFi5ceE3uXxwVKqq6detGw4YNizzGjx8PQEZGBuPHj6d9+/a0bNmS5557jpiYGKtrREZGMmzYMFq0aEHHjh15//33yc7OtlqzadMmevfuTXBwMLfffjuLFi0qspfLhRBLshdFURRFqYwcOp/EC/PD6fa/1bwwP5xD55Ou6v0yMzPZu3cvnTp1yj9nNBrp1KkTO3bsuKr3vhQVKqoWLFjAunXr8h8zZ84EoEePHgBMnDiRVatWMXXqVObMmUNUVBQjRozIf31OTg7Dhw8nKyuLefPmMXnyZBYvXsy0adPy15w6dYrhw4fTvn17fv31Vx577DHeeOMN1q5dm7+mJCHEy+1FURRFUSojGVk5/N/KQyzffY7UzByW7z7H1JWHrmrE6sKFC+Tk5ODl5WV13svLq0IDHhUqqqpWrYqPj0/+Y9WqVdSqVYt27dqRlJTEwoULGTNmDB07diQ4OJiJEyeyY8cOwsPDAVi3bh0RERF8+OGHNG7cmLCwMJ5//nnmzp1LZmYmAPPmzSMgIIAxY8YQGBjIoEGDuPPOO5k1a1b+Pi4XQizJXhRFURSlMnIhNYs1B6Otzq0+GM2F1KwK2lHFcd3UVGVmZvLbb7/Rt29fDAYDe/bsISsryyq0FxgYiL+/f76QCQ8Pp0GDBnh7e+evCQ0NJTk5mYiIiPw1HTt2tLpXaGho/jVKEkIsyV4URVEUpTJSxdmOsIY+VuduaehDFWe7q3fPKlWwsbEpUpQeGxtrpQmuNdeNqFq5ciVJSUn07t0bgJiYGOzs7HB3d7da5+XlRXR0dP6awh+e+fhya5KTk0lPTy9RCLEke1EURVGUyoiDnQ0vdm9Az2Z+ONvb0LOZHy90b4CDnc1Vu6e9vT1NmzZlw4YN+edyc3PZsGEDLVu2vGr3vRy2FXb
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"has Bsmt\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Fireplaces\n",
"\n",
"Bigger houses are more likely to have a fireplace. Thus, the variable *has Fireplace* might be an interesting predictor."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 14,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAA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roq/Lzc3Fzs7uaoZ2Q6HlP0VRFKVqY+9ufWwwgrHycg4mk4kPPviAtm3b0rFjRz777DOr56dOnUrv3r0JCwujS5cujB49mvT09MLnT58+zeOPP06bNm0ICwvjzjvvZOXKlRe9p6OjI76+vlYPKFn+a9iwIT/99BOPP/44YWFhTJ48GYDly5fTp08fmjVrxq233srnn39OXl5eidc9+uijNG/enFtvvZWlS5deMJ78/Hxee+01unXrRvPmzenRowfTp08vsW727NnceeedhIaGEhkZydixYwufS0lJ4fXXX6d9+/a0bNmSIUOGsH///ot+DleKiipFURSlahM2EBzcLMedXgTvBmV7beY5OHcS8svvbVScefPm4ezszKxZs3jppZf44osvWLNmTeHzBoOB119/nYULFzJhwgTWr1/Phx9+WPj82LFjycnJ4ccff2TBggW8+OKLFWoy+vnnn3PbbbexYMEC+vXrx+bNmxk1ahRDhgxh8eLFjB07lrlz5xYKLjOffvopPXr04LfffqN37948//zzHDlypNR7FBQU4O/vz6effsqiRYt46qmn+O9//8vixYsL1/z000+MHTuWAQMGsGDBAv73v/9Rq1atwuefffZZEhIS+Prrr5k7dy5NmzbloYceIikpqcI+ixKYlGtGamqqKSQkxJSamlrZoSiKoihFid1vMu2eZzIdW2UyZaaU7TXHVptMn7UxmUZ7mkzznzKZEo+X6WWZmZmmvXv3mjIzM0s8N3jwYNP9999vda5fv36mDz/88ILXW7Jkialt27aFx3fddZfps88+K9t7OH/Ppk2bmsLCwgof48ePN5lMJtMtt9ximjp1auHakJAQ07vvvmv1+oceesg0efJkq3Pz5883dezY0ep1b731ltWa/v37m95++22TyWQyRUVFmUJCQkx79+69YJxjxowxPfPMM4XHkZGRpk8++aTUtZs2bTK1bNnSlJ2dbXW+e/fuppkzZ5b6mov9Xsr6/a09VYqiKIri21AeZSX5NPw6BNLj5XjbD+BdHyKfu+JQGja0jsPX15eEhITC47Vr1zJlyhSOHj1KWloa+fn5ZGdnk5mZiZOTE0OGDGH06NGsXr2aiIgIbr/9dho1anTRe/bu3ZvHH3+88NjNze2Ca0NDQ62O9+/fz9atW60yU8VjAggPD7d6XVhY2EV3+82YMYM5c+Zw5swZsrOzyc3NLXwfCQkJxMbG0qFDh1Jfe+DAATIyMmjXrp3V+aysLE6ePHnBe14pKqoURVEU5XJJi7EIKjOH/6oQUWVra/3VbDAYMJlMgFgPjBgxgvvvv5/nnnsODw8PtmzZwuuvv05ubi5OTk7079+fyMhI/vnnH9asWcNXX33FqFGjePDBBy94T1dXV2rXrl2m+IqXEjMyMnjmmWe4/fbbS6x1cHAo0zWLs2jRIt5//31GjRpFeHg4Li4ufPvtt+zYsaNM101PT8fX15cffvihxHMXE4xXiooqRVEURblcPILAoxYkF8l6NO591W+7Z88eTCYTr7zyCkajtEUvWbKkxLqAgADuv/9+7r//fj7++GNmzZp1UVF1JTRp0oRjx45dUpRt376de++9t/B4x44dNG7cuNS1W7duJTw8nEGDBhWeK5phcnV1pUaNGqxbt4727duXeH3Tpk2Jj4/HxsaGoKCgy3xH5Ucb1RVFURTlcnH1gwHToUEPcAuAW16HJvdc9dvWrl2b3NxcfvjhB6Kiopg/fz4zZ860WvPuu++yatUqoqKi2LNnDxs2bKB+/fpXLaannnqK3377jc8//5xDhw5x5MgRFi1axH//+1+rdUuXLmX27NkcO3aMSZMmsXPnTgYPHnzB97l7925WrVrFsWPHmDhxIrt27bJa88wzzzB16lS+//57jh8/zp49ewozUxEREYSFhfHUU0+xevVqTp06xdatW/nvf/9b4joViWaqFEVRFKU81GgJ930P2eng4n1NbtmoUSNeffVVvv76az755BNat27N888/z6hRowrXFBQUMHbsWM6ePYurqyudOnXi1VdfvWoxderUicmTJ/PFF1/w9ddfY2trS7169ejfv7/VumeeeYbFixczZswYfH19+fjjjwkODi71mgMHDmTfvn0899xzGAwG7rzzTh544AH+/fffwjV9+vQhOzubadOm8cEHH+Dp6UnPnj0BKZl+9dVXTJw4kVdffZVz587h4+ND69at8fHxuWqfhcFkLtQqV520tDRatWrFli1bcHV1rexwFEVRlEogKyuLY8eOUbduXRwdHSs7nGtCw4YN+eKLL+jevXtlh3JBLvZ7Kev3t5b/FEVRFEVRKgAVVYqiKIqiKBWA9lQpiqIoinJVOXDgQGWHcE3QTJWiKIqiKEoFoKJKURRFURSlAlBRpSiKoiiKUgGoqFIURVEURakAVFQpiqIoiqJUACqqFEVRFEVRKgAVVYqiKIqiVDozZsygW7duNGvWjP79+7Nz587KDumyUVGlKIqiKEqlsnjxYsaPH89TTz3FvHnzaNSoEcOGDSMhIaGyQ7ssVFQpiqIoimJFdm4+Z5OzyM7Nvyb3mzp1KgMGDKBfv34EBwczZswYHB0dmTNnzjW5f0VRqaKqW7duNGzYsMRjzJgxAGRnZzNmzBjatWtHeHg4zzzzDPHx8VbXOHPmDMOHD6dFixZ06NCB999/n7y8PKs1GzZsoE+fPoSGhnLbbbcxd+7cErFcKu1YllgURVEU5UbnYEwq/zdrO90+/of/m7WdgzGpV/V+OTk57Nmzh4iIiMJzRqORiIgItm3bdlXvXdFUqqiaPXs2q1evLnxMnToVgJ49ewLw3nvvsWLFCiZOnMgPP/xAbGwsTz/9dOHr8/PzGTFiBLm5ucycOZMJEyYwb948Jk2aVLgmKiqKESNG0K5dO3777Tceeugh3njjDVatWlW4pixpx0vFoiiKoig3Otm5+fx3+UGW7DpLRk4+S3a
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"has Fireplace\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Garages\n",
"\n",
"Holding the overall living area fixed adding a garage seems to affect the price positively. Thus, *has Garage* seems like an interesting predictor as well."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 15,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image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AA/fr14z//+Q9PPfUUQKHPVe3atfn222/Jz89n5MiR9O3bl8mTJ+Pq6nrJzsXKwGAyJ1+Vq05qaipt27Zl+/btJYr1FEVRFKU4mZmZhd1qjo6OVb2d65affvqJV199lW3btlX4c7rcZ13W728tVFcURVEU5YZi6dKl+Pv7U7t2bQ4dOsS0adPo3bt3lQtPFVWKoiiKotxQxMXFMWPGDOLi4vD29qZ37948//y17bwsDRVViqIoiqLcUDz22GNWJqLXC1qoriiKoiiKUgmoqFIURVEURakEVFQpiqIoiqJUAiqqFEVRFEVRKgEVVYqiKIqiKJWAiipFURRFUZRKQEWVoiiKoijXJfPnz6d79+60bNmSQYMGsXv37qre0mVRUaUoiqIoynXHypUrmTJlCk899RRLliyhadOmjBw5koSEhKre2iVRUaUoiqIoyhXJysnjXFImWTl51+R+s2fPZvDgwQwcOJCgoCAmTpyIo6MjixYtuib3rwhVKqq6d+9OkyZNSjwmTpwIQFZWFhMnTqRjx460adOGp59+mvj4eKtrREdHM2rUKFq3bk1YWBjvvvsuubm5Vmu2bNlC//79CQkJ4fbbb2fx4sUl9nKlEGNZ9qIoiqIoNyOHz6fw3MJIun/wJ88tjOTw+ZSrer/s7Gz27dtH586dC88ZjUY6d+7Mzp07r+q9/wlVKqp++OEH1q9fX/iYPXs2AL179wZg8uTJrFmzhunTpzNv3jxiY2MZM2ZM4evz8vIYPXo0OTk
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"has Garage\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pools\n",
"\n",
"Unfortunately, almost no one in Ames, IA, has a pool. The predictor *has Pool* seems quite uninteresting."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 16,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3iUVfbA8e/UzEwmvffeIITQIQRQRMEuYhdRRMXeu+uKyiqW3WV1/a1YwIYiimLFjgjSS+gtJCG910mZTPv9MTAwhBIgEsr5PI+PzjvvvO/NIDMn9557jsLhcDgQQgghhBDHRdndAxBCCCGEOB1IUCWEEEII0QUkqBJCCCGE6AISVAkhhBBCdAEJqoQQQgghuoAEVUIIIYQQXUCCKiGEEEKILqDu7gGcSex2O5WVlXh6eqJQKLp7OEIIIYToBIfDQXNzM8HBwSiVh56PkqDqBKqsrGTEiBHdPQwhhBBCHINFixYRGhp6yOclqDqBPD09AecfitFo7ObRCCGEEKIzTCYTI0aMcH2PH4oEVSfQ3iU/o9EoQZUQQghxijlS6o4kqgshhBBCdAEJqoQQQgghuoAEVUIIIYQQXUByqoQQQogzmM1mw2KxdPcwupVGo0GlUh33dSSoEkIIIc5ADoeD8vJy6uvru3soJwVfX19CQ0OPq46kBFVCCCHEGWhvQBUcHIzBYDhji1I7HA5aWlqorKwEICws7JivJUGVEEIIcYax2WyugCogIKC7h9Pt9Ho94CzSHRwcfMxLgZKoLoQQQpxh9uZQGQyGbh7JyWPve3E8+WUSVAkhhBBnqDN1ye9guuK9kKBKCCGEEKILSFAlhBBCCNEFJKgSQghxRrPZHawuqOWDZQV8t6GUysa27h5St7vhhhv4xz/+0d3D6HIpKSn88ssvf9n1ZfefEEKIM9ryvBpueHcFdofz8WWZEbxweToGrXxFnkg33HADK1euBECr1RIVFcX111/P9ddf380j6zyZqRJCCHFG+2xNsSugApifU0JeVXP3DegMdtVVV7FkyRK+//57zj//fJ577jm+/fbb7h5Wp0lQJYQQ4ozm5eFek0ipALVKdsU5HA5efvllBg4cyNChQ3n99dfdnp81axYXX3wxmZmZjBgxgilTptDcvC8YLSkp4fbbb2fAgAFkZmZy4YUXsmjRosPeU6fTERQURFRUFPfccw+xsbH89ttvAJSWlnLHHXfQp08f+vbty3333Ud1dbXb6z/++GNGjRpFeno6o0ePZv78+V3zZnSSBFVCCCHOaJf3jcTosW+p7+6zE4kPNHbuxa11UFcIttOvd96XX36JwWBg7ty5PPLII7zxxhv8+eefrucVCgVPPfUU3377LdOmTWP58uW88sorruefe+452tvb+eijj/jmm294+OGHj7ouloeHBxaLBbvdzp133klDQwMffvghs2bNoqioiAceeMB17s8//8wLL7zAxIkT+eabb7jmmmt48sknWb58+fG/GZ0kC8ZCCCHOaH2i/Zh/VxY7Kprw9/QgPdwHrboTcw4Ff8K3D0DNTsi8HoY/An4xf/2AT5CUlBTuvvtuAGJjY/noo49YtmwZQ4cOBeCmm25ynRsZGcn999/PM888w5QpUwDnzNLo0aNJSUkBICoqqtP3ttlsfPvtt2zfvp2rr76aZcuWsWPHDn799VdXG5mXX36ZCy+8kA0bNpCRkcG7777L2LFjXTlYcXFx5OTkMHPmTAYPHny8b0enSFAlhBDijJcY7EVisFfnX9BQAp9NgOY9y0/rPoSABMh+4PCvO4XsDYb2CgoKoqamxvV46dKlzJgxg7y8PEwmEzabDbPZTGtrK3q9ngkTJjBlyhSWLFlCVlYW5513HqmpqYe95yeffMLnn3+OxWJBqVRy0003ce211/LRRx8RGhrq1pcvMTERb29v8vLyyMjIIC8vj6uvvtrten379uWDDz7ognejc2T5TwghhDhapop9AdVeub92z1j+Imq1+7yLQqHA4XBm9BcXFzN58mRSUlJ4/fXX+eKLL/j73/8O7GvzcuWVV/LLL79w6aWXsmPHDq644go+/PDDw97z4osvZv78+fz666/k5OTwxBNPoFSeOqHKqTNSIYQQ4mThEwk+0e7H0i7unrF0g82bN+NwOHj88cfJzMwkLi6OysrKDueF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Hix65zOTBseaSxCCCGEcM5Q/fuXHSzYWE5Lu40FG8uZ/suOv2zGqq6uDpvNRkBAgNvxgICAEz750a1Blb+/P0FBQa5/Fi5cSHR0NAMHDqSpqYl58+bx+OOPM2TIENLT03nhhRdYt24dOTk5ACxZsoTc3FxeeeUV0tLSGDFiBPfddx+zZ8+mvb0dgDlz5hAZGcnjjz9OQkIC48ePZ/To0bz33nuucRxp2rAzYxFCCCEE1LVYWLS9yu3Y79urqGuxdNOITpyTJqeqvb2dr7/+mnHjxqFQKNi0aRMWi8VtOi8hIYHw8HBXIJOTk0NycjKBgYGuc7KzszGZTOTm5rrOGTJkiNu9srOzXdfozLRhZ8YihBBCCPAzaBiREuR27KyUIPwMmr/mfn5+qFSqDknpNTU1bvHBiXDSBFW//PILTU1NjB07FoDq6mo0Gg3e3t5u5wUEBFBVVeU658A3bO/jI51jMploa2vr1LRhZ8YihBBCCPDQqHhgVDIX9ArFoFVxQa9Q7h+VjIdG9ZfcT6vV0rNnT5YtW+Y6ZrfbWbZsGX369PlL7nko6hN6t8OYN28ew4cPJyQkpLuHIoQQQojjkBzixb+vyqSuxYKfQfOXBVR7TZw4kccee4z09HQyMjJ4//33aW1t5fLLL/9L73ugkyKoKikpYenSpbz++uuuY4GBgVgsFhobG91miGpqaggKCnKdc+Auvb2zS/ufc2CiWnV1NUajEZ1Oh1KpPOK0YWfGIoQQQoh9PDQqQn3+2mBqrwsuuIDa2lpee+01qqqqSEtL451
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"has Pool\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Porch\n",
"\n",
"Most houses have a porch."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 17,
2021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Sq3lYmHE8qxFURRFUaobB86m8e852+j+wd/8e842DpxNu6L3y83NZffu3URGRhbtMxqNREZGsnXr1it674tRpaLqp59+YtWqVUWv6dOnA9CzZ08Axo8fz/Lly5k8eTLffvstcXFxjBgxouh8k8nE8OHDycvLY/bs2UycOJH58+czZcqUomNiYmIYPnw4HTp04Oeff+aRRx7h9ddfZ+XKlUXHlCeMeLG1KIqiKEp1IyfPxP8tPcDinWfIzDWxeOcZJi89cEUjVufOncNkMuHr62uz39fXt8qDHVUqqnx8fPD39y96LV++nLp169K+fXvS0tKYO3cuL7/8Mp06dSIsLIzx48ezdetWtm3bBsCqVas4dOgQ77//Ps2aNSM6Oppnn32WWbNmkZubC8Ds2bMJDg7m5ZdfJiQkhEGDBnH77bfz9ddfF63jYmHE8qxFURRFUaob5zLzWLE/3mbf3/vjOZeZV0UrqlqumZqq3NxcfvnlF/r27YvBYGDXrl3k5eXZhPdCQkIICgoqEjLbtm2jcePG+Pn5FR0TFRVFeno6hw4dKjqmU6dONveKiooqukZ5wojlWYuiKIqiVDdquDoQ3cTfZl+3Jv7UcHW4cvesUQM7O7tSRemJiYk2eqAquGZE1dKlS0lLS6NPnz4AJCQk4ODggKenp81xvr6+xMfHFx1T8gO0bF/smPT0dLKzs8sVRizPWhRFURSluuHkYMdzPRrTq2Ugro529GoZyL97NMbJwe6K3dPR0ZEWLVqwdu3aon0FBQWsXbuWiIiIK3bf8mBfpXcvxty5c+natSs1a9as6qU
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"has Porch\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Neighborhoods\n",
"\n",
"The instructors' notes say:\n",
"\n",
"> For instructors who cover nominal variables in their class, I would suggest incorporating the neighborhood variable into their models by converting it to a set of dummy (indicator) variables. I have found that the coefficients for the continuous variables tend to have values with more realistic interpretations when used in conjunction with the neighborhood variable.\n",
"\n",
"Indeed, plotting the price distributions by neighborhood reveals significant differences in the price level."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 18,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4EAAAL/CAYAAADY9cLJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeVhUZf8G8JsZWYRREEEB7TXQ3EASLRVErGwlzS3UQiv3BNPKXF5FkUKl0jIL1NwX1FxQMrHNFjRGTIUQTFNBs1gEEQSRbWZ+f/ib884IyDAMszD357q8ZM55OOcBBj33eZ7zfSwUCoUCREREREREZBZEhu4AERERERER6Q9DIBERERERkRlhCCQiIiIiIjIjDIFERERERERmhCGQiIiIiIjIjDAEEhERERERmRGGQCIiIiIiIjPCEEhERERERGRGGAKJiIiIiIjMCEMgEVEtFixYgG7duqFbt26Ii4szdHeMHr9fhhcXFyf8DBYsWKDXcyvP261bN50d86mnnhKO+c8//+jsuMagKb5fzRH/XSFqOi0M3QEiovtNmDABp06dqnO/ra0t2rRpg27dusHPzw8jRoxAq1at9NhDau7ufw+6urri+++/h5WVVb2f+/nnn+OLL74AAAQGBuLTTz9tsn4SERFpgyOBRGRyysrK8O+//+Knn35CZGQknnjiCRw6dMjQ3aJmLCcnB3v27DF0N4iIiHSCI4FEZNR69eoFb29v4bVCocDt27eRnp6Oq1evAgBKS0sxf/58VFRUYOzYsQbqKTV369evR1BQEFq2bGnorhARETUKQyARGbXBgwfjrbfeqnXfDz/8gP/+978oKSkBAERGRmLw4MFwcXFp9HmjoqIQFRXV6ONQ81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lu3bvC19arVy906dIFVVVVOHfuHK5evYrPP/9cq9HOuLg4LF26FADg7u4OLy8v2NjYIDMzE2fPnoVCoUBRURFmzJiBo0eParTG57Fjx7B8+XIA934v+vbtC1tbW1y9ehVnz56FXC5HcXExZs+ejbVr12LQoEF1HmvTpk346KOPhNdWVlbo168fXF1dcfv2bSQnJ6OoqAgymQzbtm1DTk4O1qxZU+cNF1UrVqwQAmDXrl3RvXt3tGjRAlevXq3zZ6ar75dcLsdbb70ljEYCgIODA/r16wd7e3vk5OQgOTkZVVVVuH37NhYsWIDbt2/j9ddfr/Pr+f333zF16lS194q3tzc6d+6Mqqoq/PHHH0I4/O233/DKK69g9+7ddQbBqqoqTJ8+Hb///ruwzdnZGY899hjs7Ozw999/48yZMzhz5gxmzpyJjh071tk3ImochkAiMnlnz54VPn7QRcOePXtQXV2N5557DkuXLlW7UJHL5TXunNentLQUM2fOFAJgmzZtEBYWhhdffLHGBWNZWRmOHTtW5zOLX3zxhRAAnZ2dsWTJEjzzzDM1jnP06FEsXrwYJSUl2Lt3L3x9fREYGKjW5sCBA0IA7NKlCz7//HN4eHjUOKdCocC5c+cQFxenk9ElpXXr1qGqqgrDhg3D0qVL1YJ5cXExwsLC8P333wttBw0ahD59+qgdY+jQoYiKikJZWRlOnTqF69ev46GHHqrznJcvX0ZqaioAwNbWFi+++KLOvh6lp556Co8++ij++OMPlJeXY926dUJQ1cb+/fuFACiRSLBgwQKMGDEClpaWau1OnjyJefPmIS8vD8ePH8emTZswdepUrc5ZUVGB+fPnCxf1HTt2xKefflpjOnBCQgIWLlyoVYXc8PBwODo64sMPP0RAQIDavt9//x1vvvkmSktLkZ+fj23btmk02vjxxx9DJBJh3rx5eP3119UC1eXLl/H222/j0qV
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 1000x800 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"_, ax = plt.subplots(figsize=(10, 8))\n",
"sns.boxplot(x=\"Neighborhood\", y=\"SalePrice\", data=df, ax=ax)\n",
"ax.set_title(\"Prices by Neighborhood\", fontsize=24)\n",
"ax.set_xlabel(\"Neighborhood\", fontsize=18)\n",
"ax.tick_params(axis='x', labelrotation = 45)\n",
2021-05-25 08:22:14 +02:00
"ax.set_ylabel(\"House Price\", fontsize=18);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The 28 neighborhoods are encoded as factor variables."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 19,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"neighborhood = pd.get_dummies(df[\"Neighborhood\"], prefix=\"nhood\", dtype=int)\n",
2021-05-25 08:22:14 +02:00
"df = pd.concat([df, neighborhood], axis=1)\n",
"del df[\"Neighborhood\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 20,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.extend(neighborhood.columns)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 21,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2898, 28)"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 21,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[neighborhood.columns].shape"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 22,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>nhood_Blmngtn</th>\n",
" <th>nhood_Blueste</th>\n",
" <th>nhood_BrDale</th>\n",
" <th>nhood_BrkSide</th>\n",
" <th>nhood_ClearCr</th>\n",
" <th>nhood_CollgCr</th>\n",
" <th>nhood_Crawfor</th>\n",
" <th>nhood_Edwards</th>\n",
" <th>nhood_Gilbert</th>\n",
" <th>nhood_Greens</th>\n",
" <th>nhood_GrnHill</th>\n",
" <th>nhood_IDOTRR</th>\n",
" <th>nhood_Landmrk</th>\n",
" <th>nhood_MeadowV</th>\n",
" <th>nhood_Mitchel</th>\n",
" <th>nhood_Names</th>\n",
" <th>nhood_NoRidge</th>\n",
" <th>nhood_NPkVill</th>\n",
" <th>nhood_NridgHt</th>\n",
" <th>nhood_NWAmes</th>\n",
" <th>nhood_OldTown</th>\n",
" <th>nhood_SWISU</th>\n",
" <th>nhood_Sawyer</th>\n",
" <th>nhood_SawyerW</th>\n",
" <th>nhood_Somerst</th>\n",
" <th>nhood_StoneBr</th>\n",
" <th>nhood_Timber</th>\n",
" <th>nhood_Veenker</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" nhood_Blmngtn nhood_Blueste nhood_BrDale nhood_BrkSide \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_ClearCr nhood_CollgCr nhood_Crawfor nhood_Edwards \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_Gilbert nhood_Greens nhood_GrnHill nhood_IDOTRR \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 1 0 0 0 \n",
"\n",
" nhood_Landmrk nhood_MeadowV nhood_Mitchel nhood_Names \\\n",
"Order PID \n",
"1 526301100 0 0 0 1 \n",
"2 526350040 0 0 0 1 \n",
"3 526351010 0 0 0 1 \n",
"4 526353030 0 0 0 1 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_NoRidge nhood_NPkVill nhood_NridgHt nhood_NWAmes \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_OldTown nhood_SWISU nhood_Sawyer nhood_SawyerW \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_Somerst nhood_StoneBr nhood_Timber nhood_Veenker \n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 "
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 22,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[neighborhood.columns].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Nominal Features\n",
"\n",
"This section investigates the rest of the nominal variables with regard to which realizations / encoding might be a useful predictor."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 23,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Alley Type of alley access to property\n",
"Bldg Type Type of dwelling\n",
"Central Air Central air conditioning\n",
"Condition 1 Proximity to various conditions\n",
"Condition 2 Proximity to various conditions (if more than one is present)\n",
"Exterior 1st Exterior covering on house\n",
"Exterior 2nd Exterior covering on house (if more than one material)\n",
"Foundation Type of foundation\n",
"Garage Type Garage location\n",
"Heating Type of heating\n",
"House Style Style of dwelling\n",
"Land Contour Flatness of the property\n",
"Lot Config Lot configuration\n",
"MS SubClass Identifies the type of dwelling involved in the sale.\n",
"MS Zoning Identifies the general zoning classification of the sale.\n",
"Mas Vnr Type Masonry veneer type\n",
"Misc Feature Miscellaneous feature not covered in other categories\n",
"Roof Matl Roof material\n",
"Roof Style Type of roof\n",
"Sale Condition Condition of sale\n",
"Sale Type Type of sale\n",
"Street Type of road access to property\n"
]
}
],
"source": [
"print_column_list(set(NOMINAL_VARIABLES) - set([\"Neighborhood\"]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Alleys\n",
"\n",
"Almost no house has access to an alley."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 24,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hU1dbA4d/MZFInvTdSSYEQQm8BpAmioIAgCqLIFUQpNgSxgaLgtVzEBjZEQRGpghRFAUE6JPQQQgIEQnrvk8x8f8zHwTHUEAhlvc/Dc5l99tlnTbhm1uyzz9oqo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GxurjFFZWcmhQ4fMrqNWq2nfvj1xcXEAVxSLEEIIcStyttXSOdzdrO2ucHecba/fYvAGDRqgUqlISUkxa/f39ycgIABra2uz9gvdIuzTpw8rV64EYNWqVcTGxuLs7HzdYr4SN01StX79eoqKiujXrx8A2dnZaLVaHBwczPq5urqSlZWl9PlnQgUory/Xp7i4mPLycvLy8qiursbV1bXGdc6tmbqSWIQQQohbkZVWw3Pdw+jdxAtbSw29m3jxbPew67pY3dnZmQ4dOjB//nxKS0trNcZ9993HsWPHOHjwIOvWraNv3751HOXVu2me/luyZAmdOnXC09OzvkMRQggh7ihhnvb8b1DMDX3674033uDhhx9mwIABjB07lvDwcFQqFQcOHCA5OZnGjRtf8nw/Pz+aNWvGK6+8QnV1NV27dr3uMV/OTZFUnTlzhq1bt/Lxxx8rbW5ubuj1egoLC81miHJycnB
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Alley\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 25,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Alley\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Building Type\n",
"\n",
"The type of a building clearly affects the valuation. The two types of townhouses as well as the 2-family condo and duplex type are summarized into a single category. This makes sense a) semantically, and b) by looking at the two sub-clusters in the scatter plot."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 26,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnN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fV6I2U1elztldgqFVf8eX369KFPnz4XbKNWq/H09Gxw/J133uHPP/8kPz8fDw8PBg8ezKRJk1AqlcDpPf9Gjx7NRx99REVFBXfccQcvvfQSX3zxBYsWLcJkMjFmzBgeeeSRK/L+roRWnVPVr18/oqKiGvyZMWMGAPX19cyYMYOuXbuSkJDAlClTKC4utrpHbm4u48ePp0OHDnTv3p233noLg8Fg1SY5OZmhQ4cSGxvLzTffzKpVqxrEsnTpUvr160f79u2566672Lt3r9X5xsQiCIIgCFfC0YIqHl+RQr/31vP4ihSOFlS1dkgX5ODgwKxZs/j555954YUX+Pbbb1m0aJFVmxMnTvDPP/+wYMEC3nvvPb777jvGjx9PQUEBS5YsYdq0acyZM4c9e/a0zptoglZNqr777js2bdok/Vm4cCEAAwYMAODNN99k3bp1zJkzhyVLllBYWGjVBWk0GpkwYQJ6vZ7ly5cze/ZsVq9ezdy5c6U2WVlZTJgwga5du/L9999z//338+KLL7Jx40apzS+//MKsWbOYNGkSq1evJjo6mnHjxlFSUiK1uVgsgiAIgnAl1OuN/O/Po6zdl0+NzsjaffnM+fMo9Xpja4fGsmXLSEhIkP7Mnj0bgEcffZSOHTsSEBBAv379ePDBB1m7dq3VtWazmTfffJO
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Bldg Type\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 27,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"# Unify the two townhouse types into one.\n",
"df[\"Bldg Type\"] = df[\"Bldg Type\"].apply(\n",
" lambda x: \"Twnhs\" if x in (\"TwnhsE\", \"TwnhsI\") else x\n",
")\n",
"# Unify the two kinds of 2-family homes.\n",
"df[\"Bldg Type\"] = df[\"Bldg Type\"].apply(\n",
" lambda x: \"2Fam\" if x in (\"2FmCon\", \"Duplx\") else x\n",
")"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 28,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"build_type = pd.get_dummies(df[\"Bldg Type\"], prefix=\"build_type\", dtype=int)\n",
2021-05-25 08:22:14 +02:00
"df = pd.concat([df, build_type], axis=1)\n",
"del df[\"Bldg Type\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 29,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.extend(build_type.columns)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 30,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>build_type_1Fam</th>\n",
" <th>build_type_2Fam</th>\n",
" <th>build_type_Twnhs</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" build_type_1Fam build_type_2Fam build_type_Twnhs\n",
"Order PID \n",
"1 526301100 1 0 0\n",
"2 526350040 1 0 0\n",
"3 526351010 1 0 0\n",
"4 526353030 1 0 0\n",
"5 527105010 1 0 0"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 30,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[build_type.columns].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Air Conditioning\n",
"\n",
"Air conditioning clearly increases the valuation (\"steeper\" regression line with respect to the overall living area)."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 31,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydZ3hU5daG75n0kEYaIYSaEFqA0EkIoBRFVKQIomBBjmBBLKBYj6AcQMXzcVCPYDmAiCLSlKaCAoL0EnrvPY30nsz3Y2UymSRAEgIBsu7rmovsPe/s/c5EmYdVnmUwmUwmFEVRFEVRlOvCWNEbUBRFURRFuRNQUaUoiqIoilIOqKhSFEVRFEUpB1RUKYqiKIqilAMqqhRFURRFUcoBFVWKoiiKo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Z07dxIZGQnA+vXrOXr0KB9//DGNGjWic+fOvPTSS8yZM4fMzEwA5s6dS0BAAG+88QaBgYEMHjyYe++9l5kzZ+bvY8aMGQwYMIB+/foRFBTEuHHjcHR0ZMGCBQAl2ouiKIqi3OlcTs1i7aFoq3NrDkVzOTXrptx/9OjRLF68mGPHjt2U+5WWW6amKjMzk19++YV+/fphMBjYu3cvWVlZhIeH568JDAzE398/X8hERkYSHByMt7d3/pqIiAiSk5M5evRo/pqwsDCre0VERORfIzMzk3379lndx2g0Eh4ezs6dOwFKtBdFURRFudOp6mxH5wY+VufuauBDVWe7m3L/Nm3aEBE
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Central Air\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use a new variable name to cleary show that the variable's *dtype* is changed from *str* to *int*."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 32,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"air_cond\"] = df[\"Central Air\"].apply(lambda x: 1 if x == \"Y\" else 0).astype(int)\n",
"del df[\"Central Air\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 33,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.append(\"air_cond\")"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 34,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>air_cond</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" air_cond\n",
"Order PID \n",
"1 526301100 1\n",
"2 526350040 1\n",
"3 526351010 1\n",
"4 526353030 1\n",
"5 527105010 1"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 34,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[[\"air_cond\"]].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### \"Proximity to various Conditions\"\n",
"\n",
"The columns *Condition 1* and *Condition 2* have the same realizations and can be regarded as \"tags\" given to a house indicating the nearby presence of a) a major street, b) a railroad, or c) a park.\n",
"\n",
"The default tag \"Norm\" (implying no \"condition\") is given to 86% of the houses (this realization should therefore not be regarded as a tag!).\n",
"\n",
"From the comparison of the grouped scatter plots below, it can be assumed that the proximity of a major street decreases the valuation (lower regression slope through the cloud of blue and orange dots). Therefore, a factor variable *major_street* is extracted indicating the proximity of an \"artery\" or \"feeder\" street.\n",
"\n",
"Further, a factor variable *railway* is extracted as a relatively high proportion of the houses has such a tag. From the plots, a railway seems to not affect the valuations strongly.\n",
"\n",
"Lastly, a factor variable *park* is extracted. From the plots, this does not seem to affect the valuation much."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"List the \"raw\" realizations:"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 35,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Feedr 174\n",
"Artery 97\n",
"RRAn 48\n",
"PosN 43\n",
"RRAe 29\n",
"PosA 24\n",
"RRNn 11\n",
"RRNe 6\n",
"Name: count, dtype: int64"
2021-05-25 08:22:14 +02:00
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 35,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(\n",
" (\n",
" df[\"Condition 1\"].value_counts() + df[\"Condition 2\"].value_counts()\n",
" )\n",
" .sort_values(ascending=False)[1:]\n",
")"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 36,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"# Condition 2 is only filled with anything other than \"Norm\"\n",
"# if Condition 1 already has such a tag.\n",
"assert not ((df[\"Condition 1\"] == \"Norm\") & (df[\"Condition 2\"] != \"Norm\")).any()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 37,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"86"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 37,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# 86% of the houses actually have no tag.\n",
"round(100* (df[\"Condition 1\"] == \"Norm\").sum() / df.shape[0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"From a simple scatter plot it is hard to see any significant impact by a predictor."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 38,
2021-05-25 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ECZKTk+/bT6vVolarK+26SqWy0s5VESKpEgRBEIRnWLGqhKTsIopVJVVyvfz8fLZv306/fv1o2bIlmzZt0u87duwYAQEB/PXXX/To0YN69eqxdetW5s2bR3R0NAEBAQQEBLBx40YAcnJy+Oijj3jhhRcIDQ1l0KBBREdH6893d4Rr3bp1tG7dmuDgYDZv3kzTpk1LJVjvvvsuH3744RO992pNqlq3bq3/AP/5Z9q0aQAUFxczbdo0mjZtSkhICKNGjSItLc3gHImJiQwdOpT69evTrFkzPv/881JZ77Fjx+jevTtBQUG0bdtW/x/rn1atWkXr1q2pV68evXr14ty5cwb7yxOLIAiCIDxNribn8t7aM7T+ej/vrT3D1eTcJ37NHTt24Ovri6+vL127dmXDhg1otVqDPl9//TXjxo1j+/btvPjii7z55pvUrFmTgwcPcvDgQTp27AjAmDFjSE9PZ8mSJWzcuJG6devy+uuvk5WVpT9XQkICu3btYt68eWzevJkOHTpQUlLCnj179H3S09P566+/6Nmz5xO992pNqtavX6//AA8ePMjSpUsB6NChAwCzZs1i3759zJkzhxUrVpCSksLIkSP1x5eUlDBs2DBUKhWrV69m9uzZbNq0iblz5+r73Lx5k2HDhtG0aVO2bNnC66+/zscff8yBAwf0fbZv305kZCQjRoxg06ZN1K5dmyFDhpCenq7v87BYBEEQBOFpUqwq4dvdV9lxPokCZQk7zicxZ/fVJz5itX79erp27QpAREQEubm5HD9+3KDP6NGjefHFF6lRowbOzs6Ym5sjk8lwdHTE0dERU1NTTp48yblz55g7dy716tX
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Condition 1\", s=15, data=df);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"However, plotting the groups seperately reveals different slopes."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 39,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAB8wAAAXiCAYAAAB5hxKQAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeVyVZf7/8fc5cNhEQUBxrUQFNUXNyiVc0spqakZjxhaz1bKmsr6almZZ5qhppelUVppmYzkV2thU2uI+KrmmpoKG+4IIHGTnwDm/P/hxB8p6AA/L69nDR3Kd+77uz2HxOpz3fV2XyeFwOAQAAAAAAAAAAAAAQD1jdnUBAAAAAAAAAAAAAAC4AoE5AAAAAAAAAAAAAKBeIjAHAAAAAAAAAAAAANRLBOYAAAAAAAAAAAAAgHqJwBwAAAAAAAAAAAAAUC8RmAMAAAAAAAAAAAAA6iUCcwAAAAAAAAAAAABAvURgDgAAAAAAAAAAAAColwjMAQAAAAAAAAAAAAD1EoE5UI/NmzdPYWFhCgsLK/bxgQMHKiwsTC+++GKlrhMdHW1cJzo6ulJ9AQBQkzG2AgBw+TH+Avmq6nsdAIrDeAugLnN3dQFATZKTk6MffvhBGzZs0J49e5ScnKy0tDT5+vqqZcuW6tKliwYPHqxevXrJbOZ+k/oqPT1d+/fv1549e7Rnzx7t3btXp06dkiS1bNlSa9ascXGFVSM6OloPPPCA8fFtt92mOXPmlHrOiy++qBUrVkiSYmJiqrM8ALUEYyvKo76MrcX55ZdfNGLECOPjzz//XNdcc40LKwJQFzD+ojzqy/h78e+2ZZk+fbruuuuuaqwIQF3BeIvyYLyVvLy85O/vrw4dOujmm2/Wn//8Z3l4eJTaX0k3ZlgsFjVq1EghISG64YYbNGzYMAUGBpba14gRI/TLL79Iksxms1auXKn27duXePzJkyc1aNAgSdLTTz+tZ555ptT+UTcQmAP/3w8//KAZM2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BrSS7NixQ0899ZSSk5ONtuzsbG3atEmbNm3S+PHj9eijj1bL86jLHn/8cX355ZfKysrSO++8o4ULFzrVz6ZNm/Tss89eEj6fOnVKp06d0sqVKzV8+HBNmjRJZnPp93V9/vnnmjp1qnJzc8u87tdff61JkybJZrMZbcePH9fixYu1bt06/etf/1KTJk20cOFCzZo1q8ibFSdOnNCCBQu0ZcsWffrpp2rQoEEFnzVQPzC2Mrai/L755hvl5eXJbDbrzjvvlCTdeeedmjt3rmw2m/773//qgQceKFdfR48e1SOPPGKE4lVh5cqVmjx58iXLBJ49e1arVq3SqlWr9Ne//lWvvfaa3N1L/rXS4XBo/Pjx+s9//nPJYwEBARo0aJBWrVql77//Xi+99FKp34sF4bu/v79uuukmJ58ZUPcw/jL+onpt2bJFzz333CVveBf+Puzfv79mz55d4u+KVdHH9OnTtXjx4iJtR48e1eLFi7Vy5Up9+OGH5X5OycnJevrpp3XgwIFynwPUd4y3jLeoGhaLxfh7ab9LlofJZDL2QC9vX8HBwbr77ru1ZMkSbdiwQbt27VL37t2drqGyP3uoOQjMUW8dOnTIGAR79OghX1/fSvf55ptvGi9wWrVqpccee0ydOnVSZmam1qxZo6VLlyo1NVWjRo3SV199pQ4dOpTY1zvvvKNdu3bppptu0pAhQ9SiRQudP39en332mdatW6djx45p+vTpevvtty859/Tp08YLHLPZrGHDhunWW2+Vr6+vYmJi9NFHH2nevHnq3LmzU8/zm2++0blz54wXCs8991yRuwSl/H1Kyis+Pl4PPfSQUlJSZDKZNHToUP3pT3+Sv7+
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 2000x1500 with 9 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"street = [\"Artery\", \"Feedr\"]\n",
"railway = [\"RRNn\", \"RRAn\", \"RRNe\", \"RRAe\"]\n",
"park = [\"PosA\", \"PosN\"]\n",
"plot = sns.lmplot(\n",
" x=\"Gr Liv Area\", y=\"SalePrice\", col=\"Condition 1\", hue=\"Condition 1\",\n",
" col_order=[\"Norm\"] + street + railway + park,\n",
" data=df, robust=True, col_wrap=4, ci=None, truncate=True, scatter_kws={\"s\": 15},\n",
")\n",
"# Adjust font sizes.\n",
"for ax in plot.axes:\n",
" ax.set_title(ax.get_title(), fontsize=20)\n",
" ax.set_xlabel(ax.get_xlabel(), fontsize=16)\n",
" ax.set_ylabel(ax.get_ylabel(), fontsize=16)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Extract factor variables *major_street*, *railway*, and *park*."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 40,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"major_street\"] = 0\n",
"df.loc[\n",
" df[\"Condition 1\"].isin(street) | df[\"Condition 2\"].isin(street),\n",
" \"major_street\",\n",
"] = 1"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 41,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"railway\"] = 0\n",
"df.loc[\n",
" df[\"Condition 1\"].isin(railway) | df[\"Condition 2\"].isin(railway),\n",
" \"railway\",\n",
"] = 1"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 42,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"park\"] = 0\n",
"df.loc[\n",
" df[\"Condition 1\"].isin(park) | df[\"Condition 2\"].isin(park),\n",
" \"park\",\n",
"] = 1"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 43,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Condition 1\"]\n",
"del df[\"Condition 2\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 44,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.extend([\"major_street\", \"railway\", \"park\"])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Show summary of counts:"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 45,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"major_street 264\n",
"railway 94\n",
"park 60\n",
"dtype: int64"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 45,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[[\"major_street\", \"railway\", \"park\"]].sum()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 46,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>major_street</th>\n",
" <th>railway</th>\n",
" <th>park</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" major_street railway park\n",
"Order PID \n",
"1 526301100 0 0 0\n",
"2 526350040 1 0 0\n",
"3 526351010 0 0 0\n",
"4 526353030 0 0 0\n",
"5 527105010 0 0 0"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 46,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[[\"major_street\", \"railway\", \"park\"]].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exterior\n",
"\n",
"This dimensions tells the main material with which the houses are made of. The category is too diverse and the various grouped scatter plots did not reveal differing slopes. For simplicity, this variable is dropped.\n",
"\n",
"This variable actually also represents tags that could be associated with a house (possibly up to two different tags)."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 47,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeZzN1f/A8dfnc9fZ99UwZjFjGIylZIwUSotkaVG2pND6DZGkIrKlvkrfX5ZK0UJZS1RUikjZJesYy1hm32fu+vn8/ri5XDMYzJjBeT4e88g9n/M559w7zb3ve1ZJVVUVQRAEQRAE4YrINd0AQRAEQRCE64EIqgRBEARBEKqACKoEQRAEQRCqgAiqBEEQBEEQqoAIqgRBEARBEKqACKoEQRAEQRCqgAiqBEEQBEEQqoC2phtwI1EUhczMTDw8PJAk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wm82MGzeO1q1b07x5c5577jmys7Ndyjhx4gSDBg2iWbNmtGnThilTpmCzuf7PuWnTJrp3705iYiJ33HEHS5YsKdeWzz//nA4dOtCkSRMefPBBdu7c6XK9Mm0RBEEQhMpSTmVj/XwFlskfYv18Bcqp6v9MWbVqFdHR0URHR9O1a1cWL16MqqoAvPvuu6SmpjJnzhxWrlzJ2LFj8fPzc7l/6tSpDBgwgGXLlpGUlMSQIUPIy8sDICgoiIMHD7J///4LtuHo0aP89NNPzJw5k1mzZvHXX38xZ84clzxLly7F3d2dr776ihEjRvC///3P2eNlt9t55plncHNz4+uvv+aNN97gv//
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Exterior 1st\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 48,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3gUxf/A8ffu1fReCYQkkBB6EyQEUUCxIFIsKAgiUqxfESmCBQQBERFFf1JUFESKNBtYUFGaIB2RGkIJJb0nV3d/f5wcHAmQQEICzOt58sjNzs7OXczd52ZnPiOpqqoiCIIgCIIgXBW5qjsgCIIgCIJwIxBBlSAIgiAIQgUQQZUgCIIgCEIFEEGVIAiCIAhCBRBBlSAIgiAIQgUQQZUgCIIgCEIFEEGVIAiCIAhCBdBWdQduJoqikJaWhoeHB5Ik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5fykpCQeffRRGjVqxL333svGjRuJi4tjzZo1FfVSXZEqDao6dOhAXFxciZ+zO3KbzWbGjRtH69atadasGc8//zwZGRkubZw6dYpBgwbRpEkT2rRpw9tvv43N5vo/5+bNm+nevTsNGzbkzjvvZPny5SX6smDBAjp06ECjRo146KGH2L17t8vxsvRFEARBEMpKOZOBdcH3WCZ/gnXB9yhnKv8zZfXq1URHRxMdHU3Xrl1ZtmwZqqoC8P7775OUlMScOXNYtWoVY8eOxc/Pz+X8KVOm0L9/f1auXEnTpk0ZMmQI2dnZAAQFBXH48GEOHjx4yT4cP36cX3/
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Exterior 2nd\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 49,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Exterior 1st\"]\n",
"del df[\"Exterior 2nd\"]\n",
"# Also discard the associated ordinal variables.\n",
"del df[\"Exter Cond\"]\n",
"del df[\"Exter Qual\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Foundation\n",
"\n",
"The type of foundation appears to have an effect. However, only three of the six realizations occur in a large number. Factor variables *found_BrkTil*, *found_CBlock*, and *found_PConc* are extracted but not regarded as \"interesting\"."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 50,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9y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weHew++jonHf4IgCILwCKlQVZFeUE6FquqBXM/IyAgHBwccHBwIDAzkzTff5OrVq+Tm5kqP6f7880/69etHkyZN2Lx5c7Vz5Obm0qNHD4YPH45CoZDO5+DggIGBAWZmZnpt//v472FRr0lVhw4d8Pf3r/ZnypQpAFRUVDBlyhQiIyMJCwtj5MiRZGdn650jLS2NIUOG0LRpU1q2bMnnn3+OWq3W63P48GG6d+9OcHAwnTt3Zt26ddViWblyJR06dKBJkyb06tWLkydP6u2vSSyCIAiCUJ8uZBTxzppYOny5m3fWxHIho+iBXr+kpIRNmzbh4eGBtbW11D579mz69+/Pn3/+SVRUlN4xV69e5dVXX8XPz4958+ZhZGT0QGOuS/WaVK1du5Z9+/ZJf5YvXw7A008/DcD06dPZtWsXc+fO5aeffiIzM5MRI0ZIx1dVVTF06FBUKhWrV69m5syZrF+/nnnz5kl9UlJSGDp0KJGRkWzcuJEBAwbw4YcfsnfvXqnPn3/+yYwZMxg+fDjr168nICCAwYMHk5OTI/W5UyyCIAiCUJ8qVFV8teMCW0+lU1pZxdZT6czdceG+j1jt3r2bsLAwwsLCCA8PZ+fOnXz11VfI5ddTjAEDBvDUU0/h7u6Oo6Oj1J6YmMgrr7xCVFQUM2bMwMDA4L7Ger/Va1Jla2urN5y3a9cuGjZ
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Foundation\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 51,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Foundation\n",
2021-05-25 08:22:14 +02:00
"PConc 1282\n",
"CBlock 1242\n",
"BrkTil 310\n",
"Slab 48\n",
"Stone 11\n",
"Wood 5\n",
"Name: count, dtype: int64"
2021-05-25 08:22:14 +02:00
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 51,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[\"Foundation\"].value_counts()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 52,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABfAAAAH6CAYAAABI7m0CAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hU1dYG8PdMSe+F0EuABKSDUkPXi6BcgaCCoIAgXBURpCgIgogBASGiF0FBQC6IJWBDjIpUgQAhdEkh1ATSJ3Uy9Xx/5JtjJnXSmEny/u7DY7LnzD7rTDJ3T9beZ21BFEURRERERERERERERERkU2TWDoCIiIiIiIiIiIiIiIpjAp+IiIiIiIiIiIiIyAYxgU9EREREREREREREZIOYwCciIiIiIiIiIiIiskFM4BMRERERERERERER2SAm8ImIiIiIiIiIiIiIbBAT+ERERERERERERERENogJfCIiIiIiIiIiIiIiG8QEPhERERERERERERGRDWICn4jKFRERgcDAQAQGBiIiIsLa4eD5559HYGAgnn/+eWuHQkREVGkcX8kahgwZgsDAQLz11lvWDqWYu3fvSu+JvXv3WjscIqonOB5TTbD2eFve75Hpd/7jjz9+wJFRZSisHQDRgxYREYEXXnjB4uNXrlyJMWPG1GBERNZT1vvBwcEBXl5eaN++PYYPH47hw4dDoSh/2EhPT8f+/fvx119/ITY2FhkZGdBqtXB3d4e/vz+6d++OJ554AgEBAdV9OURkRRxfiUqn1Wrx22+/4ejRo7h48SIyMjKQk5MDFxcXNGnSBJ06dcKwYcPQu3dvyGTF11gNGTIECQkJJfatVCrh4eGBtm3b4tFH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SenZ2Na9eu4dq1a/jqq6+wZs0aPPbYY5W8SssZjUasWLECu3btMmvXarX4+++/8ffff2PXrl346KOP0K9fv3L7mj9/Pn788Uez9ps3b2Lr1q34448/sGvXrlI3dq0rCie5DQaD9HV0dLR0K9/DDz+MDh06VPlcKpUKL7/8Ms6dO2fWnpGRgdOnT+P06dPYtWsXPv/8c7MPWSVJTU3FtGnT8Pfff5u1X7p0CZcuXcLx48excePGUv8A+fvvvzFz5kzcvXvXrF2n0yEuLg5xcXH47rvvcPDgwXLvOiCisnF8LY7ja+0cX0VRlO5Mc3JywtNPP/3Azl14kr1Ro0aV6kOj0WDu3Ln4/fffzdpVKhXOnz+P8+fPY+fOnfjss8/Qvn37EvswGAxYvXo1duzYAVEUzR4zbWp/8uRJXL9+HatWrbI4tpycHLz88ss4ffo0ZDIZ3n33XTzzzDMVv0giKhXH4+I4HtfO8biiCo+hJU3GFJaRkYGZM2cW+zvTUqIoYvXq1fjiiy8AAGPGjMGKFSu4eS6Vigl8ogrIzc3F5MmTcefOHQDAo48+iuDgYDRo0AB3797Frl27cPr0aURGRuI///kPdu3aVeP/B3z8+HFcvHgRAQEBeOGFFxAQEACNRoPff/8dX375JdRqNRYsWIDw8PBiM7l6vR4zZsyQPswEBQVh/PjxaNiwIe7du4fdu3fj+PHjyMzMLDMGvV4PX19fPPbYY+jatSuaNWsGe3t73Lt3D1FRUdi9ezfy8vIwd+5c7Nu3z2yFhGmTltDQUGkWu+jmbBW1du1a6cNM06ZN8dJLL+Ghhx6CWq3Gn3/+iV27diE7OxszZszAd999h3bt2pXa10cffYSoqCg8+uijGDVqFBo3bozU1FTs3r0bhw8fxq1bt7By5UqsW7euSjHbupiYGOnrwivlzpw5I309cODAKp/HYDDgP//5D6KiogAU1COcMGECmjZtiuTkZISFheGPP/7A9ev
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 2000x500 with 3 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot = sns.lmplot(\n",
" x=\"Gr Liv Area\", y=\"SalePrice\", col=\"Foundation\", hue=\"Foundation\",\n",
" col_order=[\"PConc\", \"CBlock\", \"BrkTil\"],\n",
" data=df, robust=True, col_wrap=4, ci=None, truncate=True, scatter_kws={\"s\": 15},\n",
")\n",
"# Adjust font sizes.\n",
"for ax in plot.axes:\n",
" ax.set_title(ax.get_title(), fontsize=20)\n",
" ax.set_xlabel(ax.get_xlabel(), fontsize=16)\n",
" ax.set_ylabel(ax.get_ylabel(), fontsize=16)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 53,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"foundation = pd.get_dummies(df[\"Foundation\"], prefix=\"found\", dtype=int)\n",
2021-05-25 08:22:14 +02:00
"# Only keep the top 3 realizations.\n",
"del foundation[\"found_Slab\"]\n",
"del foundation[\"found_Stone\"]\n",
"del foundation[\"found_Wood\"]\n",
"df = pd.concat([df, foundation], axis=1)\n",
"del df[\"Foundation\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 54,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.extend([\"found_BrkTil\", \"found_CBlock\", \"found_PConc\"])"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 55,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>found_BrkTil</th>\n",
" <th>found_CBlock</th>\n",
" <th>found_PConc</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" found_BrkTil found_CBlock found_PConc\n",
"Order PID \n",
"1 526301100 0 1 0\n",
"2 526350040 0 1 0\n",
"3 526351010 0 1 0\n",
"4 526353030 0 1 0\n",
"5 527105010 0 0 1"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 55,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[foundation.columns].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Garage Type\n",
"\n",
"As can be expected, the *Garage Type* looks very similar to the above *has Garage* variable. Therefore, it is dropped."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 56,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2Fy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HgwevRoZs6caXxdpVLx5ZdfMnHiRJ5++ml8fHwYN24cw4cPx9zcHABLS0uWLl3KJ598wsiRI8nIyMDNzY2IiIgyj1xVr16d8PBwUlJSqF+/aF2wiIgI/Pz86NevH1qtlq5du/Lqq68aX3/99ddxdHRk3rx5xMbGYmtrS506dRg+fHiZ+nOvFAaDwVAlT34Epaen07BhQ/bt21cuQ6eSJEnS/SM7O5tz587h7+9fZBrrQbRv3z6ee+45Nm7ciK+vb4U8w2Aw0KFDB5577rkidasmTJhAamoqX331VYU8+1Z3+vmV9Pe3HKmSJEmSJImNGzdiZWWFn58fFy9e5MMPP6RBgwYVFlAlJSXx22+/kZCQQM+ePSvkGZVNBlWSJEmSJJGRkcEnn3xCXFwc1apVo3nz5iWaWiyriIgIqlWrxpQpU7C3t6+w51QmGVRJkiRJkkT37t3p3r17pT3vbpspz5gxo5J6Un7k6j9JkiRJkqRyIIMqSZIkSZKkciCDKkmSJEmSpHIggypJkiRJkqRyIIMqSZIkSZKkciCDKkmSJEmSpHIgSypIkiRJ0iNu3rx5/Pnnn8TExGBhYUF4eDhjx46lRo0a7N69mwEDBtzx+sWLF9O0adNK6u39SwZVkiRJkvSI27NnD/369SM0NBS9Xs///vc/Bg8ezG+//UZ4eDjR0dHGth9++CH
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Garage Type\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 57,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Garage Type\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Heating\n",
"\n",
"Most of the houses have gas. The variable is not helpful."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 58,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3yNd/vH3yc7kYEkMmQgIUaQWCFia7VaVXRYbanuQQctndp6Slt9Ho+2v9KFGlWPVRRttWqLPWsLgiAJInue3x+Xc05OEkSEGNf79Tovub/ne9/39z5a55Prur6fy2A0Go0oiqIoiqIo14RNRS9AURRFURTldkBFlaIoiqIoSjmgokpRFEVRFKUcUFGlKIqiKIpSDqioUhRFURRFKQdUVCmKoiiKopQDKqoURVEURVHKAbuKXsCdREFBAWfOnKFSpUoYDIaKXo6iKIqiKKXAaDSSnp5OtWrVsLG5dDxKRdUN5MyZM7Rr166il6EoiqIoShlYsWIFvr6+l3xfRdUNpFKlSoD8pbi6ulbwahRFURRFKQ1paWm0a9fO/D1+KVRU3UBMKT9XV1cVVYqiKIpyi3Gl0h0tVFcURVEURSkHVFQpiqIoiqKUAyqqFEVRFEVRygGtqVIURVGUW4CCggJycnIqehm3Jfb29tja2l7zdVRUKYqiKMpNTk5ODnFxcRQUFFT0Um5bKleujK+v7zX5SKqoUhRFUZSbGKPRSEJCAra2tgQGBl7WfFK5eoxGIxkZGZw5cwYAPz+/Ml9LRZWiKIqi3MTk5eWRkZGBv78/Li4uFb2c2xJnZ2dATLqrVatW5lSgyl1FURRFuYnJz88HwMHBoYJXcntjEqy5ubllvoaKKkVRFEW5BdCesdeX8vh8VVQpiqIoiqKUAyqqFEVRFEVRygEVVYqiKMqdTUE+HFsPG76F3fMg9VRFr+i25rHHHuNf//pXRS/juqCiSlEURbmzObIKJt0Li4fC/wbA7+9BTnpFr+q6MXz4c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rCxcu5KWXXuK///1vse/0H374gbp16zJ//nxeeOGFG/oMFSqqZs+ezerVq82vSZMmAXDPPfcA8PHHH7N8+XLGjRvH1KlTOXPmDC+99JL5/Pz8fJ599llyc3OZOXMmY8aMYd68eYwfP948Jz4+nmeffZaoqCh++eUXnnjiCd555x1WrVplnrN48WJGjx7Niy++yLx586hbty6DBg0iOTnZPOdKa1EURVGUm5Xs3Hz+s2w/S3aeIiMnnyU7TzFu2f4bErH6+++/iYyMNL8GDx5cbM6RI0f466+/GDVqFM2aNaNu3bqMHTuW06dPs2zZMgAmTZpEq1atePHFF6lZsyY9e/akX79+fP/991bXatmyJU8++SRBQUEEBQVd9+crTIWKqqpVq1qFA5cvX05QUBAtWrQgNTWVOXPmMHz4cFq1akV4eDgff/wxW7duZdu2bQCsXr2agwcP8tlnn1GvXj3atWvHkCFDmD59Ojk5OQDMnDmTgIAAhg8fTkhICP3796dLly5MnjzZvI5JkybxyCOP0KtXL0JDQ/nggw9wcnJizpw5AKVai6IoiqLcrJzLyGXFvkSrsb/3JXIuI/e63zsqKor58+ebX++8806xOYcOHcLOzo7GjRubx6pUqULNmjU5dOgQAIcPH6ZJkyZW5zVp0oSjR4+Sn28Rh+Hh4dfpSa7MTVNTlZOTw4IFC+jVqxcGg4Fdu3aRm5tLdHS0eU5ISAj+/v5mIbNt2zbq1KmDl5eXeU5MTAxpaWkcPHjQPKdVq1ZW94qJiTFfIycnh927d1vdx8bGhujoaLZu3QpQqrUoiqIoys1KFRd72oV5W421D/Omiov9db+3s7MzwcHB5le
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Heating\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 59,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Heating\"]\n",
"# Also discard the associated ordinal variable.\n",
"del df[\"Heating QC\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### House Style\n",
"\n",
"In summary, this variable is very similar to the above derived variable *has 2nd Flr*. Therefore, it is dropped."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 60,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3gUVdvA4d/W7G567z2QAAFCQieAIk1sIIK+UhSxAAKiiCjqKwgfoKIvUhSUKqCINBEBBRUF6b2XQEghIb1vkq3fH4GFJQESSKGc+7q4ZM6cmXl2g5tnz5x5jsRsNpsRBEEQBEEQ7oi0rgMQBEEQBEG4H4ikShAEQRAEoRqIpEoQBEEQBKEaiKRKEARBEAShGoikShAEQRAEoRqIpEoQBEEQBKEaiKRKEARBEAShGsjrOoAHiclkIj09HVtbWyQSSV2HIwiCIAhCJZjNZoqKivDw8EAqvfF4lEiqalF6ejodO3as6zAEQRAEQbgNf//9N15eXjfcL5KqWmRrawuU/VDs7OzqOBpBEARBECqjsLCQjh07Wn6P34hIqmrRlVt+dnZ2IqkSBEEQhHvMrabuiInqgiAIgiAI1UAkVYIgCIIgCNVAJFWCIAiCIAjVQMypEgRBEIS7hMlkQqfT1XUYDxyFQoFMJrvj84ikShAEQRDuAjqdjvj4eEwmU12H8kBycnLCy8vrjupIiqRKEARBEOqY2WwmNTUVmUyGv7//TQtMCtXLbDaj1WpJT08HwNvb+7bPJZIqQRAEQahjBoMBrVaLj48PGo2mrsN54KjVa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ain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"House Style\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 61,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"House Style\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Land Contour\n",
"\n",
"This variable is assumed to contain the same information as the ordinal variable *Land Slope* and is dropped."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 62,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hU1dbA4d/UZJJJ7z0hIQVCCDWUIIig2FHsIooo2EA/G9iuoCio6OXi9Qo2QEURBbGBBUUF6b2FkoRAeu+ZZOr3x8jAGEqAQCjrfR4eM/vsc84KkZmVffZeW2Gz2WwIIYQQQojTomzrAIQQQgghLgSSVAkhhBBCtAJJqoQQQgghWoEkVUIIIYQQrUCSKiGEEEKIViBJlRBCCCFEK5CkSgghhBCiFajbOoCLidVqpaSkBHd3dxQKRVuHI4QQQogWsNls1NfXExgYiFJ57PEoSarOopKSEvr379/WYQghhBDiFPzxxx8EBwcf87gkVWeRu7s7YP+h6PX6No5GCCGEEC1RV1dH//79HZ/jxyJJ1Vl06JGfXq+XpEoIIYQ4z5xo6o5MVBdCCCGEaAWSVAkhhBBCtAJJqoQQQgghWoHMqRJCCCHOIovF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aPPiWIRQgghzkVNJgv/XraXpduLaDBaWLq9iOnL9rbZiFV6ejo6nY5ffvnF0fb9998zcOBA9Hp9m8TUWto0qfL19SUgIMDxZ/ny5URGRtKzZ09qa2tZuHAhEyZMoHfv3iQnJ/Pqq6+yefNmtmzZAtgz28z
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Land Contour\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 63,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Land Contour\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Lot Configuration\n",
"\n",
"This variable shows no good pattern and is dropped."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 64,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3gUVdvA4d+2ZJNseu+9kRAIoYYAiryCKEoTG6KIggqKhWZBQVFA8f14rWCjKIJIUxFQUUCQ0EuogZCQQnrPpm39/lhYWEINgQQ493XlMnPmzMyziew+OXPmORKj0WhEEARBEARBuCbS5g5AEARBEAThViCSKkEQBEEQhCYgkipBEARBEIQmIJIqQRAEQRCEJiCSKkEQBEEQhCYgkipBEARBEIQmIJIqQRAEQRCEJiBv7gBuJwaDgcLCQuzs7JBIJM0djiAIgiAIV8BoNFJ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PQarUsWbKEGTNmsHLlSj7++GNzn+zsbEaNGkWnTp34+eefeeKJJ3jzzTfZvHmzuc+aNWuYPn06o0ePZuXKlURFRTFixAhKSkrMfS4XiyAIgiA0tXqtnv9bf4y1B/Kp0ehZeyCf2euP3fARq8jISMaMGUNQUBD9+/cnNjaW5ORkwDSq5ObmRmJiIj4+PsTFxTFkyJALnmfr1q2kp6czc+ZMoqKi6NChAy+//LJFnzVr1mAwGHjvvfeIjIwkNDSU6dOnk5eXx44dO677a70WzZpUubi44O7ubv7asGEDAQEBdOzYkaqqKpYvX86kSZPo0qULsbG
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Lot Config\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 65,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Lot Config\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MS SubClass\n",
"\n",
"By looking at this variable's realizations, one can see that several distinct features are lumped together in one. In particular, the above variables *has 2nd Flr* and *build_type_\\** and the future age related features at the bottom of this notebook together should comprise the same patterns in a more advantagous way. Thus, the column is dropped."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 66,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['1-STORY 1946 & NEWER ALL STYLES',\n",
" '1-STORY 1945 & OLDER',\n",
" '1-STORY W/FINISHED ATTIC ALL AGES',\n",
" '1-1/2 STORY - UNFINISHED ALL AGES',\n",
" '1-1/2 STORY FINISHED ALL AGES',\n",
" '2-STORY 1946 & NEWER',\n",
" '2-STORY 1945 & OLDER',\n",
" '2-1/2 STORY ALL AGES',\n",
" 'SPLIT OR MULTI-LEVEL',\n",
" 'SPLIT FOYER',\n",
" 'DUPLEX - ALL STYLES AND AGES',\n",
" '1-STORY PUD (Planned Unit Development) - 1946 & NEWER',\n",
" '1-1/2 STORY PUD - ALL AGES',\n",
" '2-STORY PUD - 1946 & NEWER',\n",
" 'PUD - MULTILEVEL - INCL SPLIT LEV/FOYER',\n",
" '2 FAMILY CONVERSION - ALL STYLES AND AGES']"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 66,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(ALL_COLUMNS[\"MS SubClass\"][\"lookups\"].values())"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 67,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"MS SubClass\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MS Zoning\n",
"\n",
"This variable is dropped as most houses are located in a \"residential\" zone."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 68,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MS Zoning\n",
2021-05-25 08:22:14 +02:00
"RL 2252\n",
"RM 459\n",
"FV 131\n",
"RH 27\n",
"C 25\n",
"A 2\n",
"I 2\n",
"RP 0\n",
"Name: count, dtype: int64"
2021-05-25 08:22:14 +02:00
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 68,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[\"MS Zoning\"].value_counts()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 69,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcn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4O+zz77LGq1msWLF+Pl5UVJSQkHDhy4amFRNzc39u3b16Q9MTGR6dOn8/jjj7fqe7G3t2/V690u4vGfIAiC8EAzNrcweC2TyZG3wpYlba1du3a4ubmxbds2qW3btm24ubkRFhYmtVVWVnLkyBFeeuklunfvjoeHBxEREUybNu2qo1EKhQInJyeDL5lMxty5cxk6dChTpkyR+qakpPDEE08QERFBdHQ0c+bMoaamRjo+a9Ysnn76ab788ktiY2OJjo5m3rx5BqUNrnz8FxISwo8//sj06dPp2LEjAwcOZMeOHQYx7tixg4EDB9KhQwf+8pe/sH79ekJCQqisrGzx9/R6RFIlCIIgPNDa9X4I48seLUWPGoe9u8cNnauqrqKisACtRnO7wrslcXFxrFu3Tnq9du1aRo8ebdDH3Nwcc3Nztm/fTkNDQ4vuo1arefbZZ3F0dGTBggVSe21tLVOmTMHGxoY1a9awZMkS9u/fz/z58w3OP3ToEJmZmaxYsYLFixezfv161q9ff817fvzxxzzyyCP89NNP9O7dm5deekkaWcvKyuL555+nf//+bNy4kQkTJvDvf/+7Re/tZoikShAEQXiguQeF8thbHzDsX7MY98YiugwfjcJIed3zspITWfX6y3z53N/Zvuy/VBQW3IFob87w4cM5evQoOTk55OTkcOzYMYYPH27Qx8jIiMWLF7Nhwwa6dOnChAkT+OCDDzh9+vQN32f+/PlkZWXxySefYGJiIrVv2rSJhoYG3n77bYKDg+nRowevv/46GzdupLi4WOpnY2PD66+/TkBAAA899BB9+vThwIED17znqFGjePTRR/Hx8eGFF16gtraWEydOAPDDDz/g5+fHzJkz8ff3Z+jQoYwaNeqG309LiTlVgiAIwgPPwcMLBw+vG+5fVVLMz/9ehKqyAoDEXduwc3Oj24ixtyvEFrG3t6dv376sX78enU5H3759m52fNGjQIPr27cuRI0dISEhg7969LFu2jAULFjQZ2brS999/z7p16/j6669xdXU1OHbu3DlCQkIMKr936tSJxsZG0tPTcXR0BCAwMNBgaxgnJyfOnDlzzfuGhIRIfzY3N8fS0pLSUv3KzfT0dMLDww36R0REXP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YqKopnn32W4uJig2vk5uYydepUOnbsSI8ePXj77bfRaDQGfQ4dOsSoUaMIDw/n4YcfZt26dU1iWblyJf369aNDhw6MHTuWEydOGBy/kVgEQRAE4X5xpqCKf65OoN/7u/nn6gTOFFTd9ntu2bIFf39//P39GT58OGvXrkWn0932+7aWNk2q1qxZw759+6Svr776CoDBgwcDsHDhQnbt2sWSJUv45ptvKCws5JlnnpHO12q1TJs2DbVazapVq1i8eDHr16/no48+kvpkZWUxbdo0oqOj2bhxI08++SSvvfYae/fulfps3ryZRYsWMX36dNavX09oaChTpkyhpKRE6nO9WARBEAThflGv1vLv7WfYcjKf2gYtW07ms2T7mds+YrVmzRqGDx8OQK9evaiqquLw4cO39Z6tqU2TKnt7e5ycnKSvXbt24e3tTbdu3aiqqmLt2rXMmjWLHj16EB4ezsKFC4mPjychIQGAffv2kZqayrvvvktYWBh9+vTh+eefZ+XKlTQ0NACwatUqPD09mTVrFgEBAUyaNIlBgwaxfPlyKY6vvvqKcePGERcXR2BgIPPmzcPU1JS1a9cC3FAsgiAIgnC/KKtVsyelyKBtd0oRZbXq23bPtLQ0Tp48yaOPPgqAkZERQ4YMYc2
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"MS Zoning\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 70,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"MS Zoning\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Masonry Veneer Type\n",
"\n",
"None of the groups have a slope differing from the overall one."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 71,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {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YkLi4OAoKCqptR/v27QkJCWHo0KGYTCb69u3LM888Yzv/3HPP4eHhwbx580hJScHZ2ZkmTZrwxBNPXNV2K6Szs9uEq85oNNKqVSt27Nhx0R8YQRAE4eZRVlZGYmIioaGhVYaxhOpJkkTPnj0ZMmRIlbxVkyZNorCwkP/97391+syLfZ9q+vtb9FQJgiAIgnDdyM3N5ddffyU7O7vaHF3XMxFUCYIgCIJw3Wjfvj3u7u68+eabuLq61ndzLosIqgRBEARBuG4cOXLkoudnzJhxjVpy+URGdUEQBEEQhDoggipBEARBEIQ6IIIqQRAEQRCEOiCCKkEQBEEQhDoggipBEARBEIQ6IIIqQRAEQRDq1LJly2z7Et5KREoFQRAEQRCqNWnSJJYvX247dnNzIzY2lhdeeIGoqKgrvv9vv/3GN998w8GDB7FarQQFBdGrVy+GDRt2wY2fr2eip0oQBEEQhAvq1KkTGzduZOPGjSxcuBC1Wn3RPfTMZnON7vvBBx/w/PPPExsby2effcbKlSuZNGkSR44c4aeffqqr5l9TIqgSBEEQhBtIudlCekEZ5WbLNXmeVqvF29sbb29voqOjefTRRzl9+jS5ubmkpKQQGRnJqlWrGDZsGE2bNmXlypVV7pGbm8vAgQMZM2YMJpOJvXv3MnfuXCZOnMjEiRNp2bIlQUFBdOzYkTlz5jBgwAAA5syZwz333MOPP/5I165diYuLY8qUKVgsFj777DM6duxI+/bt+eSTT+yeFxkZyQ8//MCYMWNo3rw5PXv25M8//7zqX6t6Daq6d+9
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Mas Vnr Type\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 72,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Mas Vnr Type\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Miscellaneous Features\n",
"\n",
"This variable is basically a \"other\" field with no pattern."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 73,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hURdvA4d/uZtN7770nQEKoIfQqCFKk2EXfz4pYUCkKgiIgggX0fcGGqCgiTUG6FEECSAmQAIGQkN77pm42+/2xcGQJJYSEIMx9XblkZ+ec85xE2CdzZp6RabVaLYIgCIIgCMItkbd2AIIgCIIgCHcDkVQJgiAIgiA0A5FUCYIgCIIgNAORVAmCIAiCIDQDkVQJgiAIgiA0A5FUCYIgCIIgNAORVAmCIAiCIDQDg9YO4F5SX19PXl4eZmZmyGSy1g5HEARBEIRG0Gq1VFRU4OjoiFx+7fEokVTdRnl5efTs2bO1wxAEQRAEoQn27NmDs7PzNd8XSdVtZGZmBuh+KObm5q0cjSAIgiAIjaFSqejZs6f0OX4tIqm6jS498jM3NxdJlSAIgiD8y9xo6o6YqC4IgiAIgtAMRFIlCIIgCILQDERSJQiCIAiC0AzEnCpBEARBuANoNBrUanVrh3FPUiqVKBSKWz6PSKoEQRAEoRVptVpycnIoKSlp7VDuadbW1jg7O99SHUmRVAmCIAhCK7qUUDk6OmJqaiqKQ99mWq2WyspK8vLyAHBxcWnyuURSJQiCIAitRKPRSAmVnZ1da4dzzzIxMQF0RbodHR2b/ChQTFQXBEEQhFZyaQ6VqalpK0ciXPoZ3Mq8NpFUCYIgCEIrE4/8Wl9z/AxEUiUIgiAIgtAMRFIlCI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5ebFw4UICAgIAeOGFF1AoFCxatIi8vDwcHBwYN25ck+Lq3r07S5Ys4fPPP+fLL7/EwMAAX19fKUELDg5m6tSpfPnll3z00Ud06NCB1157jcmTJ0vnaN++PePGjeOVV16hpKSECRMm8NJLLzF58mSmTZvGI488gqOjI9OmTSMhIeGGMY0ePRpjY2O+/vpr5s+fj6mpKYGBgTzxxBNNusfGkGmvfFAptBiVSkVUVBRHjhxp0eJsgiAIwr9DdXU1KSkp+Pj4YGxs3Nrh3NOu97No7Oe3KP4pCIIgCILQDERSJQiCIAiC0AxEUiUIgiAIgtAMRFIlCIIgCILQDERSJQiCIAiC0AxEUiUIgiAIgtAMRFIlCIIgCILQDERSJQiCIAiC0AxEUiUIgiAIwm0VFBTEjh07WjuMZie2qREEQRAEoVlNmTKFdevWNWiPiYnh66+/boWIbg+RVAmCIAiC0Oy6d+/O3Llz9doMDQ1bKZrbQzz+EwRBEIR7QI1aQ05pNTVqzW25nqGhIQ4ODnpfVlZX33g6Ozubl19+mQ4dOtCpUyeef/55MjIyANi3bx9t2rShrKxM75jZs2fz+OOPt/h93IxWTar69OlDUFBQg69Zs2YBUFNTw6xZs+jcuTORkZG89NJLFBQU6J0jKyuLZ555hnbt2tG1a1c++OAD6urq9PocPHiQESNGEB4eTv/+/Vm7dm2DWFasWEGfPn1o06YNo0eP5sSJE3rvNyYWQRAEQbgTnc0t55VVcfRZuJtXVsVxNre8tUOSqNVqnn76aczMzFixYgU//fQTpqam/Oc//6G2tpauXbtiaWnJ1q1bpWM0Gg2bN29m6NChrRh5Q62aVK1evZp9+/ZJX8uWLQNg0KBBAMyZM4ddu3bxySef8P3335OXl8eECROk4zUaDc8++yxqtZqVK1cyb9481q1bx6JFi6Q+6enpPPvss3Tu3Jlff/2VJ554grfffpu9e/dKfTZt2sT
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Misc Feature\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 74,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Misc Feature\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Roof\n",
"\n",
"Roofs in Ames, IA, are not special enough to make a difference in the price. Even \"hip\" roofs seem already priced in bigger houses."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 75,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3yNZxvHvycnWyKRnRhBQoKYQdAYNUoHpUoppUqpKh0UtVetLlV9S6ulRqt2axYtJQ1JzdjE3hlIZJ8k5/3jknNyJEgiEuP+fj7n8+a5n/t5nuuc9HV+ue7r/l0avV6vR6FQKBQKhULxQJgVdwAKhUKhUCgUTwJKVCkUCoVCoVAUAkpUKRQKhUKhUBQCSlQpFAqFQqFQFAJKVCkUCoVCoVAUAkpUKRQKhUKhUBQCSlQpFAqFQqFQFALmxR3A00RmZiZRUVGUKFECjUZT3OEoFAqFQqHIA3q9nsTERNzc3DAzu3s+SomqIiQqKoqmTZsWdxgKhUKhUCgKwD///IOHh8ddzytRVYSUKFECkF+KnZ1dMUejUCgUCoUiLyQkJNC0aVPD9/jdUKKqCMla8rOzs1OiSqFQKBSKx4z7le6oQnWFQqFQKBSKQkCJKoVCoVAoFIpCQIkqhUKhUCgUikJA1VQpFAqFQvEAZGRkoNPpijs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FjDnPvFolAoFApFfkjVZfDVlhNsOHiVpLQMNhy8yowtJ0jVZTy0Z54/fx69Xk/FihXzfM1zzz0HYFK4vnLlSl555RU0Gs0Dx7R7924
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Roof Matl\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 76,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd1xV9f/A8dfdcNl7g4gKbtwLR2ZaWubIylFqllquyllmapma1TfT+qWmucvMUVbaMEeaKwfuLcpS2Xvc+fvjyIUrqIggqJ/n48FDzrmfc877QsGbz3h/ZGaz2YwgCIIgCIJwT+SVHYAgCIIgCMLDQCRVgiAIgiAI5UAkVYIgCIIgCOVAJFWCIAiCIAjlQCRVgiAIgiAI5UAkVYIgCIIgCOVAJFWCIAiCIAjlQFnZATxKTCYTCQkJ2NnZIZPJKjscQRAEQRBKwWw2k52djaenJ3L5rfujRFJ1HyUkJNC+ffvKDkMQBEEQhDLYuXMn3t7et3xdJFX3kZ2dHSB9U+zt7Ss5GkEQBEEQSiMrK4v27dtbfo/fikiq7qOCIT97e3uRVAmCIAjCA+ZOU3fERHVBEARBEIRyIJIqQRAEQRCEciCSKkEQBEEQhHIg5lQJgiAIQgUxGo3o9frKDkO4A5VKhUKhuOf7iKRKEARBEMqZ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Hv2bDZu3Mi8efMsbWJiYhg2bBgtWrTg559/ZuDAgbz33nvs2rXL0mbz5s3MmjWLESNGsHHjRsLCwhgyZAjJycmWNneKRRAEQRD
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Roof Style\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 77,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Roof Matl\"]\n",
"del df[\"Roof Style\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Sale Info\n",
"\n",
"Partial and abnormal (= foreclosure) sales seem to make a change with higher and lower prices respectively. These two types will be encoded in factor variables *partial_sale* and *abnormal_sale*. The impact seems to be not big though."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 78,
2021-05-25 08:22:14 +02:00
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"Sale Condition\n",
2021-05-25 08:22:14 +02:00
"Normal 2396\n",
"Partial 233\n",
"Abnorml 189\n",
"Family 46\n",
"Alloca 22\n",
"AdjLand 12\n",
"Name: count, dtype: int64"
2021-05-25 08:22:14 +02:00
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 78,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[\"Sale Condition\"].value_counts()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 79,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliI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bGsmXLSElJQaPR4ObmxuDBgxkzZgwAISEhvPPOOyxatIjPP/+cqKgo3nzzTSZNmnTTENq1a8f8+fP5+uuvWbRoETKZjICAAAYPHnzTc+zs7FizZg0LFy7km2++IT09HVtbWxo2bMjEiRMNC8lnzpzJxx9/zJgxY1Cr1URFRbFw4cJqU2q38sILL5CTk8OkSZOQSqUMHDiQbt26UVJSctNzxo8fz5QpU+jatSsqlYoLFy5U69O1a1cmT57MkiVLmDFjBp6ensyYMYNWrVrVOLZ7QaJ7kCY//+OUSiXNmzfn6NGjWFnV8HFdQRAE4aFQUVFBUlIS/v7+D0WhSsHYrb5/Nf38FtN/giAIgiAIdUAkVYIgCIIgCHVAJFWCIAiCIAh1QCRVgiAIgiAIdUAkVYIgCIIgCHVAJFWCIAiCIAh1QCRVgiAIgiAIdUAkVYIgCIIgCHVAJFWCIAiCIDy0Dh48SHBw8G23v7kfRFIlCIIgCAIAsbGxBAcHs3DhQqP2HTt2EBwcXE9RPTxEUiUIgiAIgoGZmRmLFi2iqKiozq6pUqnq7FoPMpFUCYIgCMIDqlKtJbOogkq19r7dMzo6GicnJxYsWHDTPr/++iu9evUiNDSUzp07s2TJEqPjnTt35uuvv2bixIlERkYyZcoU1q1bR1RUFDt37qRHjx6EhYUxfvx4ysvLWb9+PZ07d6ZFixZMnz4drfb6+92
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Sale Condition\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 80,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAB8wAAAPvCAYAAACmyTR0AAAAOXRFWHRTb2Z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lyNW/eXBs3brQtv/vuu7V9+3bb38uXL9fy5cvttu3Xr58WLlxY4uMqjtVq1bfffqvvvvtOERERSk5Olre3t9q3b69rr71Wd9xxR4nzdM+aNUsffvihpPzheLKysrRw4UKtXr1aJ06ckCS1bdtWt9xyi0JCQi6aD5/XXHONVq1apUOHDmnu3LkKCQlR3bp1K7y/Q4cO6YsvvtC2bdv0119/yWw2KzAwUAMGDND48ePVokWLYrc7ffq0hg0bJunvu4l//PFHff311zpw4IASEhLUp08fLVy4sMS2oaGhOnDggDIyMhQUFKQ77rhDISEh8vDwkJT/heO7777TkiVLFBkZqfT0dLVp00Z33nmnQkJCZDKZio0tPT1dmzZt0m+//ab9+/fr9OnTyszMVP369dWuXTtdddVVCgkJUb169Sp83uBayKdFkU9LRz6t+TZs2KCUlBRJ0k033aSmTZvqsssu05YtW7RixQrdc8895drfsWPHNG/ePP3222+KjY2Vr6+v+vTpo3vuuUc9e/Ysdpvi8uNvv/2mhQsXat++fUpOTpa/v78GDRqkRx55RM2aNSs1huzsbH399df64YcfdOTIEaWmpsrX11edO3fWDTfcoBtvvLHEH+3Ov2ZjYmI0f/58bdq0SVFRUUpPT9eCBQt02WWXFWkbGxur//73v9q4caPOnj0rHx8f9e7dW4899pjat29v93g///xzbd68WdHR0fL29lb//v31+OOPKygoqFznGxc38m5R5N3SkXdrvqrIu3l5eQoNDdWKFSt09OhRmUwmBQUF6YYbbtDdd99d5vbnn/uqdurUKa1bt07bt2/X4cOHFRcXJ0lq3LixevTooVGjRunKK68scftly5bphRdekJR/vgIDA/X1119r+fLlOnr0qHJyctSyZUtdf/31mjhxourUqVNqPEePHtXcuXO1ZcsWJSQkqFGjRrr00ks1YcIEde/eveoeOFwOeboo8nTpyNM1X1V/P66ojRs3asWKFdq9e7cSEhJUr149tWrVSsOGDdPYsWMd+i338OHD+uqrr7R9+3adPXtW6enpatCggdq3b68BAwbo5ptvlr+/v902ycnJWr9+vbZs2aKIiAhFR0crJydHvr6+6tixo0aMGKFbb721xOsG5XNxvGpQ6xQUnaT8D8qVMXXq1CIJS5KSkpKUlJSkvXv36osvvtBHH32kPn36VPg4q1at0quvvmqb66XA2bNn9cMPP+iHH37Q7bffrtdee61CCWnZsmW2f0+YMKHCcRa2YsUKvfLKK8rOzrZb/ueff+rPP//U0qVL9fjjj+uhhx4qc1+LFi3Sm2++qdzcXNuymJgYrVq1SuvWrdPcuXPVt2/fYreNjY3VhAkT7J7rjIwMhYeHKzw8XGvXrr1gyc0RSUlJeuSRR/T777/bLU9MTNT27du1fft2LVq0SHPnzlXz5s1L3VdcXJzuv/9+HThwwG75vn37tG/fPv3666/66KOPSr2zs7YwmUyaPHmyHn30USUkJGjhwoUOXVvF+eSTT/T+++/LarXaLY+MjFRkZKQWL16s119/Xbfcckup+zEMQ1OmTLEN3VOWadOmafHixXbLDh06pDfeeEPbt2/X+++/r7y8PD3zzDNau3atXbuIiAhNmzZNERERev3114vd/0MPPWT3gbtAYmKiduzYoR07dujLL7/UnDlzyvxSAEjk0+KQT8mntV1BzmrdurXtR+ObbrpJW7Zs0cGDB3Xo0KFSf4Aq7Py5CqX86+iHH37Qjz/+qOeee04TJ04scz/vvfee5syZY7fszJkzCg0N1Y8//qg
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 2000x1000 with 6 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot = sns.lmplot(\n",
" x=\"Gr Liv Area\", y=\"SalePrice\", col=\"Sale Condition\", hue=\"Sale Condition\",\n",
" data=df, robust=True, col_wrap=4, ci=None, truncate=True, scatter_kws={\"s\": 15},\n",
")\n",
"# Adjust font sizes.\n",
"for ax in plot.axes:\n",
" ax.set_title(ax.get_title(), fontsize=20)\n",
" ax.set_xlabel(ax.get_xlabel(), fontsize=16)\n",
" ax.set_ylabel(ax.get_ylabel(), fontsize=16)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 81,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"partial_sale\"] = df[\"Sale Condition\"].apply(lambda x: 1 if x == \"Partial\" else 0)\n",
"df[\"abnormal_sale\"] = df[\"Sale Condition\"].apply(lambda x: 1 if x == \"Abnorml\" else 0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Homes that are sold for the first time cleare are priced higher. A factor variable *new_home* is introduced."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 82,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hURRfA4d/uZje990YqKRBCS6GEIqDYUIqoSLc3QBQRKyB8gl3BEmw0EQRBVARUEJQSEloIHdJII7237d8fgYU1lCSkUOZ9Hh/ZuXPvPRsle3buzBmJXq/XIwiCIAiCIFwTaVsHIAiCIAiCcDMQSZUgCIIgCEIzEEmVIAiCIAhCMxBJlSAIgiAIQjMQSZUgCIIgCEIzEEmVIAiCIAhCMxBJlSAIgiAIQjMwaesAbiU6nY78/HwsLS2RSCRtHY4gCIIgCA2g1+upqqrCxcUFqfTy41EiqWpF+fn59OvXr63DEARBEAShCf755x/c3Nwue1wkVa3I0tISqPuPYmVl1cbRCIIgCILQEJWVlfTr18/wOX45IqlqRecf+VlZWYmkShAEQRBuMFebuiMmqguCIAiCIDQDkVQJgiAIgiA0A5FUCYIgCIIgNAMxp0oQBEEQrjNarRa1Wt3WYdwy5HI5Mpnsmq8jkipBEARBuE7o9Xpyc3MpLS1t61BuOXZ2dri5uV1THUmRVAmCIAjCdeJ8QuXi4oKFhYUoFN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kiqEhISADh48CA
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"Sale Type\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 83,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"new_home\"] = df[\"Sale Type\"].apply(lambda x: 1 if x == \"New\" else 0)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 84,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"new_variables.extend([\"partial_sale\", \"abnormal_sale\", \"new_home\"])"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 85,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Sale Condition\"]\n",
"del df[\"Sale Type\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Show summary of counts:"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 86,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"partial_sale 233\n",
"abnormal_sale 189\n",
"new_home 227\n",
"dtype: int64"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 86,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[[\"partial_sale\", \"abnormal_sale\", \"new_home\"]].sum()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 87,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>partial_sale</th>\n",
" <th>abnormal_sale</th>\n",
" <th>new_home</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" partial_sale abnormal_sale new_home\n",
"Order PID \n",
"1 526301100 0 0 0\n",
"2 526350040 0 0 0\n",
"3 526351010 0 0 0\n",
"4 526353030 0 0 0\n",
"5 527105010 0 0 0"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 87,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[[\"partial_sale\", \"abnormal_sale\", \"new_home\"]].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Street Name\n",
"\n",
"Looking at the value counts this variable is pretty useless."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 88,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Street\n",
2021-05-25 08:22:14 +02:00
"Pave 2886\n",
"Grvl 12\n",
"Name: count, dtype: int64"
2021-05-25 08:22:14 +02:00
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 88,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[\"Street\"].value_counts()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 89,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Street\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Age & Remodeling\n",
"\n",
"The dataset was put together over several years. Therefore, the variables with year numbers need to be aligned to indicate the right ages."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 90,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"# For one house the year of being remodeled is one year\n",
"# before it was built. That input error is corrected.\n",
"input_error = (df[\"Year Remod/Add\"] < df[\"Year Built\"])\n",
"assert input_error.sum() == 1\n",
"df.loc[input_error, \"Year Remod/Add\"] = df.loc[input_error, \"Year Built\"]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Introduce a factor variable *remodeled*. Almost half the houses were remodeled at some point in time."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 91,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"46"
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 91,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"remodeled = (df[\"Year Remod/Add\"] > df[\"Year Built\"])\n",
"df[\"remodeled\"] = 0\n",
"df.loc[remodeled, \"remodeled\"] = 1\n",
"round(100 * remodeled.sum() / df.shape[0])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create discrete variables *years_since_built* and *years_since_remodeled*."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 92,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"years_since_built\"] = df[\"Yr Sold\"] - df[\"Year Built\"]\n",
"df[\"years_since_remodeled\"] = df[\"Yr Sold\"] - df[\"Year Remod/Add\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 93,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAigAAAGzCAYAAAAFROyYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAABQdElEQVR4nO3de1xUdeI//hczDggOYNxUvAcyiNwGKwXH+NiaZWqFtJlLWi0fL5lC5QXXTEANMLXES+qaud5ZP5luqFm6mauJl90vBJiLknlbKmBMucZl5vz+8MdZRwVmdGDOzLyej0ePnHPe8z7v92Hm8OKc93kfB0EQBBARERFJiMzSDSAiIiK6EwMKERERSQ4DChEREUkOAwoRERFJDgMKERERSQ4DChEREUkOAwoRERFJDgMKERERSQ4DChEREUkOAwqZxWeffQaVSoVr165Zuimtmjt3LtRqtVnrXLVqFVQqlcGyJ554AnPnzjXrdoikxJq+97bgXscZY82dOxdPPPGEWdvT1sc4BhSidlJcXIxVq1bxYE5EZAQGFDKL5557Dvn5+ejevbulm2IRr7/+OvLz81ssU1xcjNWrV+M///lPO7WKqG3Z+/ee2hYDio2qq6uDXq9vt+3J5XI4OTnBwcGh3bYpJR06dICTk5Olm0F2jt9709TU1Fi6CdQCBhQzOnnyJFQqFQ4dOnTXuuzsbKhUKuTm5gIAfvjhByQkJOCxxx5DSEgIxo4di7///e8G77lx4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-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 2 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df[[\"years_since_built\", \"years_since_remodeled\"]].hist(bins=20);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Two factor variables *recently_built* and *recently_remodeled* are created indicating that the corresponding action took place in the last 10 years. The two scatter plots below suggest that these groups of \"recent vs. old\" affect the price."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 94,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df[\"recently_built\"] = df[\"years_since_built\"].apply(lambda x: 1 if x <= 10 else 0)\n",
"df[\"recently_remodeled\"] = df[\"years_since_remodeled\"].apply(lambda x: 1 if x <= 10 else 0)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 95,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3RUVdfA4d/MZNJ77wkkhAAJvRNAEBBRVEAUFQuiYkF8VewNFQUV348XGygqoCiiFEXBgiKC9BJ6D4GEhFTS+8x8fxwyk0kCJCEQyn7WmmXunXPvPZMsyc45++yjMZlMJoQQQgghxHnRNnUHhBBCCCGuBBJUCSGEEEI0AgmqhBBCCCEagQRVQgghhBCNQIIqIYQQQohGIEGVEEIIIUQjkKBKCCGEEKIR2DR1B64mRqOR9PR0nJyc0Gg0Td0dIYQQQtSByWSisLAQX19ftNozj0dJUHURpaen07dv36buhhBCCCEaYPXq1fj7+5/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/lQVbsOklRmYEVu04yfeXBCzpiVVZWxp49e+jZs6f5nFarpWfPnmzfvv2CPfdCatKgytPTEx8fH/Nr1apVhIaG0rVrV/Lz81m0aBHPP/88PXr0ICYmhrfffpvt27cTHx8PwNq1azl8+DDvvfcerVq1om/fvjzxxBPMnz+fsrIyABYsWEBwcDDPP/88ERERjB49muuuu445c+aY+3GuSLkufRFCCCEuV6eKyll9IMPq3N8HMjhVVH7hnnn
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"recently_built\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 96,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeViUVfvA8e8MDPu+gyAqCKiAuAvhmktZmkuWlpVmZYvZptmemaWVva+v1S8tKy0ts1zK1BbLXHLfV1RUBATZ932Z3x9HZhhBRSRxuT/XNVc8z5znec6gyc0597mPRq/X6xFCCCGEEFdE29gdEEIIIYS4EUhQJYQQQgjRACSoEkIIIYRoABJUCSGEEEI0AAmqhBBCCCEagARVQgghhBANQIIqIYQQQogGYN7YHbiZVFZWkpqaiq2tLRqNprG7I4QQQog60Ov1FBQU4OHhgVZ74fEoCaquotTUVHr06NHY3RBCCCFEPaxfvx4vL68Lvi9B1VVka2sLqD8UOzu7Ru6NEEIIIeoiPz+fHj16GH6OX4gEVVd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Mnj2b48eP1/uzCiGujJu9Ff93f3t6B3vg6WDJ832DuD3Mq7G7JRqZjFRdpzw9Pfnuu++YOXMmY8eOpbS0FB8fH7p162ZYUffkk09iZmbG7NmzSU1Nxd3d3ZCXY21tzcKFC5k5cybjx4+noKAAT09PIiMjL2vkasKECbzxxhv06dOH0tJSjh49esG2d999N3v27GH
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"recently_remodeled\", s=15, data=df);"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 97,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"del df[\"Yr Sold\"]\n",
"del df[\"Year Built\"]\n",
"del df[\"Year Remod/Add\"]"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 98,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"age_columns = [\n",
" \"remodeled\", \"years_since_built\", \"years_since_remodeled\",\n",
" \"recently_built\", \"recently_remodeled\",\n",
"]\n",
"new_variables.extend(age_columns)"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 99,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>remodeled</th>\n",
" <th>years_since_built</th>\n",
" <th>years_since_remodeled</th>\n",
" <th>recently_built</th>\n",
" <th>recently_remodeled</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>0</td>\n",
" <td>50</td>\n",
" <td>50</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>0</td>\n",
" <td>49</td>\n",
" <td>49</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>0</td>\n",
" <td>52</td>\n",
" <td>52</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>0</td>\n",
" <td>42</td>\n",
" <td>42</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>1</td>\n",
" <td>13</td>\n",
" <td>12</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" remodeled years_since_built years_since_remodeled \\\n",
"Order PID \n",
"1 526301100 0 50 50 \n",
"2 526350040 0 49 49 \n",
"3 526351010 0 52 52 \n",
"4 526353030 0 42 42 \n",
"5 527105010 1 13 12 \n",
"\n",
" recently_built recently_remodeled \n",
"Order PID \n",
"1 526301100 0 0 \n",
"2 526350040 0 0 \n",
"3 526351010 0 0 \n",
"4 526353030 0 0 \n",
"5 527105010 0 0 "
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 99,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[age_columns].head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Outliers\n",
"\n",
"The instructors' notes state:\n",
"\n",
"> **Five observations** that an instructor may wish to remove from the data set before giving it to students (a plot of SALE PRICE versus GR LIV AREA will quickly indicate these\n",
"points). Three of them are true **outliers** (Partial Sales that likely don’t represent actual market values) and two of them are simply unusual sales (very large houses priced\n",
"relatively appropriately). I would **recommend removing any houses with more than\n",
"4000 square feet** from the data set (which eliminates these five unusual observations)\n",
"before assigning it to students.\n",
"\n",
"To apply a more \"rigorous\" approach, outlier detection is conducted with a so-called Isolation Forest."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 100,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"# Use only numeric columns that are strongly correlated with the target.\n",
"# This mitigates the risk that a \"not so good\" chosen factor variable introduced\n",
"# in this notebook causes an observation to be removed as an outlier.\n",
"with open(\"data/correlated_variables.json\", \"r\") as file:\n",
" content = json.loads(file.read())\n",
"strongly_correlated = content[\"strongly_correlated\"]\n",
"df_encoded = encode_ordinals(df[list(set(strongly_correlated) & set(df.columns))])\n",
2024-07-10 01:31:28 +02:00
"iso = IsolationForest(n_estimators=100, bootstrap=True, contamination=0.005, random_state=random_state)\n",
2021-05-25 08:22:14 +02:00
"outliers = pd.DataFrame(\n",
" iso.fit_predict(df_encoded), columns=[\"outlier\"], index=df.index\n",
")\n",
"outliers[\"outlier\"] = outliers[\"outlier\"].apply(lambda x: 1 if x < 0 else 0)\n",
"df = pd.concat([df, outliers], axis=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The five aforementioned outliers are among the ones detected."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 101,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
2024-07-10 01:48:08 +02:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAlUAAAGwCAYAAACAZ5AeAAAAOXRFWHRTb2Z0d2FyZ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qFc++ZqXhpVMfkflqtlr59+7Js2TL3MYfDwbJlyxg4cOAxuSeA+phd+QjNmzeP0aNHExYW1tuhCCGEEKKHpYb58H+XDaCx3UqAQXPMEqo9pkyZwiOPPEJmZiZZWVm8//77dHR0cPHFFx+ze54QSVV5eTlLly7l1VdfdR8LDg7GarXS0tLiMUJUX19PSEiI+5z9d+ntGV3a95z9F6XV1dVhNBrR6XQolcrDDhF2JxYhhBBCHJqXRkW437FNpvaYMGECDQ0NvPLKK9TW1pKRkcFbb7118k//zZ8/n6CgIE477TT3sczMTDQajcfQXWFhIRUVFQwYMACAAQMGsH37do+EaOnSpRiNRpKTk93nLF++3ON+S5cudV+jO0OE3YlFCCGEECeWa665hoULF7Jp0yY+/fRT+vfvf0zv1+sjVQ6Hg/nz53PRRRehVu8Nx8fHh0mTJjF9+nT8/PwwGo1MmzaNgQMHuhOZ3NxckpOTefjhh3nooYeora1lxowZXH311Wi1WgCuuOIKZs2axYsvvsikSZNYvnw5CxYsYObMme57HW6IsDuxCCGEEOLU1utJ1dKlS6moqGDSpEldnnv88cdRKpXcfffdWCwWcnNzefLJJ93Pq1QqXn/9dZ566ikuv/xy9Ho9EydO5O6773afExMTw8yZM3n++ef54IMPCA8PZ9q0aYwaNcp9TneGCA8XixBCCCFObQqn0+n
2021-05-25 08:22:14 +02:00
"text/plain": [
2024-07-10 01:48:08 +02:00
"<Figure size 640x480 with 1 Axes>"
2021-05-25 08:22:14 +02:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sns.scatterplot(x=\"Gr Liv Area\", y=\"SalePrice\", hue=\"outlier\", s=15, data=df);"
]
},
2024-07-10 01:31:28 +02:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We concur with the notes from the paper and remove only the sales of houses with more than 4000 square feet."
]
},
2021-05-25 08:22:14 +02:00
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 102,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"# Remove the outliers.\n",
2024-07-10 01:31:28 +02:00
"df = df[df[\"Gr Liv Area\"] <= 4000]"
2021-05-25 08:22:14 +02:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Save the Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Save the Data"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 103,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"# Re-order the columns for convenience.\n",
"final_columns = (\n",
" sorted(set(list(ALL_COLUMNS.keys()) + new_variables) & set(df.columns))\n",
" + TARGET_VARIABLES\n",
")\n",
"df = df[final_columns]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Discarding useless and adding new predictors changed the final dataset significantly."
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 104,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2024-07-10 01:31:28 +02:00
"(2893, 109)"
2021-05-25 08:22:14 +02:00
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 104,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 105,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th></th>\n",
" <th>1st Flr SF</th>\n",
" <th>1st Flr SF (box-cox-0)</th>\n",
" <th>2nd Flr SF</th>\n",
" <th>3Ssn Porch</th>\n",
" <th>Bedroom AbvGr</th>\n",
" <th>Bsmt Cond</th>\n",
" <th>Bsmt Exposure</th>\n",
" <th>Bsmt Full Bath</th>\n",
" <th>Bsmt Half Bath</th>\n",
" <th>Bsmt Qual</th>\n",
" <th>Bsmt Unf SF</th>\n",
" <th>BsmtFin SF 1</th>\n",
" <th>BsmtFin SF 2</th>\n",
" <th>BsmtFin Type 1</th>\n",
" <th>BsmtFin Type 2</th>\n",
" <th>Electrical</th>\n",
" <th>Enclosed Porch</th>\n",
" <th>Fence</th>\n",
" <th>Fireplace Qu</th>\n",
" <th>Fireplaces</th>\n",
" <th>Full Bath</th>\n",
" <th>Functional</th>\n",
" <th>Garage Area</th>\n",
" <th>Garage Cars</th>\n",
" <th>Garage Cond</th>\n",
" <th>Garage Finish</th>\n",
" <th>Garage Qual</th>\n",
" <th>Gr Liv Area</th>\n",
" <th>Gr Liv Area (box-cox-0)</th>\n",
" <th>Half Bath</th>\n",
" <th>Kitchen AbvGr</th>\n",
" <th>Kitchen Qual</th>\n",
" <th>Land Slope</th>\n",
" <th>Lot Area</th>\n",
" <th>Lot Area (box-cox-0.1)</th>\n",
" <th>Lot Shape</th>\n",
" <th>Low Qual Fin SF</th>\n",
" <th>Mas Vnr Area</th>\n",
" <th>Misc Val</th>\n",
" <th>Mo Sold</th>\n",
" <th>Open Porch SF</th>\n",
" <th>Overall Cond</th>\n",
" <th>Overall Qual</th>\n",
" <th>Paved Drive</th>\n",
" <th>Pool Area</th>\n",
" <th>Pool QC</th>\n",
" <th>Screen Porch</th>\n",
" <th>TotRms AbvGrd</th>\n",
" <th>Total Bath</th>\n",
" <th>Total Bsmt SF</th>\n",
" <th>Total Porch SF</th>\n",
" <th>Total SF</th>\n",
" <th>Total SF (box-cox-0.2)</th>\n",
" <th>Utilities</th>\n",
" <th>Wood Deck SF</th>\n",
" <th>abnormal_sale</th>\n",
" <th>air_cond</th>\n",
" <th>build_type_1Fam</th>\n",
" <th>build_type_2Fam</th>\n",
" <th>build_type_Twnhs</th>\n",
" <th>found_BrkTil</th>\n",
" <th>found_CBlock</th>\n",
" <th>found_PConc</th>\n",
" <th>has 2nd Flr</th>\n",
" <th>has Bsmt</th>\n",
" <th>has Fireplace</th>\n",
" <th>has Garage</th>\n",
" <th>has Pool</th>\n",
" <th>has Porch</th>\n",
" <th>major_street</th>\n",
" <th>new_home</th>\n",
" <th>nhood_Blmngtn</th>\n",
" <th>nhood_Blueste</th>\n",
" <th>nhood_BrDale</th>\n",
" <th>nhood_BrkSide</th>\n",
" <th>nhood_ClearCr</th>\n",
" <th>nhood_CollgCr</th>\n",
" <th>nhood_Crawfor</th>\n",
" <th>nhood_Edwards</th>\n",
" <th>nhood_Gilbert</th>\n",
" <th>nhood_Greens</th>\n",
" <th>nhood_GrnHill</th>\n",
" <th>nhood_IDOTRR</th>\n",
" <th>nhood_Landmrk</th>\n",
" <th>nhood_MeadowV</th>\n",
" <th>nhood_Mitchel</th>\n",
" <th>nhood_NPkVill</th>\n",
" <th>nhood_NWAmes</th>\n",
" <th>nhood_Names</th>\n",
" <th>nhood_NoRidge</th>\n",
" <th>nhood_NridgHt</th>\n",
" <th>nhood_OldTown</th>\n",
" <th>nhood_SWISU</th>\n",
" <th>nhood_Sawyer</th>\n",
" <th>nhood_SawyerW</th>\n",
" <th>nhood_Somerst</th>\n",
" <th>nhood_StoneBr</th>\n",
" <th>nhood_Timber</th>\n",
" <th>nhood_Veenker</th>\n",
" <th>park</th>\n",
" <th>partial_sale</th>\n",
" <th>railway</th>\n",
" <th>recently_built</th>\n",
" <th>recently_remodeled</th>\n",
" <th>remodeled</th>\n",
" <th>years_since_built</th>\n",
" <th>years_since_remodeled</th>\n",
" <th>SalePrice</th>\n",
" <th>SalePrice (box-cox-0)</th>\n",
" </tr>\n",
" <tr>\n",
" <th>Order</th>\n",
" <th>PID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1</th>\n",
" <th>526301100</th>\n",
" <td>1656.0</td>\n",
" <td>7.412160</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3</td>\n",
" <td>Gd</td>\n",
" <td>Gd</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>441.0</td>\n",
" <td>639.0</td>\n",
" <td>0.0</td>\n",
" <td>BLQ</td>\n",
" <td>Unf</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>Gd</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" <td>Typ</td>\n",
" <td>528.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>Fin</td>\n",
" <td>TA</td>\n",
" <td>1656.0</td>\n",
" <td>7.412160</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Gtl</td>\n",
" <td>31770.0</td>\n",
" <td>18.196923</td>\n",
" <td>IR1</td>\n",
" <td>0.0</td>\n",
" <td>112.0</td>\n",
" <td>0.0</td>\n",
" <td>5</td>\n",
" <td>62.0</td>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>P</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>7</td>\n",
" <td>2.0</td>\n",
" <td>1080.0</td>\n",
" <td>272.0</td>\n",
" <td>2736.0</td>\n",
" <td>19.344072</td>\n",
" <td>AllPub</td>\n",
" <td>210.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>50</td>\n",
" <td>50</td>\n",
" <td>215000.0</td>\n",
" <td>12.278393</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <th>526350040</th>\n",
" <td>896.0</td>\n",
" <td>6.797940</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>270.0</td>\n",
" <td>468.0</td>\n",
" <td>144.0</td>\n",
" <td>Rec</td>\n",
" <td>LwQ</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>MnPrv</td>\n",
" <td>NA</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Typ</td>\n",
" <td>730.0</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Unf</td>\n",
" <td>TA</td>\n",
" <td>896.0</td>\n",
" <td>6.797940</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Gtl</td>\n",
" <td>11622.0</td>\n",
" <td>15.499290</td>\n",
" <td>Reg</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>6</td>\n",
" <td>0.0</td>\n",
" <td>6</td>\n",
" <td>5</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>120.0</td>\n",
" <td>5</td>\n",
" <td>1.0</td>\n",
" <td>882.0</td>\n",
" <td>260.0</td>\n",
" <td>1778.0</td>\n",
" <td>17.333478</td>\n",
" <td>AllPub</td>\n",
" <td>140.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>49</td>\n",
" <td>49</td>\n",
" <td>105000.0</td>\n",
" <td>11.561716</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <th>526351010</th>\n",
" <td>1329.0</td>\n",
" <td>7.192182</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>406.0</td>\n",
" <td>923.0</td>\n",
" <td>0.0</td>\n",
" <td>ALQ</td>\n",
" <td>Unf</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>NA</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>Typ</td>\n",
" <td>312.0</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Unf</td>\n",
" <td>TA</td>\n",
" <td>1329.0</td>\n",
" <td>7.192182</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Gd</td>\n",
" <td>Gtl</td>\n",
" <td>14267.0</td>\n",
" <td>16.027549</td>\n",
" <td>IR1</td>\n",
" <td>0.0</td>\n",
" <td>108.0</td>\n",
" <td>12500.0</td>\n",
" <td>6</td>\n",
" <td>36.0</td>\n",
" <td>6</td>\n",
" <td>6</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>6</td>\n",
" <td>1.5</td>\n",
" <td>1329.0</td>\n",
" <td>429.0</td>\n",
" <td>2658.0</td>\n",
" <td>19.203658</td>\n",
" <td>AllPub</td>\n",
" <td>393.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>52</td>\n",
" <td>52</td>\n",
" <td>172000.0</td>\n",
" <td>12.055250</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <th>526353030</th>\n",
" <td>2110.0</td>\n",
" <td>7.654443</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>TA</td>\n",
" <td>1045.0</td>\n",
" <td>1065.0</td>\n",
" <td>0.0</td>\n",
" <td>ALQ</td>\n",
" <td>Unf</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>TA</td>\n",
" <td>2</td>\n",
" <td>2</td>\n",
" <td>Typ</td>\n",
" <td>522.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>Fin</td>\n",
" <td>TA</td>\n",
" <td>2110.0</td>\n",
" <td>7.654443</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>Ex</td>\n",
" <td>Gtl</td>\n",
" <td>11160.0</td>\n",
" <td>15.396064</td>\n",
" <td>Reg</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>4</td>\n",
" <td>0.0</td>\n",
" <td>5</td>\n",
" <td>7</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>8</td>\n",
" <td>3.5</td>\n",
" <td>2110.0</td>\n",
" <td>0.0</td>\n",
" <td>4220.0</td>\n",
" <td>21.548042</td>\n",
" <td>AllPub</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>42</td>\n",
" <td>42</td>\n",
" <td>244000.0</td>\n",
" <td>12.404924</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <th>527105010</th>\n",
" <td>928.0</td>\n",
" <td>6.833032</td>\n",
" <td>701.0</td>\n",
" <td>0.0</td>\n",
" <td>3</td>\n",
" <td>TA</td>\n",
" <td>No</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>Gd</td>\n",
" <td>137.0</td>\n",
" <td>791.0</td>\n",
" <td>0.0</td>\n",
" <td>GLQ</td>\n",
" <td>Unf</td>\n",
" <td>SBrkr</td>\n",
" <td>0.0</td>\n",
" <td>MnPrv</td>\n",
" <td>TA</td>\n",
" <td>1</td>\n",
" <td>2</td>\n",
" <td>Typ</td>\n",
" <td>482.0</td>\n",
" <td>2</td>\n",
" <td>TA</td>\n",
" <td>Fin</td>\n",
" <td>TA</td>\n",
" <td>1629.0</td>\n",
" <td>7.395722</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>TA</td>\n",
" <td>Gtl</td>\n",
" <td>13830.0</td>\n",
" <td>15.946705</td>\n",
" <td>IR1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>3</td>\n",
" <td>34.0</td>\n",
" <td>5</td>\n",
" <td>5</td>\n",
" <td>Y</td>\n",
" <td>0.0</td>\n",
" <td>NA</td>\n",
" <td>0.0</td>\n",
" <td>6</td>\n",
" <td>2.5</td>\n",
" <td>928.0</td>\n",
" <td>246.0</td>\n",
" <td>2557.0</td>\n",
" <td>19.016856</td>\n",
" <td>AllPub</td>\n",
" <td>212.0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>13</td>\n",
" <td>12</td>\n",
" <td>189900.0</td>\n",
" <td>12.154253</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 1st Flr SF 1st Flr SF (box-cox-0) 2nd Flr SF 3Ssn Porch \\\n",
"Order PID \n",
"1 526301100 1656.0 7.412160 0.0 0.0 \n",
"2 526350040 896.0 6.797940 0.0 0.0 \n",
"3 526351010 1329.0 7.192182 0.0 0.0 \n",
"4 526353030 2110.0 7.654443 0.0 0.0 \n",
"5 527105010 928.0 6.833032 701.0 0.0 \n",
"\n",
" Bedroom AbvGr Bsmt Cond Bsmt Exposure Bsmt Full Bath \\\n",
"Order PID \n",
"1 526301100 3 Gd Gd 1 \n",
"2 526350040 2 TA No 0 \n",
"3 526351010 3 TA No 0 \n",
"4 526353030 3 TA No 1 \n",
"5 527105010 3 TA No 0 \n",
"\n",
" Bsmt Half Bath Bsmt Qual Bsmt Unf SF BsmtFin SF 1 \\\n",
"Order PID \n",
"1 526301100 0 TA 441.0 639.0 \n",
"2 526350040 0 TA 270.0 468.0 \n",
"3 526351010 0 TA 406.0 923.0 \n",
"4 526353030 0 TA 1045.0 1065.0 \n",
"5 527105010 0 Gd 137.0 791.0 \n",
"\n",
" BsmtFin SF 2 BsmtFin Type 1 BsmtFin Type 2 Electrical \\\n",
"Order PID \n",
"1 526301100 0.0 BLQ Unf SBrkr \n",
"2 526350040 144.0 Rec LwQ SBrkr \n",
"3 526351010 0.0 ALQ Unf SBrkr \n",
"4 526353030 0.0 ALQ Unf SBrkr \n",
"5 527105010 0.0 GLQ Unf SBrkr \n",
"\n",
" Enclosed Porch Fence Fireplace Qu Fireplaces Full Bath \\\n",
"Order PID \n",
"1 526301100 0.0 NA Gd 2 1 \n",
"2 526350040 0.0 MnPrv NA 0 1 \n",
"3 526351010 0.0 NA NA 0 1 \n",
"4 526353030 0.0 NA TA 2 2 \n",
"5 527105010 0.0 MnPrv TA 1 2 \n",
"\n",
" Functional Garage Area Garage Cars Garage Cond \\\n",
"Order PID \n",
"1 526301100 Typ 528.0 2 TA \n",
"2 526350040 Typ 730.0 1 TA \n",
"3 526351010 Typ 312.0 1 TA \n",
"4 526353030 Typ 522.0 2 TA \n",
"5 527105010 Typ 482.0 2 TA \n",
"\n",
" Garage Finish Garage Qual Gr Liv Area \\\n",
"Order PID \n",
"1 526301100 Fin TA 1656.0 \n",
"2 526350040 Unf TA 896.0 \n",
"3 526351010 Unf TA 1329.0 \n",
"4 526353030 Fin TA 2110.0 \n",
"5 527105010 Fin TA 1629.0 \n",
"\n",
" Gr Liv Area (box-cox-0) Half Bath Kitchen AbvGr \\\n",
"Order PID \n",
"1 526301100 7.412160 0 1 \n",
"2 526350040 6.797940 0 1 \n",
"3 526351010 7.192182 1 1 \n",
"4 526353030 7.654443 1 1 \n",
"5 527105010 7.395722 1 1 \n",
"\n",
" Kitchen Qual Land Slope Lot Area Lot Area (box-cox-0.1) \\\n",
"Order PID \n",
"1 526301100 TA Gtl 31770.0 18.196923 \n",
"2 526350040 TA Gtl 11622.0 15.499290 \n",
"3 526351010 Gd Gtl 14267.0 16.027549 \n",
"4 526353030 Ex Gtl 11160.0 15.396064 \n",
"5 527105010 TA Gtl 13830.0 15.946705 \n",
"\n",
" Lot Shape Low Qual Fin SF Mas Vnr Area Misc Val Mo Sold \\\n",
"Order PID \n",
"1 526301100 IR1 0.0 112.0 0.0 5 \n",
"2 526350040 Reg 0.0 0.0 0.0 6 \n",
"3 526351010 IR1 0.0 108.0 12500.0 6 \n",
"4 526353030 Reg 0.0 0.0 0.0 4 \n",
"5 527105010 IR1 0.0 0.0 0.0 3 \n",
"\n",
" Open Porch SF Overall Cond Overall Qual Paved Drive \\\n",
"Order PID \n",
"1 526301100 62.0 5 6 P \n",
"2 526350040 0.0 6 5 Y \n",
"3 526351010 36.0 6 6 Y \n",
"4 526353030 0.0 5 7 Y \n",
"5 527105010 34.0 5 5 Y \n",
"\n",
" Pool Area Pool QC Screen Porch TotRms AbvGrd Total Bath \\\n",
"Order PID \n",
"1 526301100 0.0 NA 0.0 7 2.0 \n",
"2 526350040 0.0 NA 120.0 5 1.0 \n",
"3 526351010 0.0 NA 0.0 6 1.5 \n",
"4 526353030 0.0 NA 0.0 8 3.5 \n",
"5 527105010 0.0 NA 0.0 6 2.5 \n",
"\n",
" Total Bsmt SF Total Porch SF Total SF \\\n",
"Order PID \n",
"1 526301100 1080.0 272.0 2736.0 \n",
"2 526350040 882.0 260.0 1778.0 \n",
"3 526351010 1329.0 429.0 2658.0 \n",
"4 526353030 2110.0 0.0 4220.0 \n",
"5 527105010 928.0 246.0 2557.0 \n",
"\n",
" Total SF (box-cox-0.2) Utilities Wood Deck SF \\\n",
"Order PID \n",
"1 526301100 19.344072 AllPub 210.0 \n",
"2 526350040 17.333478 AllPub 140.0 \n",
"3 526351010 19.203658 AllPub 393.0 \n",
"4 526353030 21.548042 AllPub 0.0 \n",
"5 527105010 19.016856 AllPub 212.0 \n",
"\n",
" abnormal_sale air_cond build_type_1Fam build_type_2Fam \\\n",
"Order PID \n",
"1 526301100 0 1 1 0 \n",
"2 526350040 0 1 1 0 \n",
"3 526351010 0 1 1 0 \n",
"4 526353030 0 1 1 0 \n",
"5 527105010 0 1 1 0 \n",
"\n",
" build_type_Twnhs found_BrkTil found_CBlock found_PConc \\\n",
"Order PID \n",
"1 526301100 0 0 1 0 \n",
"2 526350040 0 0 1 0 \n",
"3 526351010 0 0 1 0 \n",
"4 526353030 0 0 1 0 \n",
"5 527105010 0 0 0 1 \n",
"\n",
" has 2nd Flr has Bsmt has Fireplace has Garage has Pool \\\n",
"Order PID \n",
"1 526301100 0 1 1 1 0 \n",
"2 526350040 0 1 0 1 0 \n",
"3 526351010 0 1 0 1 0 \n",
"4 526353030 0 1 1 1 0 \n",
"5 527105010 1 1 1 1 0 \n",
"\n",
" has Porch major_street new_home nhood_Blmngtn \\\n",
"Order PID \n",
"1 526301100 1 0 0 0 \n",
"2 526350040 1 1 0 0 \n",
"3 526351010 1 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 1 0 0 0 \n",
"\n",
" nhood_Blueste nhood_BrDale nhood_BrkSide nhood_ClearCr \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_CollgCr nhood_Crawfor nhood_Edwards nhood_Gilbert \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 1 \n",
"\n",
" nhood_Greens nhood_GrnHill nhood_IDOTRR nhood_Landmrk \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_MeadowV nhood_Mitchel nhood_NPkVill nhood_NWAmes \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_Names nhood_NoRidge nhood_NridgHt nhood_OldTown \\\n",
"Order PID \n",
"1 526301100 1 0 0 0 \n",
"2 526350040 1 0 0 0 \n",
"3 526351010 1 0 0 0 \n",
"4 526353030 1 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_SWISU nhood_Sawyer nhood_SawyerW nhood_Somerst \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" nhood_StoneBr nhood_Timber nhood_Veenker park \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" partial_sale railway recently_built recently_remodeled \\\n",
"Order PID \n",
"1 526301100 0 0 0 0 \n",
"2 526350040 0 0 0 0 \n",
"3 526351010 0 0 0 0 \n",
"4 526353030 0 0 0 0 \n",
"5 527105010 0 0 0 0 \n",
"\n",
" remodeled years_since_built years_since_remodeled \\\n",
"Order PID \n",
"1 526301100 0 50 50 \n",
"2 526350040 0 49 49 \n",
"3 526351010 0 52 52 \n",
"4 526353030 0 42 42 \n",
"5 527105010 1 13 12 \n",
"\n",
" SalePrice SalePrice (box-cox-0) \n",
"Order PID \n",
"1 526301100 215000.0 12.278393 \n",
"2 526350040 105000.0 11.561716 \n",
"3 526351010 172000.0 12.055250 \n",
"4 526353030 244000.0 12.404924 \n",
"5 527105010 189900.0 12.154253 "
]
},
2024-07-10 01:31:28 +02:00
"execution_count": 105,
2021-05-25 08:22:14 +02:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "code",
2024-07-10 01:31:28 +02:00
"execution_count": 106,
2021-05-25 08:22:14 +02:00
"metadata": {},
"outputs": [],
"source": [
"df.to_csv(\"data/data_clean_with_transformations_and_factors.csv\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ames-housing",
2021-05-25 08:22:14 +02:00
"language": "python",
"name": "ames-housing"
2021-05-25 08:22:14 +02:00
},
"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.12.4"
2021-05-25 08:22:14 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 4
}