{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": { "id": "RdGj5r4ilCXW" }, "outputs": [], "source": [ "import pandas as pd\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.metrics import r2_score,mean_squared_error\n", "from sklearn.compose import ColumnTransformer\n", "from sklearn.preprocessing import OneHotEncoder, StandardScaler\n", "from sklearn.pipeline import Pipeline" ] }, { "cell_type": "markdown", "source": [ "import pandas as pd = Verileri tablolama ve ön işleme aşamalarında kullanıldı.from sklearn.model_selection import train_test_split: Ana veri setini eğitim ve test verilerine ayırmak için kullanıldı.\n", "from sklearn.linear_model import LinearRegression : Doğrusal regresyon\n", "from sklearn.metrics import r2_score,mean_squared_error : modelimizin performansını ölçmek için\n", "from sklearn.compose import ColumnTransformer :Sütun dönüşüm işlemleri\n", "from sklearn.preprocessing import OneHotEncoder, StandardScaler : kategori - sayısal dönüşüm ve ölçeklendirme\n", "from sklearn.pipeline import Pipeline : Veri işleme hattı" ], "metadata": { "id": "xOSP5tvYlhT8" } }, { "cell_type": "code", "source": [ "pip install xldr" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "collapsed": true, "id": "RB7HDScwl5fB", "outputId": "33075e92-e29d-4ad6-a849-474362666f11" }, "execution_count": 7, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "\u001b[31mERROR: Could not find a version that satisfies the requirement xldr (from versions: none)\u001b[0m\u001b[31m\n", "\u001b[0m\u001b[31mERROR: No matching distribution found for xldr\u001b[0m\u001b[31m\n", "\u001b[0m" ] } ] }, { "cell_type": "markdown", "source": [ "Proje excel dosyası olduğu için" ], "metadata": { "id": "kj4-OtBBmFuG" } }, { "cell_type": "code", "source": [ "df=pd.read_excel('cars.xls')\n", "df" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 423 }, "id": "95ASq-kSnjIB", "outputId": "3a194963-1a64-4919-c089-3611fd6402de" }, "execution_count": 9, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " Price Mileage Make Model Trim Type Cylinder \\\n", "0 17314.103129 8221 Buick Century Sedan 4D Sedan 6 \n", "1 17542.036083 9135 Buick Century Sedan 4D Sedan 6 \n", "2 16218.847862 13196 Buick Century Sedan 4D Sedan 6 \n", "3 16336.913140 16342 Buick Century Sedan 4D Sedan 6 \n", "4 16339.170324 19832 Buick Century Sedan 4D Sedan 6 \n", ".. ... ... ... ... ... ... ... \n", "799 16507.070267 16229 Saturn L Series L300 Sedan 4D Sedan 6 \n", "800 16175.957604 19095 Saturn L Series L300 Sedan 4D Sedan 6 \n", "801 15731.132897 20484 Saturn L Series L300 Sedan 4D Sedan 6 \n", "802 15118.893228 25979 Saturn L Series L300 Sedan 4D Sedan 6 \n", "803 13585.636802 35662 Saturn L Series L300 Sedan 4D Sedan 6 \n", "\n", " Liter Doors Cruise Sound Leather \n", "0 3.1 4 1 1 1 \n", "1 3.1 4 1 1 0 \n", "2 3.1 4 1 1 0 \n", "3 3.1 4 1 0 0 \n", "4 3.1 4 1 0 1 \n", ".. ... ... ... ... ... \n", "799 3.0 4 1 0 0 \n", "800 3.0 4 1 1 0 \n", "801 3.0 4 1 1 0 \n", "802 3.0 4 1 1 0 \n", "803 3.0 4 1 0 0 \n", "\n", "[804 rows x 12 columns]" ], "text/html": [ "\n", "
\n", " | Price | \n", "Mileage | \n", "Make | \n", "Model | \n", "Trim | \n", "Type | \n", "Cylinder | \n", "Liter | \n", "Doors | \n", "Cruise | \n", "Sound | \n", "Leather | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "17314.103129 | \n", "8221 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "1 | \n", "1 | \n", "
1 | \n", "17542.036083 | \n", "9135 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
2 | \n", "16218.847862 | \n", "13196 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
3 | \n", "16336.913140 | \n", "16342 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "0 | \n", "0 | \n", "
4 | \n", "16339.170324 | \n", "19832 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "0 | \n", "1 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
799 | \n", "16507.070267 | \n", "16229 | \n", "Saturn | \n", "L Series | \n", "L300 Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.0 | \n", "4 | \n", "1 | \n", "0 | \n", "0 | \n", "
800 | \n", "16175.957604 | \n", "19095 | \n", "Saturn | \n", "L Series | \n", "L300 Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.0 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
801 | \n", "15731.132897 | \n", "20484 | \n", "Saturn | \n", "L Series | \n", "L300 Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.0 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
802 | \n", "15118.893228 | \n", "25979 | \n", "Saturn | \n", "L Series | \n", "L300 Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.0 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
803 | \n", "13585.636802 | \n", "35662 | \n", "Saturn | \n", "L Series | \n", "L300 Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.0 | \n", "4 | \n", "1 | \n", "0 | \n", "0 | \n", "
804 rows × 12 columns
\n", "\n", " | Price | \n", "Mileage | \n", "Make | \n", "Model | \n", "Trim | \n", "Type | \n", "Cylinder | \n", "Liter | \n", "Doors | \n", "Cruise | \n", "Sound | \n", "Leather | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "17314.103129 | \n", "8221 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "1 | \n", "1 | \n", "
1 | \n", "17542.036083 | \n", "9135 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
2 | \n", "16218.847862 | \n", "13196 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "1 | \n", "0 | \n", "
3 | \n", "16336.913140 | \n", "16342 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "0 | \n", "0 | \n", "
4 | \n", "16339.170324 | \n", "19832 | \n", "Buick | \n", "Century | \n", "Sedan 4D | \n", "Sedan | \n", "6 | \n", "3.1 | \n", "4 | \n", "1 | \n", "0 | \n", "1 | \n", "
Pipeline(steps=[('preprocessor',\n", " ColumnTransformer(transformers=[('num', StandardScaler(),\n", " ['Mileage', 'Cylinder',\n", " 'Liter', 'Doors']),\n", " ('cat', OneHotEncoder(),\n", " ['Make', 'Model', 'Trim',\n", " 'Type'])])),\n", " ('model', LinearRegression())])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
Pipeline(steps=[('preprocessor',\n", " ColumnTransformer(transformers=[('num', StandardScaler(),\n", " ['Mileage', 'Cylinder',\n", " 'Liter', 'Doors']),\n", " ('cat', OneHotEncoder(),\n", " ['Make', 'Model', 'Trim',\n", " 'Type'])])),\n", " ('model', LinearRegression())])
ColumnTransformer(transformers=[('num', StandardScaler(),\n", " ['Mileage', 'Cylinder', 'Liter', 'Doors']),\n", " ('cat', OneHotEncoder(),\n", " ['Make', 'Model', 'Trim', 'Type'])])
['Mileage', 'Cylinder', 'Liter', 'Doors']
StandardScaler()
['Make', 'Model', 'Trim', 'Type']
OneHotEncoder()
LinearRegression()
Pipeline(steps=[('preprocessor',\n", " ColumnTransformer(transformers=[('num', StandardScaler(),\n", " ['Mileage', 'Cylinder',\n", " 'Liter', 'Doors']),\n", " ('cat', OneHotEncoder(),\n", " ['Make', 'Model', 'Trim',\n", " 'Type'])])),\n", " ('model', LinearRegression())])In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
Pipeline(steps=[('preprocessor',\n", " ColumnTransformer(transformers=[('num', StandardScaler(),\n", " ['Mileage', 'Cylinder',\n", " 'Liter', 'Doors']),\n", " ('cat', OneHotEncoder(),\n", " ['Make', 'Model', 'Trim',\n", " 'Type'])])),\n", " ('model', LinearRegression())])
ColumnTransformer(transformers=[('num', StandardScaler(),\n", " ['Mileage', 'Cylinder', 'Liter', 'Doors']),\n", " ('cat', OneHotEncoder(),\n", " ['Make', 'Model', 'Trim', 'Type'])])
['Mileage', 'Cylinder', 'Liter', 'Doors']
StandardScaler()
['Make', 'Model', 'Trim', 'Type']
OneHotEncoder()
LinearRegression()