class_docstr: Helper for dimensionality reduction to the innermost dimension of a tensor.
  
  This class wraps sklearn.decomposition classes to help them apply to arbitrary
  rank tensors. It saves lots of annoying reshaping.
  
  See the original sklearn.decomposition documentation:
  http://scikit-learn.org/stable/modules/classes.html#module-sklearn.decomposition
class_docstr_tok: ["Helper","for","dimensionality","reduction","to","the","innermost","dimension","of","a","tensor",".","This","class","wraps","sklearn.decomposition","classes","to","help","them","apply","to","arbitrary","rank","tensors",".","It","saves","lots","of","annoying","reshaping",".","See","the","original","sklearn.decomposition","documentation",":","http",":","\/\/scikit-learn.org\/stable\/modules\/classes.html","#","module-sklearn.decomposition"]
docstr: Constructor for ChannelReducer.
  
  Inputs:
    n_components: Numer of dimensions to reduce inner most dimension to.
    reduction_alg: A string or sklearn.decomposition class. Defaults to
      "NMF" (non-negative matrix factorization). Other options include:
      "PCA", "FastICA", and "MiniBatchDictionaryLearning". The name of any of
      the sklearn.decomposition classes will work, though.
    kwargs: Additional kwargs to be passed on to the reducer.
docstr_tok: ["Constructor","for","ChannelReducer",".","Inputs",":","n_components",":","Numer","of","dimensions","to","reduce","inner","most","dimension","to",".","reduction_alg",":","A","string","or","sklearn.decomposition","class",".","Defaults","to","``","NMF","''","(","non-negative","matrix","factorization",")",".","Other","options","include",":","``","PCA","''",",","``","FastICA","''",",","and","``","MiniBatchDictionaryLearning","''",".","The","name","of","any","of","the","sklearn.decomposition","classes","will","work",",","though",".","kwargs",":","Additional","kwargs","to","be","passed","on","to","the","reducer","."]
code: def __init__(self, n_components=3, reduction_alg="NMF", **kwargs):
      """Constructor for ChannelReducer.
  
      Inputs:
        n_components: Numer of dimensions to reduce inner most dimension to.
        reduction_alg: A string or sklearn.decomposition class. Defaults to
          "NMF" (non-negative matrix factorization). Other options include:
          "PCA", "FastICA", and "MiniBatchDictionaryLearning". The name of any of
          the sklearn.decomposition classes will work, though.
        kwargs: Additional kwargs to be passed on to the reducer.
      """
  
      if not isinstance(n_components, int):
          raise ValueError(
              "n_components must be an int, not '%s'." % n_components
          )
  
      # Defensively look up reduction_alg if it is a string and give useful errors.
      algorithm_map = {}
      for name in dir(sklearn.decomposition):
          obj = sklearn.decomposition.__getattribute__(name)
          if isinstance(obj, type) and issubclass(obj, BaseEstimator):
              algorithm_map[name] = obj
      if isinstance(reduction_alg, str):
          if reduction_alg in algorithm_map:
              reduction_alg = algorithm_map[reduction_alg]
          else:
              raise ValueError(
                  "Unknown dimensionality reduction method '%s'."
                  % reduction_alg
              )
  
      self.n_components = n_components
      self._reducer = reduction_alg(n_components=n_components, **kwargs)
      self._is_fit = False
  
file_path: lucid/lucid/misc/channel_reducer.py
imports: import numpy
  import sklearn.decomposition
label_desc: Use image node_id 1 to create a new ChannelReducer object from inherited base classes: object with example: obj = ChannelReducer(n_components, reduction_alg)