Computer Science > Research Paper > Georgia Institute Of Technology - CS 6601fall_2021_assignment5 LATEST 2021/2022 (All)

Georgia Institute Of Technology - CS 6601fall_2021_assignment5 LATEST 2021/2022

Document Content and Description Below

#!/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 wi... th 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 = numpy.ndarray[numpy.ndarray[float]] - m x n | datapoints x features k = int returns: initial_means = numpy.ndarray[numpy.ndarray[float]] """ newArr = array.copy() np.random.shuffle(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 np.linalg.norm(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 = numpy.ndarray[numpy.ndarray[numpy.ndarray[float]]] k = int initial_means = numpy.ndarray[numpy.ndarray[float]] returns: new_means = numpy.ndarray[numpy.ndarray[float]] clusters = numpy.ndarray[numpy.ndarray[int]] """ new_means = np.ndarray(shape=(k, len(image_values[0])), dtype=float) clusters = np.zeros(shape=len(image_values), dtype=int) meanPts = [] for i in range(k): meanPts.append( []) # For meanPts, we group all points by their corresponding cluster so we can calculate the new means eucDist = np.zeros(shape=(len(image_values), k), dtype=float) # This is for distance from each mean [Show More]

Last updated: 1 year ago

Preview 1 out of 12 pages

Reviews( 0 )

$7.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

GET ASSIGNMENT HELP
44
0

Document information


Connected school, study & course


About the document


Uploaded On

Aug 05, 2021

Number of pages

12

Written in

Seller


seller-icon
Tutor Frankline

Member since 2 years

37 Documents Sold


Additional information

This document has been written for:

Uploaded

Aug 05, 2021

Downloads

 0

Views

 44

Document Keyword Tags

More From Tutor Frankline

View all Tutor Frankline's documents »

Recommended For You

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·