Files
fenago f3b24b4b7f added
2021-02-07 15:16:01 +05:00

251 lines
5.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "lPeZ4zc4NZ3G"
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import altair as alt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "aPjMg_BfNjk7"
},
"outputs": [],
"source": [
"file_url = '../dataset/ames_iowa_housing.csv'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "6ynf1L9mOm0p"
},
"outputs": [],
"source": [
"df = pd.read_csv(file_url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 368
},
"colab_type": "code",
"id": "HBrQ-CWkPEjz",
"outputId": "36f00063-0388-42b5-fc23-0e49a2b97004"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_bar().encode(\n",
" alt.X(\"SalePrice:Q\", bin=alt.Bin(step=50000)), \n",
" y='count()'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 368
},
"colab_type": "code",
"id": "_TPQ-tfOPWo4",
"outputId": "ac8ccbe2-2ee5-4833-c340-17fc14baff62"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_bar().encode(\n",
" alt.X(\"LotArea:Q\", bin=alt.Bin(step=10000)), \n",
" y='count()'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 368
},
"colab_type": "code",
"id": "kwNy-WmyooY4",
"outputId": "e9fd0260-3a83-4edb-8df7-dcc733952b1c"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_circle().encode(\n",
" x='LotArea:Q',\n",
" y='SalePrice:Q'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 368
},
"colab_type": "code",
"id": "iRPDz3e0PW9w",
"outputId": "b68c651e-3484-484d-8d41-ce5dc488d3fe"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_bar().encode(\n",
" alt.X(\"OverallCond\", bin=True), \n",
" y='count()'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 364
},
"colab_type": "code",
"id": "akIGJh94tSWh",
"outputId": "a0a447e4-bd33-47d1-e400-73777f7dedf3"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_boxplot().encode(\n",
" x='OverallCond:O',\n",
" y='SalePrice:Q'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 381
},
"colab_type": "code",
"id": "Yt8fjkjiP4oO",
"outputId": "ee5af1bc-69e7-4911-d73e-50336e1081f7"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_bar().encode(\n",
" alt.X('YrSold:O'),\n",
" y='count()'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 381
},
"colab_type": "code",
"id": "eiBCcsMaO-R9",
"outputId": "2edfb3f2-d893-48fa-d59f-8c9edcdebab6"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_boxplot().encode(\n",
" x='YrSold:O',\n",
" y='SalePrice:Q'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 403
},
"colab_type": "code",
"id": "bUUtvOSEOf0q",
"outputId": "dc698d30-6b69-404c-e268-e09f9be505f2"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_bar().encode(\n",
" x='Neighborhood',\n",
" y='count()'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 403
},
"colab_type": "code",
"id": "VP1dedrbKJ3Z",
"outputId": "3a9b8cfa-0805-42c6-b672-4aa0d3e11b2a"
},
"outputs": [],
"source": [
"alt.Chart(df).mark_boxplot().encode(\n",
" x='Neighborhood:O',\n",
" y='SalePrice:Q'\n",
")"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "Exercise10_04.ipynb",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}