ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | FAIL | download_stamp > now() - 6 MONTH | 8 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://labex.io/es/tutorials/ml-kernel-density-estimation-49109 |
| Last Crawled | 2025-08-15 16:32:12 (7 months ago) |
| First Indexed | not set |
| HTTP Status Code | 200 |
| Meta Title | Dominando la Estimación de Densidad Kernel para la Generación de Datos | LabEx |
| Meta Description | Explora el poder de la Estimación de Densidad Kernel para generar nuevas muestras de datos a partir del conjunto de datos de dígitos usando Python y scikit-learn. |
| Meta Canonical | null |
| Boilerpipe Text | Introducción La Estimación de Densidad Kernel (KDE, por sus siglas en inglés) es una técnica de estimación de densidad no paramétrica. En este laboratorio, aprenderemos a usar la KDE para generar nuevas muestras de datos. Usaremos la biblioteca scikit-learn para implementar esta técnica. Consejos sobre la VM Una vez que se haya iniciado la VM, haga clic en la esquina superior izquierda para cambiar a la pestaña Cuaderno y acceder a Jupyter Notebook para practicar. A veces, es posible que tenga que esperar unos segundos a que Jupyter Notebook termine de cargarse. La validación de las operaciones no se puede automatizar debido a las limitaciones de Jupyter Notebook. Si tiene problemas durante el aprendizaje, no dude en preguntar a Labby. Deje sus comentarios después de la sesión y lo resolveremos rápidamente para usted. |
| Markdown | [](https://labex.io/es)
- [Aprender](https://labex.io/es/learn "Learn")
- [Proyectos](https://labex.io/es/projects "Projects")
- [Precios](https://labex.io/es/pricing "Pricing")
[Iniciar Sesión](https://labex.io/es/login)[Únete Gratis](https://labex.io/es/register)
1. [Aprender](https://labex.io/es)
2. [Tutoriales](https://labex.io/es/tutorials)
3. [Machine Learning](https://labex.io/es/tutorials/category/ml)
# Estimación de Densidad Kernel
[Machine Learning](https://labex.io/learn/ml)
Beginner

Estimación de Densidad Kernel
[Practicar Ahora](https://labex.io/es/labs/ml-kernel-density-estimation-49109)
This tutorial is from open-source community. Access the source code
💡 Este tutorial está traducido por IA desde la versión en inglés. Para ver la versión original, puedes [hacer clic aquí](https://labex.io/tutorials/ml-kernel-density-estimation-49109)
Contenido
- [Introducción](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109#introducci%C3%B3n)
- [Cargar datos](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109#cargar-datos)
- [Optimizar el ancho de banda](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109#optimizar-el-ancho-de-banda)
- [Generar nuevas muestras](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109#generar-nuevas-muestras)
- [Graficar los resultados](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109#graficar-los-resultados)
- [Resumen](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109#resumen)
[](https://labex.io/es/labs/ml-kernel-density-estimation-49109)
[Practicar Ahora](https://labex.io/es/labs/ml-kernel-density-estimation-49109)
## Introducción
La Estimación de Densidad Kernel (KDE, por sus siglas en inglés) es una técnica de estimación de densidad no paramétrica. En este laboratorio, aprenderemos a usar la KDE para generar nuevas muestras de datos. Usaremos la biblioteca scikit-learn para implementar esta técnica.
### Consejos sobre la VM
Una vez que se haya iniciado la VM, haga clic en la esquina superior izquierda para cambiar a la pestaña **Cuaderno** y acceder a Jupyter Notebook para practicar.
A veces, es posible que tenga que esperar unos segundos a que Jupyter Notebook termine de cargarse. La validación de las operaciones no se puede automatizar debido a las limitaciones de Jupyter Notebook.
Si tiene problemas durante el aprendizaje, no dude en preguntar a Labby. Deje sus comentarios después de la sesión y lo resolveremos rápidamente para usted.
## Cargar datos
Primero, cargamos el conjunto de datos de dígitos de scikit-learn. Este conjunto de datos contiene imágenes de 8x8 de dígitos del 0 al 9. Usaremos Análisis de Componentes Principales (PCA, por sus siglas en inglés) para reducir la dimensión del conjunto de datos a 15.
```
from sklearn.datasets import load_digits
from sklearn.decomposition import PCA
## load the digits dataset
digits = load_digits()
## reduce the dimension of the dataset to 15 using PCA
pca = PCA(n_components=15, whiten=False)
data = pca.fit_transform(digits.data)
```
## Optimizar el ancho de banda
Usamos la validación cruzada con búsqueda en cuadrícula para optimizar el parámetro de ancho de banda de la KDE. El parámetro de ancho de banda controla la suavidad de la estimación de densidad.
```
from sklearn.neighbors import KernelDensity
from sklearn.model_selection import GridSearchCV
import numpy as np
## use grid search cross-validation to optimize the bandwidth
params = {"bandwidth": np.logspace(-1, 1, 20)}
grid = GridSearchCV(KernelDensity(), params)
grid.fit(data)
print("best bandwidth: {0}".format(grid.best_estimator_.bandwidth))
## use the best estimator to compute the kernel density estimate
kde = grid.best_estimator_
```
## Generar nuevas muestras
Usamos el mejor estimador para tomar 44 nuevos puntos de muestra a partir de los datos. Luego transformamos los nuevos datos de vuelta a sus 64 dimensiones originales usando la inversa de PCA.
```
## sample 44 new points from the data
new_data = kde.sample(44, random_state=0)
new_data = pca.inverse_transform(new_data)
```
## Graficar los resultados
Graficamos los dígitos originales y los dígitos resampleados lado a lado en una cuadrícula de 4x11.
```
import matplotlib.pyplot as plt
## turn data into a 4x11 grid
new_data = new_data.reshape((4, 11, -1))
real_data = digits.data[:44].reshape((4, 11, -1))
## plot real digits and resampled digits
fig, ax = plt.subplots(9, 11, subplot_kw=dict(xticks=[], yticks=[]))
for j in range(11):
ax[4, j].set_visible(False)
for i in range(4):
im = ax[i, j].imshow(
real_data[i, j].reshape((8, 8)), cmap=plt.cm.binary, interpolation="nearest"
)
im.set_clim(0, 16)
im = ax[i + 5, j].imshow(
new_data[i, j].reshape((8, 8)), cmap=plt.cm.binary, interpolation="nearest"
)
im.set_clim(0, 16)
ax[0, 5].set_title("Selection from the input data")
ax[5, 5].set_title('"New" digits drawn from the kernel density model')
plt.show()
```
## Resumen
En este laboratorio, aprendimos cómo usar la Estimación de Densidad Kernel (KDE, por sus siglas en inglés) para generar nuevas muestras de datos. Usamos la biblioteca scikit-learn para implementar esta técnica. Optimizamos el parámetro de ancho de banda de la KDE usando la validación cruzada con búsqueda en cuadrícula. Luego tomamos muestras de nuevos puntos de datos y los transformamos de vuelta a su dimensión original usando PCA. Finalmente, graficamos los dígitos originales y los dígitos resampleados lado a lado en una cuadrícula de 4x11.
compartir
temas
[Linux](https://labex.io/es/tutorials/category/linux)[DevOps](https://labex.io/es/tutorials/category/devops)[Ciberseguridad](https://labex.io/es/tutorials/category/cybersecurity)[Base de datos](https://labex.io/es/tutorials/category/database)[Python](https://labex.io/es/tutorials/category/python)[Docker](https://labex.io/es/tutorials/category/docker)[Kubernetes](https://labex.io/es/tutorials/category/kubernetes)[Red Hat Enterprise Linux](https://labex.io/es/tutorials/category/rhel)[Git](https://labex.io/es/tutorials/category/git)[CompTIA](https://labex.io/es/tutorials/category/comptia)[Shell](https://labex.io/es/tutorials/category/shell)[Nmap](https://labex.io/es/tutorials/category/nmap)[Wireshark](https://labex.io/es/tutorials/category/wireshark)[Hydra](https://labex.io/es/tutorials/category/hydra)[Java](https://labex.io/es/tutorials/category/java)[SQLite](https://labex.io/es/tutorials/category/sqlite)[PostgreSQL](https://labex.io/es/tutorials/category/postgresql)[MySQL](https://labex.io/es/tutorials/category/mysql)[Redis](https://labex.io/es/tutorials/category/redis)[MongoDB](https://labex.io/es/tutorials/category/mongodb)[Golang](https://labex.io/es/tutorials/category/go)[C++](https://labex.io/es/tutorials/category/cpp)[C](https://labex.io/es/tutorials/category/c)[Ansible](https://labex.io/es/tutorials/category/ansible)[Ciencia de datos](https://labex.io/es/tutorials/category/datascience)[Pandas](https://labex.io/es/tutorials/category/pandas)[NumPy](https://labex.io/es/tutorials/category/numpy)[scikit-learn](https://labex.io/es/tutorials/category/sklearn)[Matplotlib](https://labex.io/es/tutorials/category/matplotlib)[Desarrollo web](https://labex.io/es/tutorials/category/webdev)[Alibaba Cloud](https://labex.io/es/tutorials/category/alibaba)[HTML](https://labex.io/es/tutorials/category/html)[CSS](https://labex.io/es/tutorials/category/css)[JavaScript](https://labex.io/es/tutorials/category/javascript)[React](https://labex.io/es/tutorials/category/react)[Kali Linux](https://labex.io/es/tutorials/category/kali)
Reseñas de Usuarios
> " Great Implementation! Ease of Usage and Understanding you covered it all! Also great structuring to make learning practical and easy!"
— abhishek vishwakarma
> " Хорошее начало для понимания Docker и контейнеризации. "
— george\_devops
[Ver Más Reseñas](https://labex.io/es/pricing#reviews)
Relacionado [Machine Learning Cursos](https://labex.io/learn/ml)
[ Inicio rápido con Python LinuxPython Principiante](https://labex.io/es/courses/quick-start-with-python)
[ Aprendizaje Supervisado: Regresión scikit-learnMachine Learning Intermedio](https://labex.io/es/courses/supervised-learning-regression)
[ Aprendizaje Supervisado: Clasificación scikit-learnMachine Learning Intermedio](https://labex.io/es/courses/supervised-learning-classification)
[](https://labex.io/es/tutorials/ml-kernel-density-estimation-49109)
🇪🇸 Español
Aprende Linux, DevOps y Ciberseguridad con Laboratorios Prácticos
CURSOS PRÁCTICOS
[Aprender Linux](https://labex.io/es/learn/linux)
[Aprender Python](https://labex.io/es/learn/python)
[Aprender Ciberseguridad](https://labex.io/es/learn/cybersecurity)
[Aprender Docker](https://labex.io/es/learn/docker)
[Aprender CompTIA](https://labex.io/es/learn/comptia)
[Aprender Java](https://labex.io/es/learn/java)
[Aprender Ciencia de Datos](https://labex.io/es/learn/data-science)
[Aprender Git](https://labex.io/es/learn/git)
[Aprender Kubernetes](https://labex.io/es/learn/kubernetes)
[Aprender Kali Linux](https://labex.io/es/learn/kali)
[Aprender Ansible](https://labex.io/es/learn/ansible)
[Aprender DevOps](https://labex.io/es/learn/devops)
[Aprender Machine Learning](https://labex.io/es/learn/ml)
[Examen de Práctica RHCSA](https://labex.io/es/courses/rhcsa-certification-exam-practice-exercises)
[CompTIA Linux+](https://labex.io/es/courses/comptia-linux-plus-training-labs)
[Ejercicios de Python](https://labex.io/es/exercises/python)
[Hoja de Comandos de Linux](https://linux-commands.labex.io/)
LABORATORIOS DE PRÁCTICA
[Proyectos Linux](https://labex.io/es/projects/category/linux)
[Proyectos Python](https://labex.io/es/projects/category/python)
[Proyectos Java](https://labex.io/es/projects/category/java)
[Proyectos en Lenguaje C](https://labex.io/es/projects/category/c)
[Proyectos DevOps](https://labex.io/es/projects/category/devops)
[Proyectos Golang](https://labex.io/es/projects/category/go)
[Práctica de Git](https://labex.io/es/free-labs/git)
[Práctica de Shell](https://labex.io/es/free-labs/shell)
[Práctica de Java](https://labex.io/es/free-labs/java)
[Práctica de Docker](https://labex.io/es/free-labs/docker)
[Práctica de MySQL](https://labex.io/es/free-labs/mysql)
[Práctica de MongoDB](https://labex.io/es/free-labs/mongodb)
[Práctica de Kubernetes](https://labex.io/es/free-labs/kubernetes)
[Práctica de Machine Learning](https://labex.io/es/free-labs/ml)
[Práctica de Ciberseguridad](https://labex.io/es/free-labs/cybersecurity)
[Práctica de Nmap](https://labex.io/es/free-labs/nmap)
[Práctica de Wireshark](https://labex.io/es/free-labs/wireshark)
ENTORNOS DE PRÁCTICA
[Terminal Linux Online](https://labex.io/es/tutorials/linux-online-linux-playground-372915)
[Entorno Docker](https://labex.io/es/tutorials/docker-online-docker-playground-372912)
[Entorno Python](https://labex.io/es/tutorials/python-online-python-playground-372886)
[Entorno Golang](https://labex.io/es/tutorials/go-online-golang-playground-372913)
[Compilador C++ Online](https://labex.io/es/tutorials/cpp-online-c-playground-372911)
[Entorno Ansible](https://labex.io/es/tutorials/ansible-online-ansible-playground-415831)
[Entorno Jenkins](https://labex.io/es/tutorials/jenkins-online-jenkins-playground-415838)
[Entorno Kubernetes](https://labex.io/es/tutorials/kubernetes-online-kubernetes-cluster-593609)
[Entorno Java](https://labex.io/es/tutorials/java-online-java-playground-372914)
[Entorno Rust](https://labex.io/es/tutorials/rust-online-rust-playground-372918)
[Kali Linux Online](https://labex.io/es/tutorials/kali-online-kali-linux-terminal-and-playground-592935)
[Nmap Online](https://labex.io/es/tutorials/nmap-online-nmap-playground-593613)
[Wireshark Online](https://labex.io/es/tutorials/wireshark-online-wireshark-playground-593624)
[MySQL Online](https://labex.io/es/tutorials/mysql-online-mysql-playground-372916)
[PostgreSQL Online](https://labex.io/es/tutorials/kali-online-postgresql-database-playground-593616)
[Simulador de Examen RHCSA](https://labex.io/es/tutorials/rhel-online-rhel-terminal-rhcsa-and-rhce-exam-playground-592933)
[Máquinas Virtuales Online](https://labex.io/es/tutorials/linux-online-virtual-machines-and-playgrounds-593595)
TUTORIALES
[Tutorial de Linux](https://labex.io/es/tutorials/category/linux)
[Tutorial de Docker](https://labex.io/es/tutorials/category/docker)
[Tutorial de Kubernetes](https://labex.io/es/tutorials/category/kubernetes)
[Tutorial de MongoDB](https://labex.io/es/tutorials/category/mongodb)
[Tutorial de PostgreSQL](https://labex.io/es/tutorials/category/postgresql)
[Tutorial de Wireshark](https://labex.io/es/tutorials/category/wireshark)
[Tutorial de DevOps](https://labex.io/es/tutorials/category/devops)
[Tutorial de Ciberseguridad](https://labex.io/es/tutorials/category/cybersecurity)
[Preguntas de Entrevista de Java](https://labex.io/es/tutorials/java-java-interview-questions-and-answers-593685)
[Preguntas de Entrevista de Python](https://labex.io/es/tutorials/python-python-interview-questions-and-answers-593698)
[Preguntas de Entrevista de Kubernetes](https://labex.io/es/tutorials/kubernetes-kubernetes-interview-questions-and-answers-593688)
[Preguntas de Entrevista de DevOps](https://labex.io/es/tutorials/linux-devops-interview-questions-and-answers-593679)
[Preguntas de Entrevista de Ciberseguridad](https://labex.io/es/tutorials/cybersecurity-cybersecurity-interview-questions-and-answers-593676)
[Preguntas de Entrevista de Docker](https://labex.io/es/tutorials/docker-docker-interview-questions-and-answers-593680)
[Preguntas de Entrevista de Linux](https://labex.io/es/tutorials/linux-linux-interview-questions-and-answers-593689)
[Preguntas de Entrevista de MongoDB](https://labex.io/es/tutorials/mongodb-mongodb-interview-questions-and-answers-593692)
[Preguntas de Entrevista de Bases de Datos](https://labex.io/es/tutorials/linux-database-interview-questions-and-answers-593677)
[SOPORTE](https://support.labex.io/)\|[CONTACTO](https://labex.io/cdn-cgi/l/email-protection#7e171018113e121f1c1b06501711)\|[FORO](https://labex.io/es/forum)\|[TUTORIALES](https://labex.io/es/tutorials)\|[LABORATORIOS GRATUITOS](https://labex.io/es/free-labs)\|[PREGUNTAS DE ENTREVISTA](https://labex.io/es/tutorials/linux-technical-interview-questions-and-answers-593708)\|[EJERCICIOS](https://labex.io/es/exercises)\|[LABEX TEAMS](https://labex.io/es/teams)\|[AFILIADOS](https://labex.io/es/questions/labex-affiliate-program-a6jov663)\|[MAPA DEL SITIO](https://sitemap.labex.io/)\|[POLÍTICA DE PRIVACIDAD](https://labex.io/es/privacy)\|[TÉRMINOS DE SERVICIO](https://labex.io/es/terms)
© 2017-2025 LabEx Technology Limited All Rights Reserved |
| Readable Markdown | null |
| Shard | 28 (laksa) |
| Root Hash | 1963243295958744828 |
| Unparsed URL | io,labex!/es/tutorials/ml-kernel-density-estimation-49109 s443 |