{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Correlation Plot\n", "\n", "The `corr_plot` builder takes a dataframe (can be Pandas `Dataframe` or just Python `dict`) as the input and \n", "builds a correlation plot.\n", "\n", "It allows to combine 'tile', 'point' or 'label' layers in a matrix of 'full', 'lower' or 'upper' type.\n", "\n", "A call to the terminal `build()` method will create a resulting 'plot' object. \n", "This 'plot' object can be further refined using regular Lets-Plot (ggplot) API, like `+ ggtitle()`, `+ ggsize()` and so on.\n", "\n", "\n", "The Ames Housing dataset for this demo was downloaded from [House Prices - Advanced Regression Techniques](https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data?select=train.csv) (train.csv), (c) Kaggle." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:15.544612Z", "iopub.status.busy": "2024-04-17T07:33:15.544467Z", "iopub.status.idle": "2024-04-17T07:33:15.874773Z", "shell.execute_reply": "2024-04-17T07:33:15.874452Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from lets_plot import *\n", "from lets_plot.bistro.corr import *\n", "\n", "LetsPlot.setup_html()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-04-17T07:33:15.887781Z", "iopub.status.busy": "2024-04-17T07:33:15.887642Z", "iopub.status.idle": "2024-04-17T07:33:16.024441Z", "shell.execute_reply": "2024-04-17T07:33:16.024259Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(234, 5)\n" ] }, { "data": { "text/html": [ "\n", " | displ | \n", "year | \n", "cyl | \n", "cty | \n", "hwy | \n", "
---|---|---|---|---|---|
0 | \n", "1.8 | \n", "1999 | \n", "4 | \n", "18 | \n", "29 | \n", "
1 | \n", "1.8 | \n", "1999 | \n", "4 | \n", "21 | \n", "29 | \n", "
2 | \n", "2.0 | \n", "2008 | \n", "4 | \n", "20 | \n", "31 | \n", "
3 | \n", "2.0 | \n", "2008 | \n", "4 | \n", "21 | \n", "30 | \n", "
4 | \n", "2.8 | \n", "1999 | \n", "6 | \n", "16 | \n", "26 | \n", "
\n", " | Id | \n", "MSSubClass | \n", "LotFrontage | \n", "LotArea | \n", "OverallQual | \n", "OverallCond | \n", "YearBuilt | \n", "YearRemodAdd | \n", "MasVnrArea | \n", "BsmtFinSF1 | \n", "... | \n", "WoodDeckSF | \n", "OpenPorchSF | \n", "EnclosedPorch | \n", "3SsnPorch | \n", "ScreenPorch | \n", "PoolArea | \n", "MiscVal | \n", "MoSold | \n", "YrSold | \n", "SalePrice | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "1 | \n", "60 | \n", "65.0 | \n", "8450 | \n", "7 | \n", "5 | \n", "2003 | \n", "2003 | \n", "196.0 | \n", "706 | \n", "... | \n", "0 | \n", "61 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "2 | \n", "2008 | \n", "208500 | \n", "
1 | \n", "2 | \n", "20 | \n", "80.0 | \n", "9600 | \n", "6 | \n", "8 | \n", "1976 | \n", "1976 | \n", "0.0 | \n", "978 | \n", "... | \n", "298 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "5 | \n", "2007 | \n", "181500 | \n", "
2 | \n", "3 | \n", "60 | \n", "68.0 | \n", "11250 | \n", "7 | \n", "5 | \n", "2001 | \n", "2002 | \n", "162.0 | \n", "486 | \n", "... | \n", "0 | \n", "42 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "9 | \n", "2008 | \n", "223500 | \n", "
3 | \n", "4 | \n", "70 | \n", "60.0 | \n", "9550 | \n", "7 | \n", "5 | \n", "1915 | \n", "1970 | \n", "0.0 | \n", "216 | \n", "... | \n", "0 | \n", "35 | \n", "272 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "2 | \n", "2006 | \n", "140000 | \n", "
4 | \n", "5 | \n", "60 | \n", "84.0 | \n", "14260 | \n", "8 | \n", "5 | \n", "2000 | \n", "2000 | \n", "350.0 | \n", "655 | \n", "... | \n", "192 | \n", "84 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "12 | \n", "2008 | \n", "250000 | \n", "
5 rows × 38 columns
\n", "