Skip to content

Commit 4d49967

Browse files
committed
update preprocess function to accommodate single row scoring
1 parent 2a8d6aa commit 4d49967

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

examples/pzmm_generate_complete_model_card.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,11 @@
567567
" df = pd.get_dummies(df, columns=[\"WorkClass\", \"Education\", \"MartialStatus\", \"Relationship\", \"Race\", \"Sex\"])\n",
568568
" df.columns = df.columns.str.replace(' ', '')\n",
569569
" df.columns = df.columns.str.replace('-', '_')\n",
570-
" df = df.drop(['Sex_Male'], axis=1)\n",
570+
" # Ensure that Sex_Female column exists and Sex_Male column is dropped if it exists\n",
571+
" if 'Sex_Female' not in df.columns:\n",
572+
" df['Sex_Female'] = 0\n",
573+
" if 'Sex_Male' in df.columns:\n",
574+
" df = df.drop(['Sex_Male'], axis=1)\n",
571575
" if 'index' in df.columns or 'index' in cat_vals.columns:\n",
572576
" df = pd.concat([df, cat_vals], axis=1).drop('index', axis=1)\n",
573577
" # For the model to score correctly, all OHE columns must exist\n",

0 commit comments

Comments
 (0)