Skip to content

Instantly share code, notes, and snippets.

View henrych4's full-sized avatar

hhh henrych4

  • Hong Kong
View GitHub Profile
@henrych4
henrych4 / 3a.py
Last active December 11, 2017 06:26
codes for assignment3 of ENGG5103
#Reference: http://scikit-learn.org/stable/auto_examples/neighbors/plot_classification.html#sphx-glr-auto-examples-neighbors-plot-classification-py
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn import neighbors
# Set to 1 for 3a, set to 3 for 3b
n_neighbors = 3
@henrych4
henrych4 / download_GoogleDrive.py
Last active January 17, 2024 04:02
A python script for downloading file in google drive
#Reference: https://stackoverflow.com/questions/38511444/python-download-files-from-google-drive-using-url
import requests
def download_file_from_google_drive(id, destination):
URL = "https://docs.google.com/uc?export=download"
session = requests.Session()
response = session.get(URL, params = { 'id' : id }, stream = True)
import numpy as np
from scipy.spatial import distance
m1 = [1, 3.1]
m2 = [1.5, 2.1]
m3 = [2, 2.2]
m4 = [3.1, 1.1]
all_m = [m1, m2, m3, m4]
all_m = np.array(all_m)
@henrych4
henrych4 / 4b.py
Last active November 9, 2017 08:14
import numpy as np
from scipy.spatial import distance
m1 = [1, 3.1]
m2 = [1.5, 2.1]
m3 = [2, 2.2]
m4 = [3.1, 1.1]
all_m = [m1, m2, m3, m4]
all_m = np.array(all_m)
a = 0.3