MCPcopy
hub / github.com/ContextLab/hypertools / transform

Method transform

hypertools/datageometry.py:111–143  ·  view source on GitHub ↗

Return transformed data, or transform new data using the same model parameters Parameters ---------- data : numpy array, pandas dataframe or list of arrays/dfs The data to transform. If no data is passed, the xform_data from the Data

(self, data=None)

Source from the content-addressed store, hash-verified

109
110 # a function to transform new data
111 def transform(self, data=None):
112 """
113 Return transformed data, or transform new data using the same model
114 parameters
115
116 Parameters
117 ----------
118 data : numpy array, pandas dataframe or list of arrays/dfs
119 The data to transform. If no data is passed, the xform_data from
120 the DataGeometry object will be returned.
121
122 Returns
123 ----------
124 xformed_data : list of numpy arrays
125 The transformed data
126
127 """
128 # if no new data passed,
129 if data is None:
130 return self.xform_data
131 else:
132 formatted = format_data(
133 data,
134 semantic=self.semantic,
135 vectorizer=self.vectorizer,
136 corpus=self.corpus,
137 ppca=True)
138 norm = normalizer(formatted, normalize=self.normalize)
139 reduction = reducer(
140 norm,
141 reduce=self.reduce,
142 ndims=self.reduce['params']['n_components'])
143 return aligner(reduction, align=self.align)
144
145 # a function to plot the data
146 def plot(self, data=None, **kwargs):

Callers

nothing calls this directly

Calls 1

format_dataFunction · 0.90

Tested by

no test coverage detected