{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# We import all libraries that we use\n", "\n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from sklearn.preprocessing import StandardScaler\n", "from sklearn import metrics, datasets\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.model_selection import cross_val_score\n", "from sklearn.model_selection import KFold\n", "from sklearn.neighbors import KNeighborsClassifier\n", "from sklearn.tree import DecisionTreeClassifier\n", "from sklearn import tree\n", "from sklearn.tree import export_graphviz\n", "from sklearn.ensemble import RandomForestClassifier\n", "from sklearn.svm import SVC\n", "from sklearn.neural_network import MLPClassifier\n", "from sklearn.naive_bayes import GaussianNB\n", "from sklearn.metrics import confusion_matrix\n", "from sklearn.metrics import matthews_corrcoef\n", "from sklearn.metrics import precision_score\n", "from sklearn.metrics import accuracy_score\n", "from sklearn.metrics import recall_score\n", "from sklearn.metrics import f1_score" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The size of the database is: (165, 14)\n" ] } ], "source": [ "#route = 'C:/Users/Documents/Database/' # This is an example of Database´s route, can be local or online. You can put here your local direction\n", "#https://nimbus.cicese.mx/public.php?service=files&t=454bf55581f6dc4a3b893b9967805f96 # or a web direction\n", "\n", "# We salve the database in df´s variable and use the method of Pandas read_CSV to reading CSV files\n", "df = pd.read_csv(route + 'database.csv') # Put here your local direction where you have the database \n", "print(\"The size of the database is:\", df.shape)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Show the type of the data\n", " Latency (ms) float64\n", " Jitter (ms) float64\n", " Bit Rate (Mbps) float64\n", " Packet Loss Rate (%) float64\n", " Peak Data Rate DL (Gbps) float64\n", " Peak Data Rate UL (Gbps) float64\n", " Mobility (km/h) float64\n", " Reliability (%) float64\n", " Service Availability (%) float64\n", " Survival Time (ms) float64\n", " Experienced Data Rate DL (Mbps) float64\n", " Experienced Data Rate UL (Mbps) float64\n", " Interruption Time (ms) float64\n", " Service object\n", "dtype: object\n" ] } ], "source": [ "# Pandas assign automatically a type of data but we need to check that the type of data be numeric\n", "# because the mathematic functions of Machine Learning (ML) don´t permit text-type of data\n", "# and as we can see, all type of data are float.\n", "\n", "print(\"Show the type of the data\\n\", df.dtypes) " ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Latency (ms) | \n", "Jitter (ms) | \n", "Bit Rate (Mbps) | \n", "Packet Loss Rate (%) | \n", "Peak Data Rate DL (Gbps) | \n", "Peak Data Rate UL (Gbps) | \n", "Mobility (km/h) | \n", "Reliability (%) | \n", "Service Availability (%) | \n", "Survival Time (ms) | \n", "Experienced Data Rate DL (Mbps) | \n", "Experienced Data Rate UL (Mbps) | \n", "Interruption Time (ms) | \n", "Service | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "15.0 | \n", "5.00 | \n", "11.0 | \n", "1.000000e-01 | \n", "18.0 | \n", "7.000 | \n", "260.0 | \n", "95.00000 | \n", "99.0000 | \n", "8.0 | \n", "1000.0 | \n", "500.0 | \n", "1000.0 | \n", "UHD_Video_Streaming | \n", "
1 | \n", "5.0 | \n", "5.50 | \n", "10.0 | \n", "1.000000e+00 | \n", "20.0 | \n", "10.000 | \n", "20.0 | \n", "95.00000 | \n", "99.2000 | \n", "9.0 | \n", "990.0 | \n", "440.0 | \n", "2000.0 | \n", "UHD_Video_Streaming | \n", "
2 | \n", "8.0 | \n", "10.00 | \n", "50.0 | \n", "3.800000e+00 | \n", "15.0 | \n", "7.000 | \n", "15.0 | \n", "97.00000 | \n", "99.9000 | \n", "10.0 | \n", "1000.0 | \n", "50.0 | \n", "0.2 | \n", "Immerse_Experience | \n", "
3 | \n", "40.0 | \n", "1.00 | \n", "0.5 | \n", "1.000000e-05 | \n", "18.0 | \n", "9.000 | \n", "0.0 | \n", "99.92000 | \n", "99.9990 | \n", "10.0 | \n", "5.0 | \n", "8.0 | \n", "0.0 | \n", "Smart_Grid | \n", "
4 | \n", "90.0 | \n", "18.00 | \n", "0.2 | \n", "8.000000e-02 | \n", "13.0 | \n", "2.000 | \n", "480.0 | \n", "99.99950 | \n", "99.9999 | \n", "100.0 | \n", "10.0 | \n", "10.0 | \n", "1000.0 | \n", "ITS | \n", "
5 | \n", "130.0 | \n", "5.00 | \n", "8.0 | \n", "9.000000e-01 | \n", "14.0 | \n", "6.000 | \n", "400.0 | \n", "99.94000 | \n", "95.0000 | \n", "100.0 | \n", "50.0 | \n", "25.0 | \n", "0.0 | \n", "Vo5G | \n", "
6 | \n", "10.0 | \n", "19.00 | \n", "32.0 | \n", "4.700000e+00 | \n", "13.0 | \n", "5.000 | \n", "26.0 | \n", "95.60000 | \n", "99.9200 | \n", "8.9 | \n", "900.0 | \n", "40.0 | \n", "0.1 | \n", "Immerse_Experience | \n", "
7 | \n", "2.0 | \n", "3.00 | \n", "15.0 | \n", "8.000000e-09 | \n", "0.2 | \n", "0.200 | \n", "100.0 | \n", "99.99996 | \n", "99.0000 | \n", "1.0 | \n", "10.0 | \n", "100.0 | \n", "0.0 | \n", "e_Health | \n", "
8 | \n", "5.0 | \n", "0.50 | \n", "10.0 | \n", "7.500000e-04 | \n", "0.8 | \n", "0.024 | \n", "80.0 | \n", "99.99920 | \n", "99.0000 | \n", "1.0 | \n", "50.0 | \n", "25.0 | \n", "0.0 | \n", "Connected_Vehicles | \n", "
9 | \n", "1.0 | \n", "0.05 | \n", "0.6 | \n", "1.000000e-07 | \n", "15.0 | \n", "6.000 | \n", "28.0 | \n", "99.99900 | \n", "99.9999 | \n", "0.0 | \n", "1.0 | \n", "10.0 | \n", "100.0 | \n", "Industry_Automation | \n", "