MCPcopy Create free account
hub / github.com/Derive-Risk/pyfair / supply_raw

Method supply_raw

pyfair/model/model_input.py:267–306  ·  view source on GitHub ↗

Supply raw data to the model This takes an arbitrary array, runs some quick checks, and returns the array if appropriate. Parameters ---------- target : str The eventual target of the raw data array : list, pd.Series, or array

(self, target, array)

Source from the content-addressed store, hash-verified

265 return summed
266
267 def supply_raw(self, target, array):
268 """Supply raw data to the model
269
270 This takes an arbitrary array, runs some quick checks, and returns
271 the array if appropriate.
272
273 Parameters
274 ----------
275 target : str
276 The eventual target of the raw data
277 array : list, pd.Series, or array
278 The raw data being supplied
279
280 Returns
281 =======
282 np.array
283 The data for the model
284
285 Raises
286 ------
287 pyfair.utility.fair_exception.FairException
288 Raised if the data has null values
289
290 """
291 # Ensure numeric
292 clean_array = pd.to_numeric(array)
293 # Coerce to series
294 if type(array) == pd.Series:
295 s = pd.Series(clean_array.values)
296 else:
297 s = pd.Series(clean_array)
298 # Check numeric and not null
299 if s.isnull().any():
300 raise FairException('Supplied data contains null values')
301 # Ensure values are appropriate
302 if target in self._le_1_targets:
303 if s.max() > 1 or s.min() < 0:
304 raise FairException(f'{target} data greater or less than one')
305 self._supplied_values[target] = {'raw': s.values.tolist()}
306 return s.values
307
308 def _determine_func(self, **kwargs):
309 """Checks keywords and returns the appropriate function object."""

Callers 1

input_raw_dataMethod · 0.80

Calls 1

FairExceptionClass · 0.85

Tested by

no test coverage detected