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 | |
def lse(A, b, B, d): | |
""" | |
Equality-contrained least squares. | |
The following algorithm minimizes ||Ax - b|| subject to the | |
constrain Bx = d. |
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
int covariance(int n, int m, double data[], int strides[2], char mode, double matrix[]) | |
/* This algorithm is described in: | |
* B.P. Welford: | |
* "Note on a method for calculating corrected sums of squares and products." | |
* Technometrics 4(3): 419-420 (1962). | |
* Also see: | |
* Peter M. Neely: | |
* "Comparison of several algorithms for computation of means, standard | |
* deviations and correlation coefficients." | |
* Communications of the ACM 9(7): 496-499 (1966). |
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
# -*- coding: utf-8 -*- | |
""" | |
=================================== | |
Swiss Roll reduction with LLE | |
=================================== | |
An illustration of Swiss Roll reduction | |
with locally linear embedding | |
""" |
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 -- <[email protected]> | |
# 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
""" | |
Hilbert matrix using numpy. Contains: | |
- hilb(n, m) : returns the Hilbert matrix of size (n, m) | |
- invhilb(n) : returns the inverse of the Hilbert matrix of size (n, n) | |
""" | |
import numpy as np | |
from math import factorial |
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] |
OlderNewer