{ "cells": [ { "cell_type": "markdown", "id": "dff037b7-7d71-49c2-8a47-48017c073f81", "metadata": {}, "source": [ "$R^2$ für ein polynomielles Modell" ] }, { "cell_type": "code", "execution_count": 74, "id": "8b1ff6ff-f80e-4cc3-b266-0ad417911d1d", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "# plotting settings\n", "pd.plotting.register_matplotlib_converters()\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import seaborn as sns\n", "from tqdm.notebook import tqdm" ] }, { "cell_type": "code", "execution_count": 75, "id": "f698283d-7346-4618-9b87-60a3de061a98", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Suburb', 'Address', 'Rooms', 'Type', 'Price', 'Method', 'SellerG',\n", " 'Date', 'Distance', 'Postcode', 'Bedroom2', 'Bathroom', 'Car',\n", " 'Landsize', 'BuildingArea', 'YearBuilt', 'CouncilArea', 'Lattitude',\n", " 'Longtitude', 'Regionname', 'Propertycount'],\n", " dtype='object')" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "melbourne_file_path = 'data/melb_data.csv'\n", "melbourne_data = pd.read_csv(melbourne_file_path)\n", "melbourne_data = melbourne_data.dropna(axis=0) # entfernen von Daten mit fehlenden Werten\n", "melbourne_data.columns # Spaltennamen der Tabelle (potentielle Features)\n" ] }, { "cell_type": "code", "execution_count": 83, "id": "dac65c52-f2ce-47b6-ba65-3c6bd915dfe8", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/plex/.pyenv/versions/ki/lib/python3.12/site-packages/pandas/core/nanops.py:1016: RuntimeWarning: invalid value encountered in subtract\n", " sqr = _ensure_numeric((avg - values) ** 2)\n" ] }, { "data": { "text/html": [ "
\n", " | Rooms | \n", "BuildingArea | \n", "Lattitude | \n", "Price | \n", "price_per_area | \n", "
---|---|---|---|---|---|
1 | \n", "2 | \n", "79.0 | \n", "-37.8079 | \n", "1035000.0 | \n", "6634.615385 | \n", "
2 | \n", "3 | \n", "150.0 | \n", "-37.8093 | \n", "1465000.0 | \n", "10932.835821 | \n", "
4 | \n", "4 | \n", "142.0 | \n", "-37.8072 | \n", "1600000.0 | \n", "13333.333333 | \n", "
6 | \n", "3 | \n", "210.0 | \n", "-37.8024 | \n", "1876000.0 | \n", "7657.142857 | \n", "
7 | \n", "2 | \n", "107.0 | \n", "-37.8060 | \n", "1636000.0 | \n", "6390.625000 | \n", "