class_docstr: Correlation-based classification component of FCMA
  
  The classifier first computes correlation of the input data,
  and normalizes them if needed, then uses the given classifier
  to train and/or predict the correlation data.
  NOTE: if the classifier is sklearn.svm.SVC with precomputed kernel,
  the test data may be provided in the fit method to compute
  the kernel matrix together with the training data to save the memory usage,
  but the test data will NEVER be seen in the model training.
  
  Parameters
  ----------
  
  clf: class
      The classifier used, normally a classifier class of sklearn
  
  num_processed_voxels: int, default 2000
      Used for SVM with precomputed kernel,
      every time it only computes correlation between num_process_voxels and
      the whole mask to aggregate the kernel matrices.
      This is to save the memory
      so as to handle correlations at a larger scale.
  
  epochs_per_subj: int, default 0
      The number of epochs of each subject
      within-subject normalization will be performed during
      classifier training if epochs_per_subj is specified
      default 0 means no within-subject normalization
  
  
  Attributes
  ----------
  
  training_data_: 2D numpy array in shape [num_samples, num_features]
      training_data\_ is None except clf is SVM.SVC with precomputed kernel,
      in which case training data is needed to compute
      the similarity vector for each sample to be classified.
      However, if the test samples are also provided during the fit,
      the similarity vectors can be precomputed too
      and then training_data\_ is None
  
  test_raw_data_: a list of 2D array in shape [num_TRs, num_voxels]
      default None
      test_raw_data\_ is set after a prediction is called,
      if the new input data equals test_raw_data\_,
      test_data\_ can be reused
  
  test_data_: 2D numpy array in shape [num_samples, num_features]
      default None
      test_data\_ is set after a prediction is called,
      so that the test data does not need to be regenerated in the
      subsequent operations, e.g. getting decision values of the prediction.
      test_data\_ may also be set in the fit method
      if sklearn.svm.SVC with precomputed kernel
      and the test samples are known.
      NOTE: the test samples will never be used to fit the model.
  
  num_voxels_: int
      The number of voxels of the first brain region used in the classifier.
      The first brain region is always large. When training, this region may
      be divided to compute the correlation portion by portion.
      The brain regions are defined by the applied mask, e.g. the top voxels
      selected by FCMA voxel selection
  
  num_features_: int
      The dimension of correlation data, normally is the product of
      the number of voxels of brain region 1 and
      the number of voxels of brain region 2.
      num_features\_ must be consistent in both training and classification
  
  num_samples_: int
      The number of samples
  
  num_digits_: int
      The number of digits of the first value of the kernel matrix,
      for normalizing the kernel values accordingly
class_docstr_tok: ["Correlation-based","classification","component","of","FCMA","The","classifier","first","computes","correlation","of","the","input","data",",","and","normalizes","them","if","needed",",","then","uses","the","given","classifier","to","train","and\/or","predict","the","correlation","data",".","NOTE",":","if","the","classifier","is","sklearn.svm.SVC","with","precomputed","kernel",",","the","test","data","may","be","provided","in","the","fit","method","to","compute","the","kernel","matrix","together","with","the","training","data","to","save","the","memory","usage",",","but","the","test","data","will","NEVER","be","seen","in","the","model","training",".","Parameters","--","--","--","--","--","clf",":","class","The","classifier","used",",","normally","a","classifier","class","of","sklearn","num_processed_voxels",":","int",",","default","2000","Used","for","SVM","with","precomputed","kernel",",","every","time","it","only","computes","correlation","between","num_process_voxels","and","the","whole","mask","to","aggregate","the","kernel","matrices",".","This","is","to","save","the","memory","so","as","to","handle","correlations","at","a","larger","scale",".","epochs_per_subj",":","int",",","default","0","The","number","of","epochs","of","each","subject","within-subject","normalization","will","be","performed","during","classifier","training","if","epochs_per_subj","is","specified","default","0","means","no","within-subject","normalization","Attributes","--","--","--","--","--","training_data_",":","2D","numpy","array","in","shape","[","num_samples",",","num_features","]","training_data\\_","is","None","except","clf","is","SVM.SVC","with","precomputed","kernel",",","in","which","case","training","data","is","needed","to","compute","the","similarity","vector","for","each","sample","to","be","classified",".","However",",","if","the","test","samples","are","also","provided","during","the","fit",",","the","similarity","vectors","can","be","precomputed","too","and","then","training_data\\_","is","None","test_raw_data_",":","a","list","of","2D","array","in","shape","[","num_TRs",",","num_voxels","]","default","None","test_raw_data\\_","is","set","after","a","prediction","is","called",",","if","the","new","input","data","equals","test_raw_data\\_",",","test_data\\_","can","be","reused","test_data_",":","2D","numpy","array","in","shape","[","num_samples",",","num_features","]","default","None","test_data\\_","is","set","after","a","prediction","is","called",",","so","that","the","test","data","does","not","need","to","be","regenerated","in","the","subsequent","operations",",","e.g",".","getting","decision","values","of","the","prediction",".","test_data\\_","may","also","be","set","in","the","fit","method","if","sklearn.svm.SVC","with","precomputed","kernel","and","the","test","samples","are","known",".","NOTE",":","the","test","samples","will","never","be","used","to","fit","the","model",".","num_voxels_",":","int","The","number","of","voxels","of","the","first","brain","region","used","in","the","classifier",".","The","first","brain","region","is","always","large",".","When","training",",","this","region","may","be","divided","to","compute","the","correlation","portion","by","portion",".","The","brain","regions","are","defined","by","the","applied","mask",",","e.g",".","the","top","voxels","selected","by","FCMA","voxel","selection","num_features_",":","int","The","dimension","of","correlation","data",",","normally","is","the","product","of","the","number","of","voxels","of","brain","region","1","and","the","number","of","voxels","of","brain","region","2.","num_features\\_","must","be","consistent","in","both","training","and","classification","num_samples_",":","int","The","number","of","samples","num_digits_",":","int","The","number","of","digits","of","the","first","value","of","the","kernel","matrix",",","for","normalizing","the","kernel","values","accordingly"]
docstr: Use a trained model to predict correlation data.
  
  first compute the correlation of the input data,
  and then normalize across all samples in the list
  if there are more than one sample,
  and then predict via self.clf.
  If X is None, use the similarity vectors produced in fit
  to predict
  
  Parameters
  ----------
  X: Optional[list of tuple (data1, data2)]
      data1 and data2 are numpy array in shape [num_TRs, num_voxels]
      to be computed for correlation.
      default None, meaning that the data to be predicted
      have been processed in the fit method.
      Otherwise, X contains the activity data filtered by ROIs
      and prepared for correlation computation.
      len(X) is the number of test samples.
      if len(X) > 1: normalization is done on all test samples.
      Within list, all data1s must have the same num_voxels value,
      all data2s must have the same num_voxels value.
  
  Returns
  -------
  y_pred: the predicted label of X, in shape [len(X),]
