CS 6601 fall 2020 assignment5 Georgia Institute Of Technology
CS 6601 fall 2020 assignment5 Georgia Institute Of Technology #!/usr/bin/env python # coding: utf-8 # This was input cell with execution count: 1 import os import numpy as np from helper_functions import * # Please don't modify this cell # This was input cell with execution count: def get_initial_means(array, k): """ Picks k random points from the 2D array (without replacement) to use as initial cluster means params: array = ay[ay[float]] - m x n | datapoints x features k = int returns: initial_means = ay[ay[float]] """ newArr = () le(newArr) # First shuffle up the array (so we don't need to worry about random selection) return newArr[:k] # Select k values to return # This was input cell with execution count: def dist(a, b, axis=1): """ Euclidean Distance metric """ return (a - b, axis=axis) def k_means_step(image_values, k, means): """ A single update/step of the K-means algorithm Based on a input image_values and current mean estimate calculate new means and predict clusters for each of the pixel params: image_values = ay[ay[ay[float]]] k = int initial_means = ay[ay[float]] returns: new_means = ay[ay[float]] clusters = ay[ay[int]] """ new_means = ay(shape=(k, len(image_values[0])), dtype=float) clusters = (shape=len(image_values), dtype=int) meanPts = [] for i in range(k): meanPd( []) # For meanPts, we group all points by their corresponding cluster so we can calculate the new means eucDist = (shape=(len(image_values), k), dtype=float) # This is for distance from each mean
Escuela, estudio y materia
- Institución
-
Georgia Institute Of Technology
- Grado
-
CS 6601
Información del documento
- Subido en
- 5 de agosto de 2021
- Número de páginas
- 12
- Escrito en
- 2021/2022
- Tipo
- Otro
- Personaje
- Desconocido
Temas
-
cs 6601 fall 2020 assignment5 georgia institute of technology
Documento también disponible en un lote