Files
fenago f3b24b4b7f added
2021-02-07 15:16:01 +05:00

145 lines
2.8 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "Bsi2UOD-_qJs"
},
"source": [
"# Importing and Splitting Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "_9sXD0bO_qJu"
},
"outputs": [],
"source": [
"# import libraries\n",
"import pandas as pd\n",
"from sklearn.model_selection import train_test_split"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "lqH2wbcr_qJ2"
},
"outputs": [],
"source": [
"# data doesn't have headers, so let's create headers\n",
"_headers = ['buying', 'maint', 'doors', 'persons', 'lug_boot', 'safety', 'car']"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "IBWdeps5_qJ6"
},
"outputs": [],
"source": [
"# read in cars dataset\n",
"df = pd.read_csv('../Dataset/car.data', names=_headers, index_col=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 194
},
"colab_type": "code",
"id": "ekEDfZQI_qJ9",
"outputId": "5185d230-124d-41ad-e670-d8ab9d9fc3b0"
},
"outputs": [],
"source": [
"df.head()\n",
"\n",
"# target column is 'car'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "mLo8czaT_qKC"
},
"outputs": [],
"source": [
"training, evaluation = train_test_split(df, test_size=0.3, random_state=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "NnUEDR4C_qKG"
},
"outputs": [],
"source": [
"validation, test = train_test_split(evaluation, test_size=0.5, random_state=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "TCzYFtEY_qKL"
},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"name": "Exercise6_01.ipynb",
"provenance": []
},
"file_extension": ".py",
"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.6"
},
"mimetype": "text/x-python",
"name": "python",
"npconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3
},
"nbformat": 4,
"nbformat_minor": 1
}