docstr_tok: ["Use","a","trained","model","to","predict","correlation","data",".","first","compute","the","correlation","of","the","input","data",",","and","then","normalize","across","all","samples","in","the","list","if","there","are","more","than","one","sample",",","and","then","predict","via","self.clf",".","If","X","is","None",",","use","the","similarity","vectors","produced","in","fit","to","predict","Parameters","--","--","--","--","--","X",":","Optional","[","list","of","tuple","(","data1",",","data2",")","]","data1","and","data2","are","numpy","array","in","shape","[","num_TRs",",","num_voxels","]","to","be","computed","for","correlation",".","default","None",",","meaning","that","the","data","to","be","predicted","have","been","processed","in","the","fit","method",".","Otherwise",",","X","contains","the","activity","data","filtered","by","ROIs","and","prepared","for","correlation","computation",".","len","(","X",")","is","the","number","of","test","samples",".","if","len","(","X",")",">","1",":","normalization","is","done","on","all","test","samples",".","Within","list",",","all","data1s","must","have","the","same","num_voxels","value",",","all","data2s","must","have","the","same","num_voxels","value",".","Returns","--","--","--","-","y_pred",":","the","predicted","label","of","X",",","in","shape","[","len","(","X",")",",","]"]
code: def predict(self, X=None):
      """Use a trained model to predict correlation data.
  
      first compute the correlation of the input data,
      and then normalize across all samples in the list
      if there are more than one sample,
      and then predict via self.clf.
      If X is None, use the similarity vectors produced in fit
      to predict
  
      Parameters
      ----------
      X: Optional[list of tuple (data1, data2)]
          data1 and data2 are numpy array in shape [num_TRs, num_voxels]
          to be computed for correlation.
          default None, meaning that the data to be predicted
          have been processed in the fit method.
          Otherwise, X contains the activity data filtered by ROIs
          and prepared for correlation computation.
          len(X) is the number of test samples.
          if len(X) > 1: normalization is done on all test samples.
          Within list, all data1s must have the same num_voxels value,
          all data2s must have the same num_voxels value.
  
      Returns
      -------
      y_pred: the predicted label of X, in shape [len(X),]
      """
      time1 = time.time()
      if X is not None:
          for x in X:
              assert (
                  len(x) == 2
              ), "there must be two parts for each correlation computation"
          X1, X2 = zip(*X)
          num_voxels1 = X1[0].shape[1]
          num_voxels2 = X2[0].shape[1]
          # make sure X1 always has more voxels
          if num_voxels1 < num_voxels2:
              X1, X2 = X2, X1
              num_voxels1, num_voxels2 = num_voxels2, num_voxels1
          assert (
              self.num_features_ == num_voxels1 * num_voxels2
          ), "the number of features does not match the model"
          num_test_samples = len(X1)
          self.test_raw_data_ = X
  
          # correlation computation
          corr_data = self._prepare_corerelation_data(X1, X2)
          # normalization
          normalized_corr_data = self._normalize_correlation_data(
              corr_data, num_test_samples
          )
          # test data generation
          self.test_data_ = self._prepare_test_data(
              normalized_corr_data
          )
      # prediction
      y_pred = self.clf.predict(self.test_data_)
      time2 = time.time()
      logger.info("prediction done, takes %.2f s" % (time2 - time1))
      return y_pred
  
file_path: brainiak/brainiak/fcma/classifier.py
imports: import numpy
  import time
  from sklearn.base import BaseEstimator
  import sklearn
  from .None import fcma_extension
  from .None import cython_blas
  import logging
label_desc: Use image node_id 8 for calling the Classifier obj's underlying member method code with example usage: obj.predict(X) and returns: y_pred