Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Changed from deprecated scipy.stats.mean() to numpy.mean().

This commit is contained in:
Einar Ryeng 2009-11-22 18:25:43 +00:00
parent f2afcbc3fc
commit c50d34effc
5 changed files with 12 additions and 12 deletions

View File

@ -10,7 +10,7 @@ import gtk
import laydi import laydi
from laydi import plots, main,logger from laydi import plots, main,logger
import scipy import scipy
from scipy import dot,sum,diag,arange,log,mean,newaxis,sqrt,apply_along_axis,empty from scipy import dot,sum,diag,arange,log,newaxis,sqrt,apply_along_axis,empty
from scipy.stats import corrcoef from scipy.stats import corrcoef
def correlation_loadings(data, T, test=True): def correlation_loadings(data, T, test=True):
@ -418,7 +418,7 @@ class TRBiplot(plots.ScatterPlot):
# normalize B # normalize B
Bnorm = scipy.apply_along_axis(scipy.linalg.norm, 1, B) Bnorm = scipy.apply_along_axis(scipy.linalg.norm, 1, B)
x = model._dataset['X'].copy() x = model._dataset['X'].copy()
Xc = x._array - mean(x._array,0)[newaxis] Xc = x._array - x._array.mean(0)[newaxis]
w_rot = B/Bnorm w_rot = B/Bnorm
t_rot = dot(Xc, w_rot) t_rot = dot(Xc, w_rot)

View File

@ -5,7 +5,7 @@ from scipy import zeros,zeros_like,sqrt,dot,trace,sign,round_,argmax,\
sort,ravel,newaxis,asarray,diag,sum,outer,argsort,arange,ones_like,\ sort,ravel,newaxis,asarray,diag,sum,outer,argsort,arange,ones_like,\
all,apply_along_axis,eye,atleast_2d,empty all,apply_along_axis,eye,atleast_2d,empty
from scipy.linalg import svd,inv,norm,det,sqrtm from scipy.linalg import svd,inv,norm,det,sqrtm
from scipy.stats import mean,median from scipy.stats import median
#import plots_lpls #import plots_lpls
@ -46,7 +46,7 @@ def hotelling(Pcv, P, p_center='med', cov_center='med',
P_ctr = median(Pcv, 0) P_ctr = median(Pcv, 0)
elif p_center=='mean': elif p_center=='mean':
# fixme: mean is unstable # fixme: mean is unstable
P_ctr = mean(Pcv, 0) P_ctr = Pcv.mean(0)
else: #use full else: #use full
P_ctr = P P_ctr = P
@ -59,7 +59,7 @@ def hotelling(Pcv, P, p_center='med', cov_center='med',
if cov_center == 'med': if cov_center == 'med':
Cov = median(Cov_i, 0) Cov = median(Cov_i, 0)
else: else:
Cov = mean(Cov_i, 0) Cov = Cov_i.mean(0)
reg_cov = (1. - alpha)*Cov_i + alpha*Cov reg_cov = (1. - alpha)*Cov_i + alpha*Cov
for i in xrange(n): for i in xrange(n):
@ -428,7 +428,7 @@ def fdr(tsq, tsqp, loc_method='mean'):
n_false[j,i] = (tsqp[:,i]>tsq[j]).sum() n_false[j,i] = (tsqp[:,i]>tsq[j]).sum()
#cPickle.dump(n_false, open("/tmp/nfalse.dat_"+str(n), "w")) #cPickle.dump(n_false, open("/tmp/nfalse.dat_"+str(n), "w"))
if loc_method=='mean': if loc_method=='mean':
fp = mean(n_false,1) fp = n_false.mean(1)
elif loc_method == 'median': elif loc_method == 'median':
fp = median(n_false.T) fp = median(n_false.T)
else: else:

View File

@ -3,7 +3,7 @@ from scipy import apply_along_axis,newaxis,zeros,\
trace,zeros_like,sign,sort,real,argsort,rand,array,\ trace,zeros_like,sign,sort,real,argsort,rand,array,\
matrix,nan matrix,nan
from scipy.linalg import norm,svd,inv,eig from scipy.linalg import norm,svd,inv,eig
from scipy.stats import median,mean from scipy.stats import median
def normalise(a, axis=0, return_scales=False): def normalise(a, axis=0, return_scales=False):
s = apply_along_axis(norm, axis, a) s = apply_along_axis(norm, axis, a)
@ -99,11 +99,11 @@ def mat_center(X,axis=0,ret_mn=False):
print "The X data needs to be two-dimensional" print "The X data needs to be two-dimensional"
if axis==0: if axis==0:
mnX = mean(X,axis)[newaxis] mnX = X.mean(axis)[newaxis]
Xs = X - mnX Xs = X - mnX
elif axis==1: elif axis==1:
mnX = mean(X,axis)[newaxis] mnX = X.mean(axis)[newaxis]
Xs = (X.T - mnX).T Xs = (X.T - mnX).T
if ret_mn: if ret_mn:
return Xs,mnX return Xs,mnX

View File

@ -1,6 +1,6 @@
"""Matrix cross validation selection generators """Matrix cross validation selection generators
""" """
from scipy import take,arange,ceil,repeat,newaxis,mean,asarray,dot,ones,\ from scipy import take,arange,ceil,repeat,newaxis,asarray,dot,ones,\
random,array_split,floor,vstack,asarray,minimum random,array_split,floor,vstack,asarray,minimum
from cx_utils import randperm from cx_utils import randperm
@ -188,7 +188,7 @@ def diag_pert(a, n_sets=10, center=True, index_out=False):
nm=n*m nm=n*m
start_inds = array_split(randperm(m),n_sets) # we use random start diags start_inds = array_split(randperm(m),n_sets) # we use random start diags
if center: if center:
a = a - mean(a, 0)[newaxis] a = a - a.mean(0)[newaxis]
for v in range(n_sets): for v in range(n_sets):
a_out = a.copy() a_out = a.copy()
out = [] out = []

View File

@ -1,6 +1,6 @@
"""This module implements some common validation schemes from pca and pls. """This module implements some common validation schemes from pca and pls.
""" """
from scipy import ones,mean,sqrt,dot,newaxis,zeros,sum,empty,\ from scipy import ones,sqrt,dot,newaxis,zeros,sum,empty,\
apply_along_axis,eye,kron,array,sort,zeros_like,argmax,atleast_2d apply_along_axis,eye,kron,array,sort,zeros_like,argmax,atleast_2d
from scipy.stats import median from scipy.stats import median
from scipy.linalg import triu,inv,svd,norm from scipy.linalg import triu,inv,svd,norm