fairadapt
object.predict.fairadapt.Rd
Prediction function for new data from a saved fairadapt
object.
# S3 method for fairadapt
predict(object, newdata, ...)
Object of class fairadapt
, a result of an adaptation
procedure.
A data.frame
containing the new data.
Additional arguments forwarded to computeQuants()
.
A data.frame
containing the adapted version of the new data.
The newdata
argument should be compatible with adapt.test
argument that was used when constructing the fairadapt
object. In
particular, newdata
should contain column names that appear in the formula
argument that was used when calling fairadapt()
(apart from the outcome
variable on the LHS of the formula).
n_samp <- 200
uni_dim <- c( "gender", "edu", "test", "score")
uni_adj <- matrix(c( 0, 1, 1, 0,
0, 0, 1, 1,
0, 0, 0, 1,
0, 0, 0, 0),
ncol = length(uni_dim),
dimnames = rep(list(uni_dim), 2),
byrow = TRUE)
uni_ada <- fairadapt(score ~ .,
train.data = head(uni_admission, n = n_samp),
adj.mat = uni_adj,
prot.attr = "gender"
)
predict(object = uni_ada, newdata = tail(uni_admission, n = n_samp))
#> gender edu test score
#> 801 0 -1.76238617 -1.211890953 -2.248523253
#> 802 0 -1.54667452 -2.036196837 -2.009755697
#> 803 0 1.17079453 1.169657867 1.191612986
#> 804 0 0.32899381 -0.108360551 -0.697736661
#> 805 0 -0.91324944 -0.212029256 1.984450007
#> 806 0 -0.43044750 -1.209261161 0.789841297
#> 807 0 -0.33257370 -1.074089405 -1.474926656
#> 808 0 -0.54486482 0.812795420 0.497834190
#> 809 0 -0.82170858 -1.353303876 0.982337819
#> 810 0 -2.00405830 -1.483878994 -1.670251654
#> 811 0 -0.34616002 -0.355804722 1.872163467
#> 812 0 -0.02736564 0.029302486 1.109306522
#> 813 0 -1.05996114 -0.364127628 -0.347495108
#> 814 0 -1.39135298 -0.946489317 0.841504242
#> 815 0 -0.35158523 -1.074089405 -1.031754054
#> 816 0 -1.10801481 -2.072601121 -1.038394788
#> 817 0 -1.31742723 -2.361166481 -1.253841133
#> 818 0 -1.30440964 -0.501127666 -1.127569653
#> 819 0 -1.17713378 -2.036196837 -1.321760978
#> 820 0 -0.05057400 -0.838020739 1.062412448
#> 821 0 -1.95841401 -2.710084882 -1.627486071
#> 822 0 -0.59217601 0.124843632 0.871076451
#> 823 0 -0.05057400 -0.108360551 0.667045683
#> 824 0 -0.29205193 -0.986191276 -1.783792760
#> 825 0 0.62092416 -0.114971666 0.050424648
#> 826 0 -1.23942580 -1.124719294 -1.244894150
#> 827 0 -0.33257370 -0.550042638 0.836772353
#> 828 0 0.56604172 0.807542567 -0.318456042
#> 829 0 1.66376035 1.480402631 2.299315681
#> 830 0 -1.97792341 -3.121796235 -0.780448031
#> 831 0 -1.10801481 -2.065701959 0.143680389
#> 832 0 -0.56226223 -0.605346499 -0.197988253
#> 833 0 0.67548760 0.868880270 -0.151364462
#> 834 0 -0.86922922 -2.646687427 -1.604124109
#> 835 0 -0.25647278 -1.440056662 -1.924364325
#> 836 0 -0.01533393 -0.820665352 1.861951160
#> 837 0 -1.95841401 -1.498305031 -1.462275080
#> 838 0 0.13835955 -1.790409294 -0.520312886
#> 839 0 0.22934773 0.106404515 0.318168927
#> 840 0 0.47789525 0.229617350 -0.422195985
#> 841 0 -1.26871101 -3.497560395 -0.094699039
#> 842 0 0.84408446 -0.305803234 -0.789176231
#> 843 0 -0.34616002 -0.550042638 -1.156295463
#> 844 0 0.69287651 0.539023997 0.988820130
#> 845 0 -0.09475179 -1.184286201 -0.383527997
#> 846 0 0.85944525 -0.005874030 1.297151367
#> 847 0 -0.97207326 -0.988067362 -0.509722245
#> 848 0 1.18481357 0.223671853 0.948738536
#> 849 0 0.50948254 0.031115903 -0.960078119
#> 850 0 -0.29512467 -0.004056565 0.069640746
#> 851 0 -0.28058714 -1.968535319 -0.642857333
#> 852 0 0.24114051 0.855783424 1.190722501
#> 853 0 0.69713539 0.246193257 1.672520558
#> 854 0 -0.97207326 -2.062871523 -1.376894259
#> 855 0 2.38118232 1.173632593 1.724080192
#> 856 0 -0.71691979 0.041877886 0.169921945
#> 857 0 -0.43951451 -2.782963224 -1.776423466
#> 858 0 -1.28317836 -1.390920653 -1.176246440
#> 859 0 0.24571723 -0.046012506 1.105173350
#> 860 0 -0.34616002 -1.434405915 -0.352586641
#> 861 0 -1.39340544 -2.227771994 -1.211904179
#> 862 0 0.65075203 0.870076964 0.172484884
#> 863 0 -0.25784738 0.184278366 -0.955779822
#> 864 0 -0.03731391 -0.556922603 -1.240644748
#> 865 0 -1.30440964 -0.348295627 -0.648786856
#> 866 0 0.83634837 1.801792786 0.816701249
#> 867 0 -0.65988002 -1.844452022 -0.468480289
#> 868 0 0.23614411 0.386751900 0.929639751
#> 869 0 1.65667516 1.174964842 0.453241313
#> 870 0 -2.02208129 -1.905372715 -1.723788786
#> 871 0 0.67290529 0.032173869 -0.035326898
#> 872 0 -0.28927476 -0.187664519 0.608830823
#> 873 0 -1.16736862 -1.865114023 -2.006507850
#> 874 0 0.20041711 0.344140793 0.113582414
#> 875 0 0.25339841 -0.356605410 1.462430907
#> 876 0 0.62365725 -0.972542179 1.586366410
#> 877 0 0.14883187 -0.348295627 -0.142862516
#> 878 0 -0.34616002 -0.244458389 1.685246091
#> 879 0 -1.17713378 -1.969555323 -0.172807492
#> 880 0 -2.18346033 -2.603903781 -0.935532589
#> 881 0 -1.72570731 -2.820512900 -3.559906963
#> 882 0 -1.55736943 -2.772926068 -2.731656754
#> 883 0 -0.35158523 -0.988067362 0.094147384
#> 884 0 0.93801692 0.957786338 2.973083804
#> 885 0 0.09755748 -0.393229676 0.856685667
#> 886 0 -1.74331471 -3.082900705 -2.279216961
#> 887 0 -2.34448816 -1.435563283 -2.255204660
#> 888 0 -1.97792341 -1.215501088 -1.624173997
#> 889 0 0.09756858 -1.156573500 0.095045586
#> 890 0 -3.06924223 -3.712797683 -4.430320178
#> 891 0 -0.56226223 -1.434405915 -1.282782046
#> 892 0 -0.73019707 -1.924209626 -0.867176978
#> 893 0 -0.10388291 -0.546331814 -1.116750069
#> 894 0 0.49814080 -0.395424735 -0.443540996
#> 895 0 0.51326062 0.674104083 0.954496259
#> 896 0 -0.16144575 -0.921971083 0.533034913
#> 897 0 0.82437660 0.838675786 2.434167705
#> 898 0 -0.56226223 0.107841476 1.738022171
#> 899 0 -0.40482500 -1.373614666 -2.522900649
#> 900 0 0.56256519 -0.624238187 -1.421399698
#> 901 0 0.79330411 2.024935105 0.876393816
#> 902 0 -2.00897346 -2.065701959 -3.336136856
#> 903 0 -1.00518193 -1.465181188 -1.620118314
#> 904 0 -1.76335258 -2.361166481 -1.298079833
#> 905 0 -1.31446601 -2.279801899 -0.194242511
#> 906 0 -0.40482500 -0.839388153 -0.539844056
#> 907 0 0.24571723 0.311425161 1.540468960
#> 908 0 -0.28997746 -2.038117414 0.377569531
#> 909 0 -1.30440964 -1.955211876 -0.518650912
#> 910 0 0.09756858 -1.074089405 -1.067862289
#> 911 0 -1.31609328 -1.754439190 -3.002032488
#> 912 0 -0.42331443 -1.375426561 -1.039456538
#> 913 0 0.48957851 -1.241887015 0.657435765
#> 914 0 -1.17713378 -1.434405915 -0.951787515
#> 915 0 -0.11869670 -1.566638938 -1.001299575
#> 916 0 -0.36228730 -1.498664881 -1.546853316
#> 917 0 -0.27417137 0.389377080 0.952588498
#> 918 0 -1.33156889 -1.559090289 -1.853927038
#> 919 0 -0.71706309 -1.275608741 -1.474532010
#> 920 0 -1.95841401 -2.276587625 -0.917686286
#> 921 0 -0.82017753 -1.582146965 -2.008219189
#> 922 0 -1.85499582 -2.496803403 -1.438337544
#> 923 0 -0.28840191 -0.756921041 -0.692028282
#> 924 0 -0.68699393 -1.480622677 -0.837267282
#> 925 0 -1.73656768 -2.390473070 -1.981547684
#> 926 0 0.24571723 -0.005874030 1.517489869
#> 927 0 -0.56027783 0.029302486 0.631959853
#> 928 0 -0.28840191 0.107841476 0.945444557
#> 929 0 -0.50719514 -1.840148830 -1.432336509
#> 930 0 -0.56226223 -1.124719294 1.250912889
#> 931 0 -2.92749251 -2.892119311 -2.289800236
#> 932 0 0.42719647 0.433596689 0.899829891
#> 933 0 -1.61068178 -1.443623594 -1.207835484
#> 934 0 -0.88440664 -0.440364450 0.465921575
#> 935 0 -0.63826637 -0.975313128 -0.280759713
#> 936 0 0.86814650 1.571927196 1.664871387
#> 937 0 -1.52454974 -0.370525777 -0.948986281
#> 938 0 0.93801692 -0.151819126 1.682221972
#> 939 0 -2.45535470 -3.121796235 -2.162776061
#> 940 0 -0.28997746 -0.355804722 0.587418523
#> 941 0 -1.33156889 -0.693222303 0.356856675
#> 942 0 0.06527531 -0.658202059 -0.317153475
#> 943 0 -1.54667452 -2.023746740 -1.481437987
#> 944 0 -0.56027783 -0.348295627 -1.990669444
#> 945 0 0.95781033 0.915731389 2.498366165
#> 946 0 0.28057936 -0.264326178 0.324320914
#> 947 0 1.80669879 1.084950383 0.895222646
#> 948 0 1.14755867 1.180202946 1.802367455
#> 949 0 0.59581414 1.926888054 0.364802173
#> 950 0 0.01456239 -0.342731345 0.381268872
#> 951 0 -0.67249027 -1.095405615 0.569697590
#> 952 0 -0.10045302 -0.818827187 -0.549087261
#> 953 0 -0.31126552 -0.682830213 0.166889733
#> 954 0 -1.30440964 -1.093176616 -0.911256296
#> 955 0 0.27966699 -0.244458389 0.213121286
#> 956 0 0.66508909 0.568883700 0.150221197
#> 957 0 -1.59801626 -2.266070448 -2.750619416
#> 958 0 -1.39088095 -1.755829534 -1.691135270
#> 959 0 0.24308580 -0.227891531 -1.326310399
#> 960 0 -0.60047991 0.288362252 -0.759343490
#> 961 0 -0.38061202 -1.420420046 -1.300735252
#> 962 0 0.47459251 0.036977119 0.829957649
#> 963 0 1.01232003 0.544826681 0.149567854
#> 964 0 -1.43119017 -1.093176616 -0.470509409
#> 965 0 -0.59816428 -0.962079122 -1.205855074
#> 966 0 -1.33156889 -1.498305031 0.617005511
#> 967 0 -0.83459906 -1.340114903 -1.219394858
#> 968 0 -1.30440964 -0.629011687 0.091312402
#> 969 0 -0.46492562 0.258910409 0.118477910
#> 970 0 -0.46355298 -0.549713195 -0.321729818
#> 971 0 -0.16144575 -1.515208888 1.218577031
#> 972 0 -1.00678886 -1.272298519 0.333778613
#> 973 0 -0.20732525 -0.790899405 -0.164120438
#> 974 0 -0.19867168 -1.424801374 -0.515737721
#> 975 0 -1.31742723 -0.968668154 -0.585724370
#> 976 0 -1.39135298 -2.105238961 -0.554345955
#> 977 0 -1.10801481 -2.504233176 -1.142323022
#> 978 0 -0.30265223 -0.403718017 -0.025212237
#> 979 0 -1.33156889 -1.481990330 -1.182021588
#> 980 0 -0.91324944 -1.559090289 -0.504013446
#> 981 0 0.95369779 0.506355585 0.524688786
#> 982 0 -0.93067447 -2.383798643 -3.030736973
#> 983 0 1.14904187 -0.124322538 -0.214029243
#> 984 0 -0.63826637 -0.244458389 0.531710091
#> 985 0 -2.00897346 -2.065701959 -2.195556550
#> 986 0 -0.88212247 -1.168627410 -0.231555284
#> 987 0 -0.02736564 0.243248892 2.017461669
#> 988 0 -0.63795435 -1.156573500 1.075378490
#> 989 0 -0.68699393 -0.550042638 1.104165903
#> 990 0 -0.28840191 -0.390671052 1.739168447
#> 991 0 0.46017993 -0.490180198 0.100981820
#> 992 0 0.21354142 -1.815610955 -2.239312858
#> 993 0 -1.57435407 -1.072093592 -1.288697389
#> 994 0 -0.56226223 -1.093176616 2.041889298
#> 995 0 -1.23878050 -2.409644152 -3.071024177
#> 996 0 0.11159425 0.682887893 -2.155281612
#> 997 0 -0.05483850 -0.244458389 -0.789234909
#> 998 0 -1.22256601 -0.814845191 0.049963241
#> 999 0 -1.54667452 -1.215501088 -0.360933334
#> 1000 0 -0.86701806 -1.689133889 -0.004731789