Skip to content

Instantly share code, notes, and snippets.

View RamonLopezEscudero's full-sized avatar

Ramon Lopez Escudero RamonLopezEscudero

  • Universidad de Guanajuato
View GitHub Profile
@RamonLopezEscudero
RamonLopezEscudero / divide_poligono_qgis.py
Created September 22, 2017 21:50
Division de polígonos sin errores topológicos en QGIS usando Python
# -*- coding: utf-8 -*-
def calcula_lado_linea(x0, x1, x2, y0, y1, y2):
valor = (x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0)
if valor > 0 and valor >= (1 * 10**(-10)):
aux_valor = 1
elif valor > 0 and valor < (1 * 10**(-10)):
aux_valor = 0
elif valor < 0 and abs(valor) < (1 * 10**(-10)):
aux_valor = 0
@RamonLopezEscudero
RamonLopezEscudero / MST_Prim.py
Created May 27, 2017 02:48
Algoritmo para realizar un MST con el algoritmo de Prim. La construcción del grafo fue basada a partir del código compartido por K. Hong (https://plus.google.com/+KHongSanFrancisco)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import sys
class Graph:
def __init__(self):
self.size = 0
self.vertices = { }
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import numpy as np
# ------------------------------------------------------------- #
# -------------------------FUNCIONES--------------------------- #
def generate_random_points_2D(num_puntos, media, mat_cov):
aux_arr = []
for i in range(num_puntos):
@RamonLopezEscudero
RamonLopezEscudero / EM.py
Created March 20, 2017 07:52
EM Algorithm
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import numpy as np
# ------------------------------------------------------------- #
# -------------------------FUNCIONES--------------------------- #
def generate_random_points_2D(num_puntos, media, mat_cov):
aux_arr = []
for i in range(num_puntos):
@RamonLopezEscudero
RamonLopezEscudero / KNearestNeighbors.py
Created March 2, 2017 18:36
Clasificación con K-Vecinos Cercanos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import numpy as np
import matplotlib.pyplot as plt
# ------------------------------------------------------------- #
# ---------------------------CLASES---------------------------- #
class KNearest:
def __init__(self, num_datos, knear):
@RamonLopezEscudero
RamonLopezEscudero / Minimos_Cuadrados.py
Created February 24, 2017 22:12
Mínimos cuadrados: método del gradiente descendente y por la pseudoinversa.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import Matrix_Operations as matope
import numpy as np
import matplotlib.pyplot as plt
# ------------------------------------------------------------- #
# -------------------------FUNCIONES--------------------------- #
def generate_random_points_2D(clase, num_puntos, media, mat_cov):
@RamonLopezEscudero
RamonLopezEscudero / Perceptron.py
Created February 22, 2017 08:35
Clasificación binaria a través de un perceptrón
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import numpy as np
import matplotlib.pyplot as plt
# ------------------------------------------------------------- #
# -------------------------FUNCIONES--------------------------- #
class perceptron:
def __init__(self, num_datos):
@RamonLopezEscudero
RamonLopezEscudero / Layered_Range_Tree.py
Created February 15, 2017 23:39
Algoritmo para la búsqueda en rango 2D utilizando "Fractional Cascading"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import copy
import random as rand
import matplotlib.pyplot as plt
# ------------------------------------------------------------- #
# ---------------------------CLASES---------------------------- #
class Estructura2D:
@RamonLopezEscudero
RamonLopezEscudero / k_queens.py
Created February 10, 2017 01:47
Problema de las k-reinas con algoritmos genéticos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import time
import numpy as np
from itertools import izip_longest, imap
import matplotlib.pyplot as plt
import random as rand
# ------------------------------------------------------------- #
@RamonLopezEscudero
RamonLopezEscudero / Range_2D_Tree.py
Last active February 10, 2017 01:44
Búsqueda en rango 2D
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------LIBRERIAS-------------------------- #
# ------------------------------------------------------------- #
import random as rand
import matplotlib.pyplot as plt
# ------------------------------------------------------------- #
# ---------------------------CLASES---------------------------- #
class Node:
def __init__(self, val):