{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "e1bdbd46-1f35-4373-80ec-727f0e26f009", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "from sklearn.datasets import load_iris\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.metrics import accuracy_score\n", "\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")" ] }, { "cell_type": "code", "execution_count": 2, "id": "327dafe0-68d4-4200-a889-b03bc97a1057", "metadata": {}, "outputs": [], "source": [ "iris = load_iris()" ] }, { "cell_type": "code", "execution_count": 3, "id": "5ced7579-bb9f-4a20-abe2-c0c258ef4073", "metadata": {}, "outputs": [], "source": [ "X = iris.data[:, :1]\n", "y = iris.target" ] }, { "cell_type": "code", "execution_count": 4, "id": "c8e84e37-e034-4dcb-af3d-03d9cae87a92", "metadata": {}, "outputs": [], "source": [ "X = np.array([tuple(i.tolist()) for i in X], dtype=[(\"col1\", float)])\n", "y = np.array([i for i in y], dtype=[(\"col3\", y.dtype)])" ] }, { "cell_type": "code", "execution_count": 5, "id": "fab25223-225c-430b-a58d-368466d7fe02", "metadata": {}, "outputs": [], "source": [ "X = X.reshape(-1, 1)" ] }, { "cell_type": "code", "execution_count": 6, "id": "50359601-4b0d-4a94-a1c8-44a833b8f4e5", "metadata": { "tags": [] }, "outputs": [], "source": [ "x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)" ] }, { "cell_type": "code", "execution_count": 7, "id": "17fc4619-c5c0-4beb-81df-81617b1c7a56", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(array([[(6.3,)],\n", " [(6.5,)],\n", " [(5.6,)],\n", " [(5.7,)],\n", " [(6.4,)]], dtype=[('col1', '