{ "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": 1, "metadata": { "id": "XZAE4_Oo_g72" }, "outputs": [], "source": [ "from sklearn import datasets\n", "\n", "irisData = datasets.load_iris()\n", "\n", "x_total = irisData.data\n", "y_total = irisData.target" ] }, { "cell_type": "code", "source": [ "# 데이터 분할\n", "\n", "from sklearn.model_selection import train_test_split, cross_val_score\n", "x_train, x_test, y_train, y_test = train_test_split(x_total, y_total, random_state=10)" ], "metadata": { "id": "fKHN8GVCBxh4" }, "execution_count": 2, "outputs": [] }, { "cell_type": "code", "source": [ "# 모형 학습\n", "\n", "from sklearn.neighbors import KNeighborsClassifier\n", "\n", "kNN = KNeighborsClassifier()\n", "kNN.fit(x_train, y_train)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 74 }, "id": "JaBHniZ0Cw6u", "outputId": "8e475960-640d-4f97-a9b7-01277371fd73" }, "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "KNeighborsClassifier()" ], "text/html": [ "
KNeighborsClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
KNeighborsClassifier()