parameters: (dataDir)
return_statement: return dataDimension + 1, numClasses, Xtrain, Ytrain, Xtest, Ytest, mean, std
docstring: Function to pre-process input data
      Expects a .npy file of form [lbl feats] for each datapoint
      Outputs a train and test set datapoints appended with 1 for Bias induction
      dataDimension, numClasses are inferred directly
docstring_summary: Function to pre-process input data
      Expects a .npy file of form [lbl feats] for each datapoint
      Outputs a train and test set datapoints appended with 1 for Bias induction
      dataDimension, numClasses are inferred directly
docstring_tokens: Function to pre - process input data Expects a . npy file of form [ lbl feats ] for each datapoint Outputs a train and test set datapoints appended with 1 for Bias induction dataDimension numClasses are inferred directly
function: def preProcessData(dataDir):
      '''
      Function to pre-process input data
      Expects a .npy file of form [lbl feats] for each datapoint
      Outputs a train and test set datapoints appended with 1 for Bias induction
      dataDimension, numClasses are inferred directly
      '''
      train = np.load(dataDir + '/train.npy')
      test = np.load(dataDir + '/test.npy')
  
      dataDimension = int(train.shape[1]) - 1
  
      Xtrain = train[:, 1:dataDimension + 1]
      Ytrain_ = train[:, 0]
  
      Xtest = test[:, 1:dataDimension + 1]
      Ytest_ = test[:, 0]
  
      # Mean Var Normalisation
      mean = np.mean(Xtrain, 0)
      std = np.std(Xtrain, 0)
      std[std[:] < 0.000001] = 1
      Xtrain = (Xtrain - mean) / std
      Xtest = (Xtest - mean) / std
      # End Mean Var normalisation
  
      # Classification.
  
      numClasses = max(Ytrain_) - min(Ytrain_) + 1
      numClasses = int(max(numClasses, max(Ytest_) - min(Ytest_) + 1))
  
      lab = Ytrain_.astype('uint8')
      lab = np.array(lab) - min(lab)
  
      lab_ = np.zeros((Xtrain.shape[0], numClasses))
      lab_[np.arange(Xtrain.shape[0]), lab] = 1
      if (numClasses == 2):
          Ytrain = np.reshape(lab, [-1, 1])
      else:
          Ytrain = lab_
  
      lab = Ytest_.astype('uint8')
      lab = np.array(lab) - min(lab)
  
      lab_ = np.zeros((Xtest.shape[0], numClasses))
      lab_[np.arange(Xtest.shape[0]), lab] = 1
      if (numClasses == 2):
          Ytest = np.reshape(lab, [-1, 1])
      else:
          Ytest = lab_
  
      trainBias = np.ones([Xtrain.shape[0], 1])
      Xtrain = np.append(Xtrain, trainBias, axis=1)
      testBias = np.ones([Xtest.shape[0], 1])
      Xtest = np.append(Xtest, testBias, axis=1)
  
      mean = np.append(mean, np.array([0]))
      std = np.append(std, np.array([1]))
  
      return dataDimension + 1, numClasses, Xtrain, Ytrain, Xtest, Ytest, mean, std
function_tokens: def preProcessData ( dataDir ) : train = np . load ( dataDir + '/train.npy' ) test = np . load ( dataDir + '/test.npy' ) dataDimension = int ( train . shape [ 1 ] ) - 1 Xtrain = train [ : , 1 : dataDimension + 1 ] Ytrain_ = train [ : , 0 ] Xtest = test [ : , 1 : dataDimension + 1 ] Ytest_ = test [ : , 0 ] # Mean Var Normalisation mean = np . mean ( Xtrain , 0 ) std = np . std ( Xtrain , 0 ) std [ std [ : ] < 0.000001 ] = 1 Xtrain = ( Xtrain - mean ) / std Xtest = ( Xtest - mean ) / std # End Mean Var normalisation # Classification. numClasses = max ( Ytrain_ ) - min ( Ytrain_ ) + 1 numClasses = int ( max ( numClasses , max ( Ytest_ ) - min ( Ytest_ ) + 1 ) ) lab = Ytrain_ . astype ( 'uint8' ) lab = np . array ( lab ) - min ( lab ) lab_ = np . zeros ( ( Xtrain . shape [ 0 ] , numClasses ) ) lab_ [ np . arange ( Xtrain . shape [ 0 ] ) , lab ] = 1 if ( numClasses == 2 ) : Ytrain = np . reshape ( lab , [ - 1 , 1 ] ) else : Ytrain = lab_ lab = Ytest_ . astype ( 'uint8' ) lab = np . array ( lab ) - min ( lab ) lab_ = np . zeros ( ( Xtest . shape [ 0 ] , numClasses ) ) lab_ [ np . arange ( Xtest . shape [ 0 ] ) , lab ] = 1 if ( numClasses == 2 ) : Ytest = np . reshape ( lab , [ - 1 , 1 ] ) else : Ytest = lab_ trainBias = np . ones ( [ Xtrain . shape [ 0 ] , 1 ] ) Xtrain = np . append ( Xtrain , trainBias , axis = 1 ) testBias = np . ones ( [ Xtest . shape [ 0 ] , 1 ] ) Xtest = np . append ( Xtest , testBias , axis = 1 ) mean = np . append ( mean , np . array ( [ 0 ] ) ) std = np . append ( std , np . array ( [ 1 ] ) ) return dataDimension + 1 , numClasses , Xtrain , Ytrain , Xtest , Ytest , mean , std