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
""" | |
This module implements the Lowess function for nonparametric regression. | |
Functions: | |
lowess Fit a smooth nonparametric regression curve to a scatterplot. | |
For more information, see | |
William S. Cleveland: "Robust locally weighted regression and smoothing | |
scatterplots", Journal of the American Statistical Association, December 1979, |
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
===================== | |
Lasso and Elastic Net | |
===================== | |
Lasso and elastic net (L1 and L2 penalisation) implemented using a | |
coordinate descent. | |
The coefficients can be forced to be positive. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import numpy as np | |
from scipy import linalg | |
from datetime import datetime | |
import gc | |
mu_sec = 1e-6 # number of seconds in one microseconds | |
solve_time =[] | |
solve_triangular_time =[] |
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
""" | |
Just some experiments with pls | |
""" | |
import numpy as np | |
m, n = 3, 3 | |
X = np.random.randn(m, n) | |
Y = np.random.randn(m, n) |
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
import pylab as pl | |
import numpy as np | |
import scipy.linalg | |
nrm2, = scipy.linalg.get_blas_funcs(('nrm2',), np.empty(0, dtype=np.float32)) | |
x_min, x_max = -4., 0 | |
y_min, y_max = 0, 4. | |
h = 134567e-7 |
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
import numpy as np | |
from scikits.learn import svm, grid_search, datasets | |
iris = datasets.load_iris() | |
parameters = {'C': [np.array(1)]} | |
svr = svm.SVC() | |
clf = grid_search.GridSearchCV(svr, parameters) | |
clf.fit(iris.data, iris.target) | |
print clf.grid_points_scores_ |
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
""" | |
=============================================== | |
Handwritten digits and Locally Linear Embedding | |
=============================================== | |
An illustration of locally linear embedding on the digits dataset. | |
""" | |
# Author: Fabian Pedregosa -- <fabian.pedregosa@inria.fr> | |
# License: BSD, (C) INRIA 2011 |
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
import numpy as np | |
from scipy import linalg | |
def cgs(A): | |
"""Classical Gram-Schmidt (CGS) algorithm""" | |
m, n = A.shape | |
R = np.zeros((n, n)) | |
Q = np.empty((m, n)) | |
R[0, 0] = linalg.norm(A[:, 0]) | |
Q[:, 0] = A[:, 0] / R[0, 0] |
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
import numpy as np | |
from scipy import linalg | |
def ridge(A, b, alphas): | |
"""Return coefficients for regularized least squares | |
||A x - b|| + alpha ||x|| | |
""" | |
U, s, V = linalg.svd(X, full_matrices=False) | |
d = np.dot(U.T, y) / (s + alphas[:, np.newaxis] / s) | |
return np.dot(d, V) |
OlderNewer