{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"using VMLS, Plots"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Dict{String,Array{T,1} where T} with 6 entries:\n",
" \"baths\" => [2, 2, 2, 2, 1, 2, 2, 1, 1, 1 … 2, 2, 2, 2, 2, 3, 2, 2, 2, 2]\n",
" \"location\" => [2, 2, 2, 3, 3, 2, 2, 2, 2, 2 … 3, 4, 3, 3, 3, 3, 3, 2, 3, 4]\n",
" \"price\" => [94.905, 98.937, 100.309, 106.25, 107.502, 108.75, 110.7, 113.2…\n",
" \"beds\" => [2, 3, 3, 3, 3, 2, 2, 2, 2, 2 … 3, 3, 4, 4, 3, 4, 3, 3, 4, 3]\n",
" \"area\" => [0.941, 1.146, 0.909, 1.289, 1.02, 1.022, 1.134, 0.844, 0.795, …\n",
" \"condo\" => [1, 0, 0, 0, 0, 0, 1, 0, 1, 0 … 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"D=house_sales_data()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"price=D[\"price\"];"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"beds=D[\"beds\"];\n",
"area=D[\"area\"];"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"beds[1]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"beds[2]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Array{Float64,1}:\n",
" 0.941\n",
" 2.0"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x=[area[1],beds[1]]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Array{Float64,1}:\n",
" 148.73\n",
" -18.85"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"beta=[148.73,-18.85]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"54.4"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"v=54.40"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"156.65492999999998"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"haty=x'*beta+v"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"94.905"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"price[1]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"scatter([price[1]],[haty])"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot!([1:800],[1:800])"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Float64,1}:\n",
" 1.0\n",
" 0.941\n",
" 2.0"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tildex=[1;x]"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Float64,1}:\n",
" 54.4\n",
" 148.73\n",
" -18.85"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"p=[v;beta]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"156.65492999999998"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tildex'*p"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"156.65492999999998"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"haty"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Float64,1}:\n",
" 1.0\n",
" 1.146\n",
" 3.0"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"house2=[1,area[2],beds[2]]"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2×3 Array{Float64,2}:\n",
" 1.0 0.941 2.0\n",
" 1.0 1.146 3.0"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T=[tildex';house2']"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"774"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"length(beds)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"774×3 Array{Float64,2}:\n",
" 1.0 0.941 2.0\n",
" 1.0 1.146 3.0\n",
" 1.0 0.909 3.0\n",
" 1.0 1.289 3.0\n",
" 1.0 1.02 3.0\n",
" 1.0 1.022 2.0\n",
" 1.0 1.134 2.0\n",
" 1.0 0.844 2.0\n",
" 1.0 0.795 2.0\n",
" 1.0 0.588 2.0\n",
" 1.0 1.356 3.0\n",
" 1.0 1.118 3.0\n",
" 1.0 1.329 4.0\n",
" ⋮ \n",
" 1.0 0.96 3.0\n",
" 1.0 1.456 3.0\n",
" 1.0 1.45 3.0\n",
" 1.0 1.358 3.0\n",
" 1.0 1.329 4.0\n",
" 1.0 1.715 4.0\n",
" 1.0 1.262 3.0\n",
" 1.0 2.28 4.0\n",
" 1.0 1.477 3.0\n",
" 1.0 1.216 3.0\n",
" 1.0 1.685 4.0\n",
" 1.0 1.362 3.0"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"T=[ones(774) area beds]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"774-element Array{Float64,1}:\n",
" 156.65492999999998\n",
" 168.29457999999997\n",
" 133.04556999999997\n",
" 189.56296999999995\n",
" 149.5546\n",
" 168.70205999999996\n",
" 185.35981999999996\n",
" 142.22812\n",
" 134.94034999999997\n",
" 104.15324\n",
" 199.52787999999998\n",
" 164.13013999999998\n",
" 176.66216999999997\n",
" ⋮\n",
" 140.63079999999997\n",
" 214.40087999999997\n",
" 213.50849999999997\n",
" 199.82533999999998\n",
" 176.66216999999997\n",
" 234.07195\n",
" 185.54725999999997\n",
" 318.10439999999994\n",
" 217.52420999999998\n",
" 178.70567999999997\n",
" 229.61004999999997\n",
" 200.42025999999998"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"estprice=T*p"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"