Commit 6cb8a56
Raw-covariate adjustment for custom models (#323)
Summary:
Pull Request resolved: #323
`Sample.adjust()` now supports fitting models on raw covariates (without a model matrix) for IPW via `use_model_matrix=False`. Categorical columns are encoded as integer codes (ordinal encoding). NaN values in categorical columns are assigned a distinct code (one higher than the maximum) rather than being mapped to `-1`.
Note that ordinal encoding treats categories as ordered numeric values; for true unordered categorical support, use sklearn 1.4+ with `HistGradientBoostingClassifier` and `categorical_features="from_dtype"`.
Pull Request resolved: #321
Reviewed By: omriharosh
Differential Revision: D92627587
Pulled By: talgalili
fbshipit-source-id: 94d3b7d9e33bdd0b384dd18019e1ef653945d17f1 parent d54dcc0 commit 6cb8a56
File tree
8 files changed
+557
-98
lines changed- .github/workflows
- balance
- utils
- weighting_methods
- tests
- tutorials
8 files changed
+557
-98
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 5 | | |
11 | 6 | | |
12 | 7 | | |
13 | 8 | | |
14 | 9 | | |
15 | 10 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | 11 | | |
20 | 12 | | |
21 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
22 | 31 | | |
23 | 32 | | |
24 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
517 | 516 | | |
518 | 517 | | |
519 | 518 | | |
| |||
940 | 939 | | |
941 | 940 | | |
942 | 941 | | |
943 | | - | |
| 942 | + | |
944 | 943 | | |
945 | 944 | | |
946 | 945 | | |
947 | 946 | | |
948 | 947 | | |
949 | 948 | | |
| 949 | + | |
| 950 | + | |
950 | 951 | | |
951 | | - | |
| 952 | + | |
952 | 953 | | |
953 | 954 | | |
954 | 955 | | |
955 | 956 | | |
956 | 957 | | |
957 | | - | |
958 | | - | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
959 | 965 | | |
960 | | - | |
| 966 | + | |
961 | 967 | | |
962 | 968 | | |
963 | 969 | | |
964 | | - | |
965 | | - | |
| 970 | + | |
| 971 | + | |
966 | 972 | | |
967 | | - | |
| 973 | + | |
968 | 974 | | |
969 | 975 | | |
970 | 976 | | |
| |||
977 | 983 | | |
978 | 984 | | |
979 | 985 | | |
980 | | - | |
| 986 | + | |
981 | 987 | | |
982 | | - | |
983 | | - | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
990 | 996 | | |
991 | 997 | | |
992 | 998 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
94 | 117 | | |
95 | 118 | | |
96 | 119 | | |
| |||
0 commit comments