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

Method _get_model_parameter_table

pyfair/report/base_report.py:290–348  ·  view source on GitHub ↗

Generate a table with parameter statistics and icons

(self, model)

Source from the content-addressed store, hash-verified

288 return overview_html
289
290 def _get_model_parameter_table(self, model):
291 """Generate a table with parameter statistics and icons"""
292 params = dict(**model.export_params())
293 # Remove items we don't want.
294 params = {
295 key: value
296 for key, value
297 in params.items()
298 if key in self._format_strings.keys()
299 }
300 # Set up alias and dataframe
301 fs = self._format_strings
302 param_df = pd.DataFrame(params).T
303 # For possible param column name
304 for column in self._param_cols:
305 # If the column is not present in param_df
306 if column not in param_df.columns:
307 # Add that column in with null data
308 param_df[column] = np.NaN
309 # Create descriptive statistics from parameter df
310 param_df = param_df[self._param_cols]
311 param_df['mean'] = model.export_results().mean(axis=0)
312 param_df['stdev'] = model.export_results().std(axis=0)
313 param_df['min'] = model.export_results().min(axis=0)
314 param_df['max'] = model.export_results().max(axis=0)
315 # Transform param_df in place
316 param_df = param_df.apply(
317 lambda row: pd.Series(
318 [
319 # ... by getting the format string and formatting
320 fs[row.name].format(item)
321 # For each item
322 for item
323 in row
324 ],
325 # And keep the index
326 index=row.index.values
327 ),
328 # On a column basis
329 axis=1,
330 )
331 param_df = param_df.applymap(lambda x: '' if 'nan' in x else x)
332 # Do not truncate our base64 images.
333 pd.set_option('display.max_colwidth', -1)
334 # Create our distribution icons as strings in table
335 param_df['distribution'] = [
336 self._get_distribution_icon(model, target)
337 for target
338 in param_df.index.values
339 ]
340 # Export table to html
341 detail_table = param_df.to_html(
342 border=0,
343 header=True,
344 justify='left',
345 classes='fair_table',
346 escape=False
347 )

Callers 2

_construct_outputMethod · 0.80

Calls 4

to_htmlMethod · 0.80
export_paramsMethod · 0.45
export_resultsMethod · 0.45

Tested by 1