Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
""" | |
LightPCA : PCA with little memory footprint, but can only fit_transform() | |
the data (no transform(), no inverse_transform()). | |
targeted data (be sure to have at least 5-6GB of free memory): | |
>>> import numpy as np | |
>>> from light_pca import LightPCA | |
>>> X = np.random.randn(1301, 500000) # ~5GB | |
>>> pca = LightPCA(copy=False, n_components=1300) | |
>>> X = pca.fit_transform(X) | |
""" |
This file contains hidden or 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 | |
import svmlight_loader | |
from sklearn.ensemble import GradientBoostingRegressor | |
from time import time | |
ROOT_DIR = '/home/pprett/corpora/yahoo-ltrc-2010/data' | |
X_train, y_train = svmlight_loader.load_svmlight_file(ROOT_DIR + '/set1.train.txt', | |
n_features=700, |
This file contains hidden or 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, optimize | |
MAX_ITER = 100 | |
def group_lasso(X, y, alpha, groups, max_iter=MAX_ITER, rtol=1e-6, | |
verbose=False): | |
""" | |
Linear least-squares with l2/l1 regularization solver. |
This file contains hidden or 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) |
This file contains hidden or 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, |