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

141 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "9IIZwgmoUrmb"
},
"source": [
"# Import and Split Data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "bqo23ud-Urme"
},
"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": {
"base_uri": "https://localhost:8080/",
"height": 266
},
"colab_type": "code",
"id": "os1H7RpwUrms",
"outputId": "0794006a-0b2a-48b5-9191-7ac0f9b086cf"
},
"outputs": [],
"source": [
"# data doesn't have headers, so let's create headers\n",
"_headers = ['buying', 'maint', 'doors', 'persons', 'lug_boot', 'safety', 'car']\n",
"# read in cars dataset\n",
"df = pd.read_csv('../Dataset/car.data', names=_headers, index_col=None)\n",
"df.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "1tu3JxwoUrmz"
},
"outputs": [],
"source": [
"#split the data into 80% for training and 20% for evaluation\n",
"training_df, eval_df = train_test_split(df, train_size=0.8, random_state=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 266
},
"colab_type": "code",
"id": "oEkV14eBUrm5",
"outputId": "b04aae52-a6d7-4c13-8f00-e6e208aa9220"
},
"outputs": [],
"source": [
"training_df.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 266
},
"colab_type": "code",
"id": "cH8g00PnUrm_",
"outputId": "a3f5230e-2f55-4444-f558-28ac1d458a91"
},
"outputs": [],
"source": [
"eval_df.info()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "rOkZg2K8UrnE"
},
"outputs": [],
"source": []
}
],
"metadata": {
"colab": {
"name": "Exercise7.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
}