170 lines
3.4 KiB
Plaintext
170 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "GqVBlXmg1WBj"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from sklearn.model_selection import train_test_split\n",
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "04jwUFPb1mvO"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"df = pd.read_csv(\"./north_korea_missile_test_database.csv\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "POfj6rYe1223"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"y = df[\"Missile Name\"]\n",
|
|
"x = df.drop(\"Missile Name\", axis=1)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(y.shape)\n",
|
|
"\n",
|
|
"print(x.shape)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "2XgHv3692X8M"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Randomly split the dataset and its labels into a training set consisting 80% of the size of the original dataset and a testing set 20% of the size\n",
|
|
"X_train, X_test, y_train, y_test = train_test_split(x,y,test_size=0.2, random_state = 31)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"id": "u2Z96h-g2wZM"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# We will apply the train_test_split method once more, to obtain a validation set, x_val and y_val\n",
|
|
"X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size = 0.25, random_state=31)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"id": "BPSL4tyT3JjN",
|
|
"outputId": "1809bb3c-75fa-40da-a489-dd1ad3646134"
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"# 60% of the size of the original data, a validation set of 20% and a testing set of 20%\n",
|
|
"print(len(X_train))\n",
|
|
"print(len(y_train))\n",
|
|
"print(len(X_val))\n",
|
|
"print(len(y_val))\n",
|
|
"print(len(X_test))\n",
|
|
"print(len(y_test))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(y_train)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(y_val)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(y_test)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"collapsed_sections": [],
|
|
"name": "Train test split Udemy.ipynb",
|
|
"provenance": []
|
|
},
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.8.8"
|
|
},
|
|
"widgets": {
|
|
"application/vnd.jupyter.widget-state+json": {
|
|
"state": {},
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|