import pandas as pd
import numpy as np
from sklearn.cluster import KMeans
iris = pd.read_csv('../input/mydata2/4-iris.data')
data=iris.values
X=data[:,[0,1]]
Y = data[:,4]
import matplotlib.pyplot as plt
# Truth
label = set(iris['species'])
for i in label:
species=iris[iris['species']==i]
plt.scatter(species['sepal_length'], species['sepal_width'])
plt.show()
c=np.insert(X,2,kmeans, axis=1)
import matplotlib.pyplot as plt
# Kmeans Predict
label = set(kmeans)
for i in label:
species=c[c[:,2]==i]
plt.scatter(species[:,0], species[:,1])
plt.show()
ผลที่ได้
5. ลองปรับค่า n_cluster=3
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=3).fit_predict(X)
kmeans3
ผลที่ได้
5. ลองปรับค่า n_cluster=4
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=4).fit_predict(X)
kmeans3
ที่เด่นสุดคือ สามารถใช้ไฟล์จาก Google Drive ได้ !!! เป็นประโยชน์มาก โดยเฉพาะกับมหาวิทยาลัยที่ได้ใช้บริการ G Suite for Education อย่าง ม.สงขลานครินทร์ เพราะ เราจะสามารถใช้พื้นที่ได้ Unlimited !
แต่!!!
สุดท้ายก็มาติดตรงที่ Google Colab นี้ เป็น VM อยู่ใน Google Compute Engine นั่นแหล่ะ แต่เค้าไม่คิดค่าบริการกับเรา ซึ่งของฟรี ก็มีข้อจำกัดอยู่คือ พื้นที่
Google Colab ให้ประมาณ 400 GB
แต่อย่างน้อย ก็สามารถเชื่อมต่อเอาข้อมูลจาก Google Drive มาได้ง่าย ก็ดีแล้ว แถม Jupyter Notebook ที่สร้างก็สามารถ Save เก็บไว้ใน Google Drive ได้เลย การส่งผลลัพท์ออกไป Google Drive ก็ง่าย
วิธีการคือ ให้เพิ่ม email address ของ Group ที่เป็น Parent ลงไปใน Child Group เช่น ในที่นี้ เพิ่ม all-staffs@groups.google.com ลงไปเป็นสมาชิกของ faculty01 Group แล้วตั้งค่าให้ Email Delivery เป็น No email และ Posting Permission เป็น Override : member is allowed to post