commit gráfica
This commit is contained in:
2
.idea/PythonProject.iml
generated
2
.idea/PythonProject.iml
generated
@@ -2,7 +2,7 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.13" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.12" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
62
GUI/pantalla.py
Normal file
62
GUI/pantalla.py
Normal file
@@ -0,0 +1,62 @@
|
||||
import pygame
|
||||
|
||||
# Inicializar pygame
|
||||
pygame.init()
|
||||
|
||||
# Configuración de la pantalla
|
||||
ANCHO, ALTO = 600, 400 # Puedes cambiar el tamaño
|
||||
TERCIO_ANCHO = ANCHO // 3
|
||||
|
||||
screen = pygame.display.set_mode((ANCHO, ALTO))
|
||||
pygame.display.set_caption("Cambio de colores con teclas")
|
||||
|
||||
# Fuente para el texto
|
||||
font = pygame.font.Font(None, 36)
|
||||
|
||||
|
||||
# Variables para controlar la iluminación
|
||||
i_presionado = False
|
||||
d_presionado = False
|
||||
espacio_presionado = False
|
||||
|
||||
# Bucle principal
|
||||
running = True
|
||||
while running:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
elif event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_i:
|
||||
i_presionado = True
|
||||
elif event.key == pygame.K_d:
|
||||
d_presionado = True
|
||||
elif event.key == pygame.K_SPACE:
|
||||
espacio_presionado = True
|
||||
elif event.type == pygame.KEYUP:
|
||||
if event.key == pygame.K_i:
|
||||
i_presionado = False
|
||||
elif event.key == pygame.K_d:
|
||||
d_presionado = False
|
||||
elif event.key == pygame.K_SPACE:
|
||||
espacio_presionado = False
|
||||
|
||||
# Fondo en blanco
|
||||
screen.fill((255, 255, 255))
|
||||
|
||||
# Dibujar los rectángulos si se presionan teclas
|
||||
if i_presionado:
|
||||
pygame.draw.rect(screen, (255, 0, 0), (0, 0, TERCIO_ANCHO, ALTO))
|
||||
text_surface = font.render("Izquierda", True, (0, 0, 0))
|
||||
screen.blit(text_surface, (TERCIO_ANCHO // 2 - text_surface.get_width() // 2, 20))
|
||||
if d_presionado:
|
||||
pygame.draw.rect(screen, (0, 255, 0), (2 * TERCIO_ANCHO, 0, TERCIO_ANCHO, ALTO))
|
||||
text_surface = font.render("Derecha", True, (0, 0, 0))
|
||||
screen.blit(text_surface, (2 * TERCIO_ANCHO + TERCIO_ANCHO // 2 - text_surface.get_width() // 2, 20))
|
||||
# Mostrar texto solo cuando se presiona espacio
|
||||
if espacio_presionado:
|
||||
text_surface = font.render("None", True, (0, 0, 0))
|
||||
screen.blit(text_surface, (ANCHO // 2 - text_surface.get_width() // 2, ALTO // 2))
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
pygame.quit()
|
@@ -2,88 +2,86 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "5fe31b7f-2243-4587-9740-46164846cff3",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:41.300262Z",
|
||||
"start_time": "2025-02-13T20:09:41.297886Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:13:55.436438Z",
|
||||
"start_time": "2025-03-02T19:13:46.916154Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import matplotlib\n",
|
||||
"import pandas as pd\n",
|
||||
"from datetime import datetime, timezone\n",
|
||||
"import zoneinfo\n"
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 1
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "cbb445af-6351-43b0-8142-f9aa35388e6e",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:41.308855Z",
|
||||
"start_time": "2025-02-13T20:09:41.306360Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:13:55.474641Z",
|
||||
"start_time": "2025-03-02T19:13:55.449280Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"logs_path = \"join/mergedLog_output.txt\"\n",
|
||||
"openbci_path = \"join/mergedData_output.txt\"\n",
|
||||
"output_csv_path = \"OpenBCI_with_labels.csv\"\n",
|
||||
"label_name = \"Movement\"\n",
|
||||
"timestamp_col=\"Timestamp\""
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 2
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "f613abe9-8d5b-444c-af3c-b0ab826ed3f4",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:43.026443Z",
|
||||
"start_time": "2025-02-13T20:09:41.323419Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:13:57.903721Z",
|
||||
"start_time": "2025-03-02T19:13:55.482610Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Leer los logs y extraer tiempos y etiquetas\n",
|
||||
"with open(logs_path, \"r\") as logs_file:\n",
|
||||
" logs_data = [log.strip().split(\",\") for log in logs_file.readlines()]\n",
|
||||
"with open(openbci_path, \"r\") as openbci_file:\n",
|
||||
" lineas = [linea.strip().split(\",\") for linea in openbci_file.readlines() if not linea.strip().startswith('%')]"
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 3
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "d8eba4ab-63ee-40f5-b30d-f8ae58d5aa79",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:43.043659Z",
|
||||
"start_time": "2025-02-13T20:09:43.039923Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:13:58.869318Z",
|
||||
"start_time": "2025-03-02T19:13:58.856580Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Utility functions\n",
|
||||
"def remove_columns(df, columns):\n",
|
||||
@@ -104,25 +102,90 @@
|
||||
" else:\n",
|
||||
" data.loc[mask, label_name] = label.strip()\n",
|
||||
" return True"
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 4
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "1ecf8906-828c-4e13-a267-2b96f61e2c2e",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:46.253744Z",
|
||||
"start_time": "2025-02-13T20:09:43.057864Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:07.618668Z",
|
||||
"start_time": "2025-03-02T19:13:58.903011Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"#Convertir los datos en un DataFrame\n",
|
||||
"columns = \"Sample Index, EXG Channel 0, EXG Channel 1, EXG Channel 2, EXG Channel 3, EXG Channel 4, EXG Channel 5, EXG Channel 6, EXG Channel 7, EXG Channel 8, EXG Channel 9, EXG Channel 10, EXG Channel 11, EXG Channel 12, EXG Channel 13, EXG Channel 14, EXG Channel 15, Accel Channel 0, Accel Channel 1, Accel Channel 2, Not_Used1, Digital Channel 0 (D11), Digital Channel 1 (D12), Digital Channel 2 (D13), Digital Channel 3 (D17), Not_Used2, Digital Channel 4 (D18), Analog Channel 0, Analog Channel 1, Analog Channel 2, Timestamp, Marker Channel, Timestamp (Formatted)\".split(\",\")\n",
|
||||
"columns = [column.strip() for column in columns]\n",
|
||||
"types = {}\n",
|
||||
"\n",
|
||||
"data_df = pd.DataFrame(lineas, columns=columns)\n",
|
||||
"exceptions = [\"Timestamp (Formatted)\"]\n",
|
||||
"\n",
|
||||
"for column in data_df.columns:\n",
|
||||
" if column in exceptions:\n",
|
||||
" continue\n",
|
||||
" data_df[column] = pd.to_numeric(data_df[column], errors='coerce')\n",
|
||||
"remove_columns(data_df, [\"Not_Used1\", \"Not_Used2\", \"Timestamp (Formatted)\", \"Sample Index\"])\n",
|
||||
"data_df[timestamp_col] = pd.to_datetime(data_df[timestamp_col], unit=\"s\", utc=True).dt.tz_convert(\"Europe/Madrid\")\n",
|
||||
"# Create the label column\n",
|
||||
"data_df[label_name]= \"\"\n",
|
||||
"data_df.head()"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" EXG Channel 0 EXG Channel 1 EXG Channel 2 EXG Channel 3 EXG Channel 4 \\\n",
|
||||
"0 19162.754019 10400.132585 -26819.835820 -10368.437811 -17614.694549 \n",
|
||||
"1 38187.821291 20561.995573 -53613.967134 -20684.863113 -36268.231126 \n",
|
||||
"2 37916.314652 20446.347647 -53464.702185 -20528.311494 -36279.362295 \n",
|
||||
"3 38343.098860 20722.995189 -53693.628751 -20771.207901 -35548.817879 \n",
|
||||
"4 37910.905529 20389.820086 -53463.472839 -20529.742006 -36741.171687 \n",
|
||||
"\n",
|
||||
" EXG Channel 5 EXG Channel 6 EXG Channel 7 EXG Channel 8 EXG Channel 9 \\\n",
|
||||
"0 175.684711 -23469.398733 -13855.980498 -20491.900503 -22635.343389 \n",
|
||||
"1 361.517115 -46906.543899 -27692.805552 4671.916923 -32254.126043 \n",
|
||||
"2 -755.690128 -46767.136069 -27537.952666 4684.500955 -32010.313214 \n",
|
||||
"3 628.978089 -47001.941145 -27767.415675 4760.072203 -32191.876434 \n",
|
||||
"4 -392.630743 -46768.946560 -27551.766044 4555.129058 -32183.382771 \n",
|
||||
"\n",
|
||||
" ... Digital Channel 1 (D12) Digital Channel 2 (D13) \\\n",
|
||||
"0 ... 112.0 15.5 \n",
|
||||
"1 ... 0.0 0.0 \n",
|
||||
"2 ... 0.0 0.0 \n",
|
||||
"3 ... 0.0 0.0 \n",
|
||||
"4 ... 104.0 15.5 \n",
|
||||
"\n",
|
||||
" Digital Channel 3 (D17) Digital Channel 4 (D18) Analog Channel 0 \\\n",
|
||||
"0 120.0 16.0 0.0 \n",
|
||||
"1 0.0 0.0 0.0 \n",
|
||||
"2 0.0 0.0 0.0 \n",
|
||||
"3 0.0 0.0 0.0 \n",
|
||||
"4 112.0 120.0 0.0 \n",
|
||||
"\n",
|
||||
" Analog Channel 1 Analog Channel 2 Timestamp \\\n",
|
||||
"0 0.0 0.0 2025-01-27 17:31:42.443204641+01:00 \n",
|
||||
"1 0.0 0.0 2025-01-27 17:31:42.443370104+01:00 \n",
|
||||
"2 0.0 0.0 2025-01-27 17:31:42.443432808+01:00 \n",
|
||||
"3 0.0 0.0 2025-01-27 17:31:42.443464756+01:00 \n",
|
||||
"4 0.0 0.0 2025-01-27 17:31:42.443489552+01:00 \n",
|
||||
"\n",
|
||||
" Marker Channel Movement \n",
|
||||
"0 0.0 \n",
|
||||
"1 0.0 \n",
|
||||
"2 0.0 \n",
|
||||
"3 0.0 \n",
|
||||
"4 0.0 \n",
|
||||
"\n",
|
||||
"[5 rows x 30 columns]"
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
@@ -290,51 +353,6 @@
|
||||
"</table>\n",
|
||||
"<p>5 rows × 30 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" EXG Channel 0 EXG Channel 1 EXG Channel 2 EXG Channel 3 EXG Channel 4 \\\n",
|
||||
"0 19162.754019 10400.132585 -26819.835820 -10368.437811 -17614.694549 \n",
|
||||
"1 38187.821291 20561.995573 -53613.967134 -20684.863113 -36268.231126 \n",
|
||||
"2 37916.314652 20446.347647 -53464.702185 -20528.311494 -36279.362295 \n",
|
||||
"3 38343.098860 20722.995189 -53693.628751 -20771.207901 -35548.817879 \n",
|
||||
"4 37910.905529 20389.820086 -53463.472839 -20529.742006 -36741.171687 \n",
|
||||
"\n",
|
||||
" EXG Channel 5 EXG Channel 6 EXG Channel 7 EXG Channel 8 EXG Channel 9 \\\n",
|
||||
"0 175.684711 -23469.398733 -13855.980498 -20491.900503 -22635.343389 \n",
|
||||
"1 361.517115 -46906.543899 -27692.805552 4671.916923 -32254.126043 \n",
|
||||
"2 -755.690128 -46767.136069 -27537.952666 4684.500955 -32010.313214 \n",
|
||||
"3 628.978089 -47001.941145 -27767.415675 4760.072203 -32191.876434 \n",
|
||||
"4 -392.630743 -46768.946560 -27551.766044 4555.129058 -32183.382771 \n",
|
||||
"\n",
|
||||
" ... Digital Channel 1 (D12) Digital Channel 2 (D13) \\\n",
|
||||
"0 ... 112.0 15.5 \n",
|
||||
"1 ... 0.0 0.0 \n",
|
||||
"2 ... 0.0 0.0 \n",
|
||||
"3 ... 0.0 0.0 \n",
|
||||
"4 ... 104.0 15.5 \n",
|
||||
"\n",
|
||||
" Digital Channel 3 (D17) Digital Channel 4 (D18) Analog Channel 0 \\\n",
|
||||
"0 120.0 16.0 0.0 \n",
|
||||
"1 0.0 0.0 0.0 \n",
|
||||
"2 0.0 0.0 0.0 \n",
|
||||
"3 0.0 0.0 0.0 \n",
|
||||
"4 112.0 120.0 0.0 \n",
|
||||
"\n",
|
||||
" Analog Channel 1 Analog Channel 2 Timestamp \\\n",
|
||||
"0 0.0 0.0 2025-01-27 17:31:42.443204641+01:00 \n",
|
||||
"1 0.0 0.0 2025-01-27 17:31:42.443370104+01:00 \n",
|
||||
"2 0.0 0.0 2025-01-27 17:31:42.443432808+01:00 \n",
|
||||
"3 0.0 0.0 2025-01-27 17:31:42.443464756+01:00 \n",
|
||||
"4 0.0 0.0 2025-01-27 17:31:42.443489552+01:00 \n",
|
||||
"\n",
|
||||
" Marker Channel Movement \n",
|
||||
"0 0.0 \n",
|
||||
"1 0.0 \n",
|
||||
"2 0.0 \n",
|
||||
"3 0.0 \n",
|
||||
"4 0.0 \n",
|
||||
"\n",
|
||||
"[5 rows x 30 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
@@ -342,43 +360,40 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"#Convertir los datos en un DataFrame\n",
|
||||
"columns = \"Sample Index, EXG Channel 0, EXG Channel 1, EXG Channel 2, EXG Channel 3, EXG Channel 4, EXG Channel 5, EXG Channel 6, EXG Channel 7, EXG Channel 8, EXG Channel 9, EXG Channel 10, EXG Channel 11, EXG Channel 12, EXG Channel 13, EXG Channel 14, EXG Channel 15, Accel Channel 0, Accel Channel 1, Accel Channel 2, Not_Used1, Digital Channel 0 (D11), Digital Channel 1 (D12), Digital Channel 2 (D13), Digital Channel 3 (D17), Not_Used2, Digital Channel 4 (D18), Analog Channel 0, Analog Channel 1, Analog Channel 2, Timestamp, Marker Channel, Timestamp (Formatted)\".split(\",\")\n",
|
||||
"columns = [column.strip() for column in columns]\n",
|
||||
"types = {}\n",
|
||||
"\n",
|
||||
"data_df = pd.DataFrame(lineas, columns=columns)\n",
|
||||
"exceptions = [\"Timestamp (Formatted)\"]\n",
|
||||
"\n",
|
||||
"for column in data_df.columns:\n",
|
||||
" if column in exceptions:\n",
|
||||
" continue\n",
|
||||
" data_df[column] = pd.to_numeric(data_df[column], errors='coerce')\n",
|
||||
"remove_columns(data_df, [\"Not_Used1\", \"Not_Used2\", \"Timestamp (Formatted)\", \"Sample Index\"])\n",
|
||||
"data_df[timestamp_col] = pd.to_datetime(data_df[timestamp_col], unit=\"s\", utc=True).dt.tz_convert(\"Europe/Madrid\")\n",
|
||||
"# Create the label column\n",
|
||||
"data_df[label_name]= \"\"\n",
|
||||
"data_df.head()"
|
||||
]
|
||||
"execution_count": 5
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "7f4bf8f8-99dd-4f0a-aa20-aa09643d9553",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:12:07.148168Z",
|
||||
"start_time": "2025-02-13T20:12:07.142272Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:07.774264Z",
|
||||
"start_time": "2025-03-02T19:14:07.736637Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Convertir los logs en un DataFrame\n",
|
||||
"log_df = pd.DataFrame(logs_data, columns=[\"Timestamp\", \"Label\"])\n",
|
||||
"#log_df[timestamp_col] = pd.to_datetime(log_df[timestamp_col], errors=\"coerce\", utc=True)\n",
|
||||
"log_df[timestamp_col] = log_df[timestamp_col].astype(str)\n",
|
||||
"\n",
|
||||
"log_df.head()"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
" Timestamp Label\n",
|
||||
"0 2025-01-27 17:31:40.0 i\n",
|
||||
"1 2025-01-27 17:32:13.0 none\n",
|
||||
"2 2025-01-27 17:33:08.0 none\n",
|
||||
"3 2025-01-27 17:50:46.0 c\n",
|
||||
"4 2025-01-27 17:51:11.0 i"
|
||||
],
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
@@ -431,14 +446,6 @@
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" Timestamp Label\n",
|
||||
"0 2025-01-27 17:31:40.0 i\n",
|
||||
"1 2025-01-27 17:32:13.0 none\n",
|
||||
"2 2025-01-27 17:33:08.0 none\n",
|
||||
"3 2025-01-27 17:50:46.0 c\n",
|
||||
"4 2025-01-27 17:51:11.0 i"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
@@ -446,20 +453,20 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Convertir los logs en un DataFrame\n",
|
||||
"log_df = pd.DataFrame(logs_data, columns=[\"Timestamp\", \"Label\"])\n",
|
||||
"#log_df[timestamp_col] = pd.to_datetime(log_df[timestamp_col], errors=\"coerce\", utc=True)\n",
|
||||
"log_df[timestamp_col] = log_df[timestamp_col].astype(str)\n",
|
||||
"\n",
|
||||
"log_df.head()"
|
||||
]
|
||||
"execution_count": 6
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "b46901ba",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:07.881015Z",
|
||||
"start_time": "2025-03-02T19:14:07.862014Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"log_df.dtypes"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@@ -474,25 +481,21 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"log_df.dtypes"
|
||||
]
|
||||
"execution_count": 7
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "0c8715db-9090-4fd6-9ade-9796c268b0b5",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:46.288560Z",
|
||||
"start_time": "2025-02-13T20:09:46.285065Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:08.125032Z",
|
||||
"start_time": "2025-03-02T19:14:08.118581Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def test(data, start_time, end_time):\n",
|
||||
" mask = (data[timestamp_col] >= start_time) & (data[\"Timestamp\"] < end_time)\n",
|
||||
@@ -500,32 +503,23 @@
|
||||
" print(\"xdata=\")\n",
|
||||
" print(xdata.empty)\n",
|
||||
" print(data.loc[mask,timestamp_col])"
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 8
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "90095eb1-91fb-4159-ae70-0ff42cfb2b4b",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-02-13T20:09:46.444389Z",
|
||||
"start_time": "2025-02-13T20:09:46.316312Z"
|
||||
},
|
||||
"collapsed": true,
|
||||
"jupyter": {
|
||||
"outputs_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:09.127121Z",
|
||||
"start_time": "2025-03-02T19:14:08.512800Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"*Error, no hay registros en el intervalo [2025-01-27 18:35:34.6, 2025-01-27 18:35:35.5)\n",
|
||||
"There were 1 errors in 79 intervals\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"errors = 0\n",
|
||||
"for i in range(len(log_df) - 1):\n",
|
||||
@@ -538,13 +532,31 @@
|
||||
" #test(data_df, start_time, end_time)\n",
|
||||
" #break\n",
|
||||
"print(f\"There were {errors} errors in {len(log_df)} intervals\")"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"*Error, no hay registros en el intervalo [2025-01-27 18:35:34.6, 2025-01-27 18:35:35.5)\n",
|
||||
"There were 1 errors in 79 intervals\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 9
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "d4e2a7aa",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:09.252955Z",
|
||||
"start_time": "2025-03-02T19:14:09.220421Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"data_df.value_counts(label_name)"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@@ -563,15 +575,26 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"data_df.value_counts(label_name)"
|
||||
]
|
||||
"execution_count": 10
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "1dfbc859",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:09.887517Z",
|
||||
"start_time": "2025-03-02T19:14:09.417859Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Clean dataset\n",
|
||||
"data_df.dropna(inplace=True)\n",
|
||||
"data_df = data_df[data_df.Movement != \"\"] # Remove empty labels\n",
|
||||
"data_df = data_df[data_df.Movement != \"c\"] # Remove calibration\n",
|
||||
"data_df.reset_index(drop=True, inplace=True)\n",
|
||||
"data_df[\"Movement\"] = data_df[\"Movement\"].astype(\"category\")\n",
|
||||
"data_df.value_counts(label_name)"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
@@ -588,165 +611,32 @@
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Clean dataset\n",
|
||||
"data_df.dropna(inplace=True)\n",
|
||||
"data_df = data_df[data_df.Movement != \"\"] # Remove empty labels\n",
|
||||
"data_df = data_df[data_df.Movement != \"c\"] # Remove calibration\n",
|
||||
"data_df.reset_index(drop=True, inplace=True)\n",
|
||||
"data_df[\"Movement\"] = data_df[\"Movement\"].astype(\"category\")\n",
|
||||
"data_df.value_counts(label_name)"
|
||||
]
|
||||
"execution_count": 11
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "aa4aa1a2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:14:18.221695Z",
|
||||
"start_time": "2025-03-02T19:14:09.977021Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"data_df.to_csv(os.path.join(\"csv\", \"openbci.csv\"), index=False)"
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": 12
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "ef4a6478",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "20d636799a67496f8cdf8619162fef24",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Summarize dataset: 0%| | 0/5 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/rmontanana/miniconda3/lib/python3.11/site-packages/ydata_profiling/model/pandas/describe_date_pandas.py:57: UserWarning: Discarding nonzero nanoseconds in conversion.\n",
|
||||
" \"min\": pd.Timestamp.to_pydatetime(series.min()),\n",
|
||||
"/home/rmontanana/miniconda3/lib/python3.11/site-packages/ydata_profiling/model/pandas/describe_date_pandas.py:58: UserWarning: Discarding nonzero nanoseconds in conversion.\n",
|
||||
" \"max\": pd.Timestamp.to_pydatetime(series.max()),\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "35e53f0f76e14e7f923b1055285670d3",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Generate report structure: 0%| | 0/1 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "6bbac27856134eef912956682f6cf5f3",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Render HTML: 0%| | 0/1 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "d2697cde02024e359b2e9df92b78179a",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Export report to file: 0%| | 0/1 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "ac17608271ce4757b0156753b390fc28",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Summarize dataset: 0%| | 0/5 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/home/rmontanana/miniconda3/lib/python3.11/site-packages/ydata_profiling/model/pandas/describe_date_pandas.py:57: UserWarning: Discarding nonzero nanoseconds in conversion.\n",
|
||||
" \"min\": pd.Timestamp.to_pydatetime(series.min()),\n",
|
||||
"/home/rmontanana/miniconda3/lib/python3.11/site-packages/ydata_profiling/model/pandas/describe_date_pandas.py:58: UserWarning: Discarding nonzero nanoseconds in conversion.\n",
|
||||
" \"max\": pd.Timestamp.to_pydatetime(series.max()),\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "f4a5bd4acb4c406492ad4fab3aed97cd",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Generate report structure: 0%| | 0/1 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "e8487fd4f12a493497e4b86b567149d8",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Render HTML: 0%| | 0/1 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "2c62e1d308d9498f8bca16b58f44204b",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"Export report to file: 0%| | 0/1 [00:00<?, ?it/s]"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:16:52.896034Z",
|
||||
"start_time": "2025-03-02T19:14:18.274675Z"
|
||||
}
|
||||
],
|
||||
},
|
||||
"source": [
|
||||
"# Generate analysis info into html folder\n",
|
||||
"from ydata_profiling import ProfileReport\n",
|
||||
@@ -768,52 +658,103 @@
|
||||
" )\n",
|
||||
"report.to_file(os.path.join(\"html\", \"OpenBCI_report.html\"))\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "09039cdf",
|
||||
"metadata": {},
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "985c493925d6403684ddaba1b2280a5e",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
" | | [ 0%] 00:00 -> (? left)"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Report html/OpenBCI_report_sv.html was generated.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n",
|
||||
"\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n",
|
||||
"\u001b[1;31mClick <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. \n",
|
||||
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
|
||||
"C:\\Users\\lucia\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
||||
" from .autonotebook import tqdm as notebook_tqdm\n",
|
||||
"Summarize dataset: 80%|████████ | 28/35 [00:06<00:01, 6.63it/s, Describe variable:Movement] C:\\Users\\lucia\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\ydata_profiling\\model\\pandas\\describe_date_pandas.py:57: UserWarning: Discarding nonzero nanoseconds in conversion.\n",
|
||||
" \"min\": pd.Timestamp.to_pydatetime(series.min()),\n",
|
||||
"C:\\Users\\lucia\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\ydata_profiling\\model\\pandas\\describe_date_pandas.py:58: UserWarning: Discarding nonzero nanoseconds in conversion.\n",
|
||||
" \"max\": pd.Timestamp.to_pydatetime(series.max()),\n",
|
||||
"Summarize dataset: 100%|██████████| 613/613 [01:43<00:00, 5.91it/s, Completed] \n",
|
||||
"Generate report structure: 100%|██████████| 1/1 [00:09<00:00, 9.54s/it]\n",
|
||||
"Render HTML: 100%|██████████| 1/1 [00:17<00:00, 17.93s/it]\n",
|
||||
"Export report to file: 100%|██████████| 1/1 [00:00<00:00, 5.79it/s]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 13
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"id": "09039cdf",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:24:14.038282Z",
|
||||
"start_time": "2025-03-02T19:24:13.189122Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"import sweetviz as sv\n",
|
||||
"report = sv.analyze(data_df)\n",
|
||||
"report.show_html(os.path.join(\"html\", \"OpenBCI_report_sv.html\"), open_browser=False, layout=\"widescreen\")"
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Feature: EXG Channel 0 |▎ | [ 3%] 00:00 -> (00:12 left)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "AttributeError",
|
||||
"evalue": "module 'numpy' has no attribute 'VisibleDeprecationWarning'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
|
||||
"\u001B[1;31mAttributeError\u001B[0m Traceback (most recent call last)",
|
||||
"Cell \u001B[1;32mIn[20], line 2\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21;01msweetviz\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;28;01mas\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21;01msv\u001B[39;00m\n\u001B[1;32m----> 2\u001B[0m report \u001B[38;5;241m=\u001B[39m \u001B[43msv\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43manalyze\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdata_df\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 3\u001B[0m report\u001B[38;5;241m.\u001B[39mshow_html(os\u001B[38;5;241m.\u001B[39mpath\u001B[38;5;241m.\u001B[39mjoin(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mhtml\u001B[39m\u001B[38;5;124m\"\u001B[39m, \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mOpenBCI_report_sv.html\u001B[39m\u001B[38;5;124m\"\u001B[39m), open_browser\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m, layout\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mwidescreen\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n",
|
||||
"File \u001B[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\sweetviz\\sv_public.py:12\u001B[0m, in \u001B[0;36manalyze\u001B[1;34m(source, target_feat, feat_cfg, pairwise_analysis)\u001B[0m\n\u001B[0;32m 8\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21manalyze\u001B[39m(source: Union[pd\u001B[38;5;241m.\u001B[39mDataFrame, Tuple[pd\u001B[38;5;241m.\u001B[39mDataFrame, \u001B[38;5;28mstr\u001B[39m]],\n\u001B[0;32m 9\u001B[0m target_feat: \u001B[38;5;28mstr\u001B[39m \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m,\n\u001B[0;32m 10\u001B[0m feat_cfg: FeatureConfig \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mNone\u001B[39;00m,\n\u001B[0;32m 11\u001B[0m pairwise_analysis: \u001B[38;5;28mstr\u001B[39m \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mauto\u001B[39m\u001B[38;5;124m'\u001B[39m):\n\u001B[1;32m---> 12\u001B[0m report \u001B[38;5;241m=\u001B[39m \u001B[43msweetviz\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mDataframeReport\u001B[49m\u001B[43m(\u001B[49m\u001B[43msource\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mtarget_feat\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;28;43;01mNone\u001B[39;49;00m\u001B[43m,\u001B[49m\n\u001B[0;32m 13\u001B[0m \u001B[43m \u001B[49m\u001B[43mpairwise_analysis\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mfeat_cfg\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 14\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m report\n",
|
||||
"File \u001B[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\sweetviz\\dataframe_report.py:277\u001B[0m, in \u001B[0;36mDataframeReport.__init__\u001B[1;34m(self, source, target_feature_name, compare, pairwise_analysis, fc, verbosity)\u001B[0m\n\u001B[0;32m 274\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m f \u001B[38;5;129;01min\u001B[39;00m features_to_process:\n\u001B[0;32m 275\u001B[0m \u001B[38;5;66;03m# start = time.perf_counter()\u001B[39;00m\n\u001B[0;32m 276\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mprogress_bar\u001B[38;5;241m.\u001B[39mset_description_str(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mFeature: \u001B[39m\u001B[38;5;132;01m{\u001B[39;00mf\u001B[38;5;241m.\u001B[39msource\u001B[38;5;241m.\u001B[39mname\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m--> 277\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_features[f\u001B[38;5;241m.\u001B[39msource\u001B[38;5;241m.\u001B[39mname] \u001B[38;5;241m=\u001B[39m \u001B[43msa\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43manalyze_feature_to_dictionary\u001B[49m\u001B[43m(\u001B[49m\u001B[43mf\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 278\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mprogress_bar\u001B[38;5;241m.\u001B[39mupdate(\u001B[38;5;241m1\u001B[39m)\n\u001B[0;32m 279\u001B[0m \u001B[38;5;66;03m# print(f\"DONE FEATURE------> {f.source.name}\"\u001B[39;00m\n\u001B[0;32m 280\u001B[0m \u001B[38;5;66;03m# f\" {(time.perf_counter() - start):.2f} {self._features[f.source.name]['type']}\")\u001B[39;00m\n\u001B[0;32m 281\u001B[0m \u001B[38;5;66;03m# self.progress_bar.set_description_str('[FEATURES DONE]')\u001B[39;00m\n\u001B[0;32m 282\u001B[0m \u001B[38;5;66;03m# self.progress_bar.close()\u001B[39;00m\n\u001B[0;32m 283\u001B[0m \n\u001B[0;32m 284\u001B[0m \u001B[38;5;66;03m# Wrap up summary\u001B[39;00m\n",
|
||||
"File \u001B[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\sweetviz\\series_analyzer.py:142\u001B[0m, in \u001B[0;36manalyze_feature_to_dictionary\u001B[1;34m(to_process)\u001B[0m\n\u001B[0;32m 140\u001B[0m \u001B[38;5;66;03m# Perform full analysis on source/compare/target\u001B[39;00m\n\u001B[0;32m 141\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m returned_feature_dict[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mtype\u001B[39m\u001B[38;5;124m\"\u001B[39m] \u001B[38;5;241m==\u001B[39m FeatureType\u001B[38;5;241m.\u001B[39mTYPE_NUM:\n\u001B[1;32m--> 142\u001B[0m \u001B[43msweetviz\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mseries_analyzer_numeric\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43manalyze\u001B[49m\u001B[43m(\u001B[49m\u001B[43mto_process\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mreturned_feature_dict\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 143\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m returned_feature_dict[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mtype\u001B[39m\u001B[38;5;124m\"\u001B[39m] \u001B[38;5;241m==\u001B[39m FeatureType\u001B[38;5;241m.\u001B[39mTYPE_CAT:\n\u001B[0;32m 144\u001B[0m sweetviz\u001B[38;5;241m.\u001B[39mseries_analyzer_cat\u001B[38;5;241m.\u001B[39manalyze(to_process, returned_feature_dict)\n",
|
||||
"File \u001B[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\sweetviz\\series_analyzer_numeric.py:102\u001B[0m, in \u001B[0;36manalyze\u001B[1;34m(to_process, feature_dict)\u001B[0m\n\u001B[0;32m 98\u001B[0m do_stats_numeric(to_process\u001B[38;5;241m.\u001B[39mcompare, compare_dict)\n\u001B[0;32m 100\u001B[0m do_detail_numeric(to_process\u001B[38;5;241m.\u001B[39msource, to_process\u001B[38;5;241m.\u001B[39msource_counts, to_process\u001B[38;5;241m.\u001B[39mcompare_counts, feature_dict)\n\u001B[1;32m--> 102\u001B[0m feature_dict[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mminigraph\u001B[39m\u001B[38;5;124m\"\u001B[39m] \u001B[38;5;241m=\u001B[39m \u001B[43mGraphNumeric\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mmini\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mto_process\u001B[49m\u001B[43m)\u001B[49m\n\u001B[0;32m 103\u001B[0m feature_dict[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mdetail_graphs\u001B[39m\u001B[38;5;124m\"\u001B[39m] \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mlist\u001B[39m()\n\u001B[0;32m 104\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m num_bins \u001B[38;5;129;01min\u001B[39;00m [\u001B[38;5;241m0\u001B[39m, \u001B[38;5;241m5\u001B[39m, \u001B[38;5;241m15\u001B[39m, \u001B[38;5;241m30\u001B[39m]:\n",
|
||||
"File \u001B[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\sweetviz\\graph_numeric.py:71\u001B[0m, in \u001B[0;36mGraphNumeric.__init__\u001B[1;34m(self, which_graph, to_process)\u001B[0m\n\u001B[0;32m 67\u001B[0m normalizing_weights \u001B[38;5;241m=\u001B[39m norm_source\n\u001B[0;32m 69\u001B[0m gap_percent \u001B[38;5;241m=\u001B[39m config[\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mGraphs\u001B[39m\u001B[38;5;124m\"\u001B[39m]\u001B[38;5;241m.\u001B[39mgetfloat(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124msummary_graph_categorical_gap\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m---> 71\u001B[0m warnings\u001B[38;5;241m.\u001B[39mfilterwarnings(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mignore\u001B[39m\u001B[38;5;124m'\u001B[39m, category\u001B[38;5;241m=\u001B[39m\u001B[43mnp\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mVisibleDeprecationWarning\u001B[49m)\n\u001B[0;32m 72\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mhist_specs \u001B[38;5;241m=\u001B[39m axs\u001B[38;5;241m.\u001B[39mhist(plot_data, weights \u001B[38;5;241m=\u001B[39m normalizing_weights, bins\u001B[38;5;241m=\u001B[39m\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mnum_bins, \\\n\u001B[0;32m 73\u001B[0m rwidth \u001B[38;5;241m=\u001B[39m (\u001B[38;5;241m100.0\u001B[39m \u001B[38;5;241m-\u001B[39m gap_percent) \u001B[38;5;241m/\u001B[39m \u001B[38;5;241m100.0\u001B[39m)\n\u001B[0;32m 74\u001B[0m warnings\u001B[38;5;241m.\u001B[39mfilterwarnings(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124monce\u001B[39m\u001B[38;5;124m'\u001B[39m, category\u001B[38;5;241m=\u001B[39mnp\u001B[38;5;241m.\u001B[39mVisibleDeprecationWarning)\n",
|
||||
"File \u001B[1;32m~\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python312\\site-packages\\numpy\\__init__.py:427\u001B[0m, in \u001B[0;36m__getattr__\u001B[1;34m(attr)\u001B[0m\n\u001B[0;32m 424\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21;01mnumpy\u001B[39;00m\u001B[38;5;21;01m.\u001B[39;00m\u001B[38;5;21;01mchar\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;28;01mas\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21;01mchar\u001B[39;00m\n\u001B[0;32m 425\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m char\u001B[38;5;241m.\u001B[39mchararray\n\u001B[1;32m--> 427\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mAttributeError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mmodule \u001B[39m\u001B[38;5;132;01m{!r}\u001B[39;00m\u001B[38;5;124m has no attribute \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 428\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{!r}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;241m.\u001B[39mformat(\u001B[38;5;18m__name__\u001B[39m, attr))\n",
|
||||
"\u001B[1;31mAttributeError\u001B[0m: module 'numpy' has no attribute 'VisibleDeprecationWarning'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 20
|
||||
},
|
||||
{
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-03-02T19:19:56.383373Z",
|
||||
"start_time": "2025-03-02T19:19:54.731156Z"
|
||||
}
|
||||
},
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# Clean the dataset\n",
|
||||
"dataset = pd.read_csv(os.path.join(\"csv\", 'openbci.csv'))\n",
|
||||
"\n",
|
||||
"print(\"Column Timestamp is not useful, dropping it\")\n",
|
||||
"dataset = dataset.drop(columns=['Timestamp'])\n",
|
||||
"for column in dataset.columns:\n",
|
||||
" if dataset[column].unique().size == 1:\n",
|
||||
" print(f\"Column {column} has only one unique value, dropping it\")\n",
|
||||
" dataset = dataset.drop(columns=[column])"
|
||||
],
|
||||
"id": "a84eb1933bd93977",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Column Timestamp is not useful, dropping it\n",
|
||||
"Column Analog Channel 0 has only one unique value, dropping it\n",
|
||||
"Column Analog Channel 1 has only one unique value, dropping it\n",
|
||||
"Column Analog Channel 2 has only one unique value, dropping it\n",
|
||||
"Column Marker Channel has only one unique value, dropping it\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"execution_count": 16
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
@@ -17,6 +17,57 @@
|
||||
"estimators = 100"
|
||||
]
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "markdown",
|
||||
"source": "# UDP Receiver"
|
||||
},
|
||||
{
|
||||
"metadata": {},
|
||||
"cell_type": "code",
|
||||
"outputs": [],
|
||||
"execution_count": null,
|
||||
"source": [
|
||||
"import socket\n",
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"from sklearn.ensemble import RandomForestClassifier\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"UDP_IP = \"0.0.0.0\"\n",
|
||||
"UDP_PORT = 5005\n",
|
||||
"BUFFER_SIZE = 1024\n",
|
||||
"\n",
|
||||
"dataset = pd.read_csv(os.path.join(\"csv\", 'openbci.csv'))\n",
|
||||
"\n",
|
||||
"X = dataset.iloc[:, :-1].values\n",
|
||||
"y = dataset.iloc[:, -1].values\n",
|
||||
"\n",
|
||||
"modelo = RandomForestClassifier(n_estimators=100, random_state=19)\n",
|
||||
"modelo.fit(X, y)\n",
|
||||
"\n",
|
||||
"columnas = dataset.columns[:-1]\n",
|
||||
"\n",
|
||||
"sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n",
|
||||
"sock.bind((UDP_IP, UDP_PORT))\n",
|
||||
"\n",
|
||||
"print(f\"🔄 Servidor UDP en {UDP_IP}:{UDP_PORT}, esperando datos...\")\n",
|
||||
"\n",
|
||||
"while True:\n",
|
||||
" try:\n",
|
||||
" data, addr = sock.recvfrom(BUFFER_SIZE)\n",
|
||||
" decoded_data = data.decode(\"utf-8\").strip()\n",
|
||||
"\n",
|
||||
" values = np.array([float(x) for x in decoded_data.split(\",\")]).reshape(1, -1)\n",
|
||||
"\n",
|
||||
" df = pd.DataFrame(values, columns=columnas)\n",
|
||||
"\n",
|
||||
" prediccion = modelo.predict(df)[0]\n",
|
||||
"\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"❌ Error al procesar el dato: {e}\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -53,13 +104,7 @@
|
||||
],
|
||||
"source": [
|
||||
"dataset = pd.read_csv(os.path.join(\"csv\", 'openbci.csv'))\n",
|
||||
"# Clean the dataset\n",
|
||||
"print(\"Column Timestamp is not useful, dropping it\")\n",
|
||||
"dataset = dataset.drop(columns=['Timestamp'])\n",
|
||||
"for column in dataset.columns:\n",
|
||||
" if dataset[column].unique().size == 1:\n",
|
||||
" print(f\"Column {column} has only one unique value, dropping it\")\n",
|
||||
" dataset = dataset.drop(columns=[column])\n",
|
||||
"\n",
|
||||
"print(\"-\"*70)\n",
|
||||
"# Split the dataset\n",
|
||||
"X = dataset.iloc[:, :-1].values\n",
|
||||
@@ -81,23 +126,19 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Accuracy: 0.9947342176450832 (+/- 0.0004227947973763874)\n"
|
||||
]
|
||||
"metadata": {
|
||||
"jupyter": {
|
||||
"is_executing": true
|
||||
}
|
||||
],
|
||||
},
|
||||
"source": [
|
||||
"clf = RandomForestClassifier(n_estimators=estimators, n_jobs=-1, random_state=random_state)\n",
|
||||
"cv = StratifiedKFold(n_splits=splits, shuffle=True, random_state=random_state)\n",
|
||||
"scores = cross_validate(clf, X, y, scoring=\"accuracy\", cv=cv, n_jobs=-1, return_train_score=True)\n",
|
||||
"print(f\"Accuracy: {np.mean(scores['test_score'])} (+/- {np.std(scores['test_score'])})\")"
|
||||
]
|
||||
],
|
||||
"outputs": [],
|
||||
"execution_count": null
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@@ -131,6 +172,7 @@
|
||||
"source": [
|
||||
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.20, random_state=random_state, stratify=y)\n",
|
||||
"clf.fit(X_train, y_train)\n",
|
||||
"\n",
|
||||
"y_pred = clf.predict(X_test)\n",
|
||||
"print(classification_report(y_test, y_pred, digits=7))"
|
||||
]
|
||||
|
23
graficas.py
Normal file
23
graficas.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Datos de número de esferas y tiempos de ejecución
|
||||
esferas = [2, 3, 4, 5, 6, 7, 8, 9, 10]
|
||||
tiempo_sin_opt = [0.000352, 0.000665, 0.001057, 0.001575, 0.002254, 0.003026, 0.003879, 0.004943, 0.006069]
|
||||
tiempo_con_opt = [0.000415, 0.000782, 0.001290, 0.001933, 0.002772, 0.003041, 0.004010, 0.005100, 0.006061]
|
||||
|
||||
# Crear la gráfica
|
||||
plt.figure(figsize=(8, 5))
|
||||
plt.plot(esferas, tiempo_sin_opt, marker="o", linestyle="-", label="Tiempo sin optimizar")
|
||||
plt.plot(esferas, tiempo_con_opt, marker="s", linestyle="--", label="Tiempo optimizado (-O2)")
|
||||
|
||||
plt.xlabel("Número de Esferas")
|
||||
plt.ylabel("Tiempo de ejecución (s)")
|
||||
plt.title("Comparación de Tiempos de Ejecución con y sin Optimización")
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
|
||||
# Guardar la imagen en el mismo directorio
|
||||
plt.savefig("comparacion_tiempos.png")
|
||||
|
||||
# Mostrar la gráfica
|
||||
plt.show()
|
Reference in New Issue
Block a user