Skip to content

Instantly share code, notes, and snippets.

@fabianp
Created February 10, 2011 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianp/820401 to your computer and use it in GitHub Desktop.
Save fabianp/820401 to your computer and use it in GitHub Desktop.
Some experiments with PLS
"""
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)
from scikits.learn import pls
clf = pls.PLSRegression()
clf.fit(X, Y, algorithm='svd', n_components=n)
print clf.coefs
#
# Seems strange to me that results vary so much
#
clf.fit(X, Y, algorithm='nipals', n_components=n)
print clf.coefs
#
# I would expect pls to degrade gracefully into usual regression when
# Y is a vector. Instead, I get a LinalgError
#
clf.n_components = 1
clf.fit([[0, 0], [1, 1]], [0, 1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment