def reduceDim(data, dim, func='pca'):
 try:
  pcaFunc = globals()[func]
 except KeyError:
  raise ValueError('Unknown function to calc principal components')
 pc = pcaFunc(data, dim)
 return (pc * asmatrix(makeCentered(data)).T).T

def reduceDim ( data , dim , func = 'pca' ) : try : pcaFunc = globals ( ) [ func ] except KeyError : raise ValueError ( 'Unknown function to calc principal components' ) pc = pcaFunc ( data , dim ) return ( pc * asmatrix ( makeCentered ( data ) ) . T ) . T
reduce the dimension of datapoints to dim via principal component analysis .