title: Dimensionality reduction being way too slow using PCA and a small dataset
body: <p>I have the following data set stored using numpy:
  <a href="https://www.dropbox.com/sh/ppseiv9skqlhljr/AACQEWZh11oszL5-Z_NHqre3a?dl=0" rel="nofollow">https://www.dropbox.com/sh/ppseiv9skqlhljr/AACQEWZh11oszL5-Z_NHqre3a?dl=0</a></p>
  
  <p>There is a different numpy file for the training and development partitions of the data set</p>
  
  <pre><code>[50,1,396]
  </code></pre>
  
  <p>I am using PCA Fast from the mlpy library in order to perform dimensionality reduction. However the whole process is too slow and I can not find out why.
  Before I perform the PCA I convert the dataset to the following shape:</p>
  
  <pre><code>[50,396]
  </code></pre>
  
  <p>So the shape of the dataset is not the cause of my problem.</p>
  
  <p>The code I use is the following:</p>
  
  <pre><code>import os
  import numpy as np
  import sys
  import csv
  import mlpy
  
  inputfiletrain=''
  outputfiletrain=''
  inputfiledev=''
  outputfiledev=''
  
  def parseCommandLineArgs():
          global inputfiletrain
          global outputfiletrain
          global inputfiledev
          global outputfiledev
  
          for i in range(0, len(sys.argv)):
  
                  if sys.argv[i] == 'inputfiletrain':
                          inputfiletrain = sys.argv[i + 1]
                          print
                          print "------*****Using Directory :*****------"
                          print 'inputfiletrain=' + inputfiletrain
                          print "------**********************------"
                          print
  
                  if sys.argv[i] == 'outputfiletrain':
                          outputfiletrain = sys.argv[i + 1]
                          print
                          print "------*****Using Directory :*****------"
                          print 'outputfiletrain=' + outputfiletrain
                          print "------**********************------"
                          print
  
                  if sys.argv[i] == 'inputfiledev':
                          inputfiledev = sys.argv[i + 1]
                          print
                          print "------*****Using Directory :*****------"
                          print 'inputfiledev=' + inputfiledev
                          print "------**********************------"
                          print
  
                  if sys.argv[i] == 'outputfiledev':
                          outputfiledev = sys.argv[i + 1]
                          print
                          print "------*****Using outputFeatures Filename :*****------"
                          print 'outputfiledev=' + outputfiledev
                          print "------**********************------"
                          print
  
  
  
  
  def pcaDimRed(features, nDims):
          X=np.empty([features.shape[0], features.shape[2]])
          print features.shape[2]
          print X.shape
  
  
          for i,f in enumerate(features):
  
              #np.append(X,f[0],axis=0)
  
              X[i]=f[0]
          #np.vstack(X)
  
  
          print X
          print "PCAStarting"
      #pca = mlpy.PCA(method='cov')
      pca=  mlpy.PCAFast(k=nDims, eps=0.1)
      pca.learn(X)
      coeff = pca.coeff()
      coeff = coeff[:,0:nDims]
  
          print "PCAEnding"
      featuresNew = []
      for f in X:
          ft = f.copy()
  #       ft = pca.transform(ft, k=nDims)
          ft = np.dot(f, coeff)
          featuresNew.append(ft)
  
  
          thodwrisformat = np.empty((len(files), 1, mean.shape[0]))
          for i,f in enumerate(featuresNew):
              thodwrisformat[i][0]=f
  
      return (thodwrisformat, coeff)
  
  def pcaDevelopmentSet(features, nDims,coeff):
  
          featuresNew = []
  
                  for f in features:
                          ft = f.copy()
          #       ft = pca.transform(ft, k=nDims)
                          ft = np.dot(f, coeff)
                          featuresNew.append(ft)
                  return featuresNew
  
  parseCommandLineArgs()
  print inputfiledev
  FeaturesDev = np.load(inputfiledev)
  FeaturesTrain = np.load(inputfiletrain)
  
  PCATrain=pcaDimRed(FeaturesTrain,68)
  FeaturesTrain=PCATrain[1]
  coeff=PCATrain[2]
  FeaturesDev=pcaDevelopmentSet(FeaturesDev, 68,coeff)
  
  
  np.save(outputfiledev,FeaturesDev)
  np.save(outputfiletrain,FeaturesTrain)
  </code></pre>
  
  <p>I am using this code under ubuntu linux and python 2.7. To install mlpy one has to use the following commands:</p>
  
  <pre><code>wget http://sourceforge.net/projects/mlpy/files/mlpy%203.5.0/mlpy-3.5.0.tar.gz
  tar xvf mlpy-3.5.0.tar.gz
  cd mlpy-3.5.0
  sudo python setup.py install
  </code></pre>
  
  <p>Finally to run this code, assuming the script is stored as pca.py and it is is in the same folder that the directory feature_vectors containing the partitions of the datasets resides, one must use the following command:</p>
  
  <pre><code>python pca.py inputfiletrain feature_vectors/train/featuresShape.npy outputfiletrain feature_vectors/train/featuresShapePCA.npy inputfiledev feature_vectors/development/featuresShape.npy outputfiledev feature_vectors/development/featuresShapePCA.npy 
  </code></pre>
  
  <p>I need ideas, why the PCA is that slow on this dataset...</p>