diff --git a/scikit_learn_ML_01.ipynb b/scikit_learn_ML_01.ipynb new file mode 100644 index 0000000..b9a04b4 --- /dev/null +++ b/scikit_learn_ML_01.ipynb @@ -0,0 +1,462 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyPuEIRryr2g0wc8LaS7jy3X", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "wN03_nY2vCrg" + }, + "outputs": [], + "source": [ + "from sklearn.datasets import load_iris\n" + ] + }, + { + "cell_type": "code", + "source": [ + "iris = load_iris()\n", + "type(iris)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 187 + }, + "id": "KtrvVuBwEi8f", + "outputId": "5aefa11f-1a9f-422c-8477-480973fd11e1" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "sklearn.utils._bunch.Bunch" + ], + "text/html": [ + "
\n", + "
sklearn.utils._bunch.Bunch
def __init__(**kwargs)
/usr/local/lib/python3.10/dist-packages/sklearn/utils/_bunch.pyContainer object exposing keys as attributes.\n",
+              "\n",
+              "Bunch objects are sometimes used as an output for functions and methods.\n",
+              "They extend dictionaries by enabling values to be accessed by key,\n",
+              "`bunch["value_key"]`, or by an attribute, `bunch.value_key`.\n",
+              "\n",
+              "Examples\n",
+              "--------\n",
+              ">>> from sklearn.utils import Bunch\n",
+              ">>> b = Bunch(a=1, b=2)\n",
+              ">>> b['b']\n",
+              "2\n",
+              ">>> b.b\n",
+              "2\n",
+              ">>> b.a = 3\n",
+              ">>> b['a']\n",
+              "3\n",
+              ">>> b.c = 6\n",
+              ">>> b['c']\n",
+              "6
\n", + " \n", + "
" + ] + }, + "metadata": {}, + "execution_count": 3 + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(iris.data)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "09x8GCQdErVr", + "outputId": "878fca0f-bace-4d4c-e9a1-866b492eec34" + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[[5.1 3.5 1.4 0.2]\n", + " [4.9 3. 1.4 0.2]\n", + " [4.7 3.2 1.3 0.2]\n", + " [4.6 3.1 1.5 0.2]\n", + " [5. 3.6 1.4 0.2]\n", + " [5.4 3.9 1.7 0.4]\n", + " [4.6 3.4 1.4 0.3]\n", + " [5. 3.4 1.5 0.2]\n", + " [4.4 2.9 1.4 0.2]\n", + " [4.9 3.1 1.5 0.1]\n", + " [5.4 3.7 1.5 0.2]\n", + " [4.8 3.4 1.6 0.2]\n", + " [4.8 3. 1.4 0.1]\n", + " [4.3 3. 1.1 0.1]\n", + " [5.8 4. 1.2 0.2]\n", + " [5.7 4.4 1.5 0.4]\n", + " [5.4 3.9 1.3 0.4]\n", + " [5.1 3.5 1.4 0.3]\n", + " [5.7 3.8 1.7 0.3]\n", + " [5.1 3.8 1.5 0.3]\n", + " [5.4 3.4 1.7 0.2]\n", + " [5.1 3.7 1.5 0.4]\n", + " [4.6 3.6 1. 0.2]\n", + " [5.1 3.3 1.7 0.5]\n", + " [4.8 3.4 1.9 0.2]\n", + " [5. 3. 1.6 0.2]\n", + " [5. 3.4 1.6 0.4]\n", + " [5.2 3.5 1.5 0.2]\n", + " [5.2 3.4 1.4 0.2]\n", + " [4.7 3.2 1.6 0.2]\n", + " [4.8 3.1 1.6 0.2]\n", + " [5.4 3.4 1.5 0.4]\n", + " [5.2 4.1 1.5 0.1]\n", + " [5.5 4.2 1.4 0.2]\n", + " [4.9 3.1 1.5 0.2]\n", + " [5. 3.2 1.2 0.2]\n", + " [5.5 3.5 1.3 0.2]\n", + " [4.9 3.6 1.4 0.1]\n", + " [4.4 3. 1.3 0.2]\n", + " [5.1 3.4 1.5 0.2]\n", + " [5. 3.5 1.3 0.3]\n", + " [4.5 2.3 1.3 0.3]\n", + " [4.4 3.2 1.3 0.2]\n", + " [5. 3.5 1.6 0.6]\n", + " [5.1 3.8 1.9 0.4]\n", + " [4.8 3. 1.4 0.3]\n", + " [5.1 3.8 1.6 0.2]\n", + " [4.6 3.2 1.4 0.2]\n", + " [5.3 3.7 1.5 0.2]\n", + " [5. 3.3 1.4 0.2]\n", + " [7. 3.2 4.7 1.4]\n", + " [6.4 3.2 4.5 1.5]\n", + " [6.9 3.1 4.9 1.5]\n", + " [5.5 2.3 4. 1.3]\n", + " [6.5 2.8 4.6 1.5]\n", + " [5.7 2.8 4.5 1.3]\n", + " [6.3 3.3 4.7 1.6]\n", + " [4.9 2.4 3.3 1. ]\n", + " [6.6 2.9 4.6 1.3]\n", + " [5.2 2.7 3.9 1.4]\n", + " [5. 2. 3.5 1. ]\n", + " [5.9 3. 4.2 1.5]\n", + " [6. 2.2 4. 1. ]\n", + " [6.1 2.9 4.7 1.4]\n", + " [5.6 2.9 3.6 1.3]\n", + " [6.7 3.1 4.4 1.4]\n", + " [5.6 3. 4.5 1.5]\n", + " [5.8 2.7 4.1 1. ]\n", + " [6.2 2.2 4.5 1.5]\n", + " [5.6 2.5 3.9 1.1]\n", + " [5.9 3.2 4.8 1.8]\n", + " [6.1 2.8 4. 1.3]\n", + " [6.3 2.5 4.9 1.5]\n", + " [6.1 2.8 4.7 1.2]\n", + " [6.4 2.9 4.3 1.3]\n", + " [6.6 3. 4.4 1.4]\n", + " [6.8 2.8 4.8 1.4]\n", + " [6.7 3. 5. 1.7]\n", + " [6. 2.9 4.5 1.5]\n", + " [5.7 2.6 3.5 1. ]\n", + " [5.5 2.4 3.8 1.1]\n", + " [5.5 2.4 3.7 1. ]\n", + " [5.8 2.7 3.9 1.2]\n", + " [6. 2.7 5.1 1.6]\n", + " [5.4 3. 4.5 1.5]\n", + " [6. 3.4 4.5 1.6]\n", + " [6.7 3.1 4.7 1.5]\n", + " [6.3 2.3 4.4 1.3]\n", + " [5.6 3. 4.1 1.3]\n", + " [5.5 2.5 4. 1.3]\n", + " [5.5 2.6 4.4 1.2]\n", + " [6.1 3. 4.6 1.4]\n", + " [5.8 2.6 4. 1.2]\n", + " [5. 2.3 3.3 1. ]\n", + " [5.6 2.7 4.2 1.3]\n", + " [5.7 3. 4.2 1.2]\n", + " [5.7 2.9 4.2 1.3]\n", + " [6.2 2.9 4.3 1.3]\n", + " [5.1 2.5 3. 1.1]\n", + " [5.7 2.8 4.1 1.3]\n", + " [6.3 3.3 6. 2.5]\n", + " [5.8 2.7 5.1 1.9]\n", + " [7.1 3. 5.9 2.1]\n", + " [6.3 2.9 5.6 1.8]\n", + " [6.5 3. 5.8 2.2]\n", + " [7.6 3. 6.6 2.1]\n", + " [4.9 2.5 4.5 1.7]\n", + " [7.3 2.9 6.3 1.8]\n", + " [6.7 2.5 5.8 1.8]\n", + " [7.2 3.6 6.1 2.5]\n", + " [6.5 3.2 5.1 2. ]\n", + " [6.4 2.7 5.3 1.9]\n", + " [6.8 3. 5.5 2.1]\n", + " [5.7 2.5 5. 2. ]\n", + " [5.8 2.8 5.1 2.4]\n", + " [6.4 3.2 5.3 2.3]\n", + " [6.5 3. 5.5 1.8]\n", + " [7.7 3.8 6.7 2.2]\n", + " [7.7 2.6 6.9 2.3]\n", + " [6. 2.2 5. 1.5]\n", + " [6.9 3.2 5.7 2.3]\n", + " [5.6 2.8 4.9 2. ]\n", + " [7.7 2.8 6.7 2. ]\n", + " [6.3 2.7 4.9 1.8]\n", + " [6.7 3.3 5.7 2.1]\n", + " [7.2 3.2 6. 1.8]\n", + " [6.2 2.8 4.8 1.8]\n", + " [6.1 3. 4.9 1.8]\n", + " [6.4 2.8 5.6 2.1]\n", + " [7.2 3. 5.8 1.6]\n", + " [7.4 2.8 6.1 1.9]\n", + " [7.9 3.8 6.4 2. ]\n", + " [6.4 2.8 5.6 2.2]\n", + " [6.3 2.8 5.1 1.5]\n", + " [6.1 2.6 5.6 1.4]\n", + " [7.7 3. 6.1 2.3]\n", + " [6.3 3.4 5.6 2.4]\n", + " [6.4 3.1 5.5 1.8]\n", + " [6. 3. 4.8 1.8]\n", + " [6.9 3.1 5.4 2.1]\n", + " [6.7 3.1 5.6 2.4]\n", + " [6.9 3.1 5.1 2.3]\n", + " [5.8 2.7 5.1 1.9]\n", + " [6.8 3.2 5.9 2.3]\n", + " [6.7 3.3 5.7 2.5]\n", + " [6.7 3. 5.2 2.3]\n", + " [6.3 2.5 5. 1.9]\n", + " [6.5 3. 5.2 2. ]\n", + " [6.2 3.4 5.4 2.3]\n", + " [5.9 3. 5.1 1.8]]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(iris.feature_names)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "AdrEh88xFUsn", + "outputId": "8d16bbc7-85cf-47fd-a04a-ecc5153e4468" + }, + "execution_count": 5, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(iris.target)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "eqJKrOc2FVCJ", + "outputId": "181b4828-27a2-4776-c374-2c81c6c2bb7a" + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", + " 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", + " 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2\n", + " 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", + " 2 2]\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(iris.target_names)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "a3-hyl6wFVS-", + "outputId": "2666838b-f6eb-47d6-8edc-95a4115de5c6" + }, + "execution_count": 7, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "['setosa' 'versicolor' 'virginica']\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(type(iris.data))\n", + "print(type(iris.target))" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "SBqGfDPoFVkW", + "outputId": "11512822-a1cd-4883-83e9-c4e7d94d9db3" + }, + "execution_count": 8, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\n", + "\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(iris.data.shape)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "BzXWB4bvFV3P", + "outputId": "1c11063a-9a52-4f0a-cf71-289700e37333" + }, + "execution_count": 9, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "(150, 4)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "print(iris.target.shape)" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EI8SUuSNHLz5", + "outputId": "fedeeec7-9b6e-47dd-a01a-f366e00235a3" + }, + "execution_count": 10, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "(150,)\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "X = iris.data\n", + "y = iris.target" + ], + "metadata": { + "id": "hIxIE7Y8HMeH" + }, + "execution_count": 11, + "outputs": [] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "nY7-6fvpwEAu" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file