This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import numpy as np | |
from sklearn.decomposition import PCA | |
n_components=10 | |
ncomp_selected = 0 # the index of the PCA component to select (int or list) | |
# read image | |
pilimg_pumpkin = Image.open('pumpkin.jpg') | |
npimg_pumpkin = np.array(pilimg_pumpkin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sum_from_one(k): | |
sum = 0 | |
for i in range(1, k+1): | |
sum += i | |
return sum | |
sum_list = [] | |
for i in range(0, N): | |
sum_list.append(sum_from_one(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def linear_fit(x, y): | |
N_ = len(x) | |
X_, y_ = np.vstack([x, np.ones(N_)]).T, np.array(y) | |
fit_results = np.linalg.lstsq(X_, y_, rcond=None) | |
a_, b_ = fit_results[0] | |
r2error_ = fit_results[1][0] | |
return a_, b_, r2error_ |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer