{ "cells": [ { "cell_type": "markdown", "id": "18bdba27", "metadata": {}, "source": [ "# PW4 - Linear Regression" ] }, { "cell_type": "markdown", "id": "3629bfdf", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": 454, "id": "d6eb2aab", "metadata": {}, "outputs": [], "source": [ "import random\n", "import pandas as pd\n", "import numpy as np\n", "from numpy.linalg import inv\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "e69e5d68", "metadata": {}, "source": [ "## Load data" ] }, { "cell_type": "markdown", "id": "ba14bf9f", "metadata": {}, "source": [ "Define the path to the file containing the data" ] }, { "cell_type": "code", "execution_count": 455, "id": "5f3f924f", "metadata": {}, "outputs": [], "source": [ "datafile = \"lausanne-appart.csv\"" ] }, { "cell_type": "markdown", "id": "adfab574", "metadata": {}, "source": [ "Read the data" ] }, { "cell_type": "code", "execution_count": 456, "id": "5108e239", "metadata": {}, "outputs": [], "source": [ "dataset = pd.read_csv(datafile)" ] }, { "cell_type": "markdown", "id": "5a97d4cc", "metadata": {}, "source": [ "Display first rows" ] }, { "cell_type": "code", "execution_count": 457, "id": "34222aff", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | living_area | \n", "nb_rooms | \n", "rent_price | \n", "
|---|---|---|---|
| 0 | \n", "69 | \n", "3.0 | \n", "1810 | \n", "
| 1 | \n", "95 | \n", "3.5 | \n", "2945 | \n", "
| 2 | \n", "21 | \n", "1.5 | \n", "685 | \n", "
| 3 | \n", "20 | \n", "1.0 | \n", "720 | \n", "
| 4 | \n", "33 | \n", "1.5 | \n", "830 | \n", "