Assignment4
Assignment4
ipynb - Colaboratory
import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
drive.mount('/content/gdrive')
[[-7.87157 -4.86573]
[-4.76661 -6.87944]
[-6.67986 -5.8308 ]
...
[ 6.91832 -0.32132]
[-8.23828 -4.00405]
[-5.75112 -5.99531]]
#taking k as input
k = int(input("Enter the value of k : "))
x1 = np.asarray(clusters[0])[:, 0]
y1 = np.asarray(clusters[0])[:, 1]
x2 = np.asarray(clusters[1])[:, 0]
y2 = np.asarray(clusters[1])[:, 1]
# plotting classified data points of two classes with different colored marker
plt.scatter(x1, y1, c = 'red', marker = 's', label = 'Class 1')
plt.scatter(x2, y2, c = 'green', marker = 'H', label = 'Class 2')
plt.legend(loc = 'best')
plt.show()
https://colab.research.google.com/drive/1A2rXv6R5N4bVbrStI9bsxdhKsJlzNVYu?authuser=3#scrollTo=QzW8dbY5YkR0&printMode=true 2/3
8/20/22, 7:33 PM 180104072_Assignment4.ipynb - Colaboratory
https://colab.research.google.com/drive/1A2rXv6R5N4bVbrStI9bsxdhKsJlzNVYu?authuser=3#scrollTo=QzW8dbY5YkR0&printMode=true 3/3