[text] aoeuaoeu

Viewer

copydownloadembedprintName: aoeuaoeu
  1. def get_named_version(data):
  2.     named_columns = ['age', 'workclass', 'fnlwgt', 'education', 'education-num',
  3.        'marital-status', 'occupation', 'relationship', 'race', 'sex',
  4.        'capital-gain', 'capital-loss', 'hours-per-week', 'native-country',
  5.        'income']
  6.  
  7.     data_named = copy.deepcopy(data)
  8.     data_named.columns = named_columns
  9.  
  10.     return data_named
  11.  
  12. def eval_harness(real, synthetic, private_synthetic, random):
  13.  
  14.     real, synthetic, private_synthetic, random = [get_named_version(d) for d in [real, synthetic, private_synthetic, random]]
  15.     
  16.     def eval_single(real, synthetic, name='non-private'):
  17.         print('#' * 10 + f' {name} ' + '#' * 10)
  18.         print('chi-square =', CSTest.compute(real, synthetic), 'komolgorov-smirnov =', KSTest.compute(real, synthetic))
  19.         print('train syn test real =', MulticlassDecisionTreeClassifier.compute(real, synthetic, target='income'))
  20.  
  21.         train = real.sample(int(len(real) * 0.75))
  22.         test = real[~real.index.isin(train.index)]
  23.         MulticlassDecisionTreeClassifier.compute(test, train, target='income')
  24.         print('train real test real =', MulticlassDecisionTreeClassifier.compute(synthetic, synthetic, target='income'))
  25.         print('1 - ROCAUC =', LogisticDetection.compute(real, synthetic))
  26.  
  27.         print()
  28.  
  29.     eval_single(real, random, name='random')
  30.     eval_single(real, synthetic, name='non-private')
  31.     eval_single(real, private_synthetic, name='private')
  32.     
  33.     
  34. eval_harness(data, synthetic_df, private_synthetic_df, random_df)

Editor

You can edit this paste and save as new:


File Description
  • aoeuaoeu
  • Paste Code
  • 30 Jun-2022
  • 1.53 Kb
You can Share it: