Skip to content

Commit 2c83956

Browse files
committed
fixes notebook
1 parent f2b759f commit 2c83956

File tree

2 files changed

+49
-33
lines changed

2 files changed

+49
-33
lines changed

notebooks/CART_LawSchoolAdmissionBar.ipynb

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,13 @@
510510
"name": "stderr",
511511
"output_type": "stream",
512512
"text": [
513-
"/var/folders/v8/64zc34sn3b95klfm660085h80000gn/T/ipykernel_74614/158703987.py:5: SettingWithCopyWarning: \n",
513+
"C:\\Users\\maike\\AppData\\Local\\Temp\\ipykernel_33120\\158703987.py:5: SettingWithCopyWarning: \n",
514514
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
515515
"Try using .loc[row_indexer,col_indexer] = value instead\n",
516516
"\n",
517517
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
518518
" real_data[column] = label_encoders[column].fit_transform(real_data[column])\n",
519-
"/var/folders/v8/64zc34sn3b95klfm660085h80000gn/T/ipykernel_74614/158703987.py:5: SettingWithCopyWarning: \n",
519+
"C:\\Users\\maike\\AppData\\Local\\Temp\\ipykernel_33120\\158703987.py:5: SettingWithCopyWarning: \n",
520520
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
521521
"Try using .loc[row_indexer,col_indexer] = value instead\n",
522522
"\n",
@@ -633,7 +633,7 @@
633633
},
634634
{
635635
"cell_type": "code",
636-
"execution_count": 8,
636+
"execution_count": 11,
637637
"metadata": {},
638638
"outputs": [],
639639
"source": [
@@ -644,6 +644,7 @@
644644
"from synthpop import NUM_COLS_DTYPES\n",
645645
"from synthpop.processor import NAN_KEY\n",
646646
"from synthpop.method import CART_METHOD, METHODS_MAP, NA_METHODS\n",
647+
"import numpy as np\n",
647648
"\n",
648649
"class Synthpop:\n",
649650
" def __init__(self,\n",
@@ -748,7 +749,7 @@
748749
},
749750
{
750751
"cell_type": "code",
751-
"execution_count": 9,
752+
"execution_count": null,
752753
"metadata": {},
753754
"outputs": [],
754755
"source": [
@@ -758,7 +759,7 @@
758759
"from synthpop.method import DEFAULT_METHODS_MAP, INIT_METHODS_MAP, CONT_TO_CAT_METHODS_MAP\n",
759760
"from synthpop.method import ALL_METHODS, INIT_METHODS, DEFAULT_METHODS, NA_METHODS\n",
760761
"from synthpop.processor import NAN_KEY\n",
761-
"\n",
762+
"import numpy as np\n",
762763
"\n",
763764
"INIT_STEP = 'init'\n",
764765
"PROCESSOR_STEP = 'processor'\n",
@@ -1075,13 +1076,16 @@
10751076
"metadata": {},
10761077
"outputs": [
10771078
{
1078-
"name": "stdout",
1079-
"output_type": "stream",
1080-
"text": [
1081-
"train_sex\n",
1082-
"train_race1\n",
1083-
"train_ugpa\n",
1084-
"train_bar\n"
1079+
"ename": "NameError",
1080+
"evalue": "name 'np' is not defined",
1081+
"output_type": "error",
1082+
"traceback": [
1083+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
1084+
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
1085+
"Cell \u001b[1;32mIn[10], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# Initialize Synthpop object with method 'cart'\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m spop \u001b[38;5;241m=\u001b[39m \u001b[43mSynthpop\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mcart\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# Fit the Synthpop model\u001b[39;00m\n\u001b[0;32m 5\u001b[0m spop\u001b[38;5;241m.\u001b[39mfit(real_data, dtypes\u001b[38;5;241m=\u001b[39mdtypes_dict)\n",
1086+
"Cell \u001b[1;32mIn[8], line 22\u001b[0m, in \u001b[0;36mSynthpop.__init__\u001b[1;34m(self, method, visit_sequence, proper, cont_na, smoothing, default_method, numtocat, catgroups, seed)\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m 11\u001b[0m method\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[0;32m 12\u001b[0m visit_sequence\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 20\u001b[0m seed\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[0;32m 21\u001b[0m \u001b[38;5;66;03m# initialise the validator and processor\u001b[39;00m\n\u001b[1;32m---> 22\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvalidator \u001b[38;5;241m=\u001b[39m \u001b[43mValidator\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m 23\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprocessor \u001b[38;5;241m=\u001b[39m Processor(\u001b[38;5;28mself\u001b[39m)\n\u001b[0;32m 25\u001b[0m \u001b[38;5;66;03m# initialise arguments\u001b[39;00m\n",
1087+
"Cell \u001b[1;32mIn[9], line 23\u001b[0m, in \u001b[0;36mValidator.__init__\u001b[1;34m(self, spop)\u001b[0m\n\u001b[0;32m 20\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m, spop):\n\u001b[0;32m 21\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mspop \u001b[38;5;241m=\u001b[39m spop\n\u001b[0;32m 22\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattributes_types \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmethod\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[38;5;28mstr\u001b[39m, \u001b[38;5;28mlist\u001b[39m),\n\u001b[1;32m---> 23\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvisit_sequence\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[43mnp\u001b[49m\u001b[38;5;241m.\u001b[39mndarray, \u001b[38;5;28mlist\u001b[39m),\n\u001b[0;32m 24\u001b[0m \u001b[38;5;66;03m# 'predictor_matrix': (NONE_TYPE,),\u001b[39;00m\n\u001b[0;32m 25\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mproper\u001b[39m\u001b[38;5;124m'\u001b[39m: (\u001b[38;5;28mbool\u001b[39m,),\n\u001b[0;32m 26\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcont_na\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[38;5;28mdict\u001b[39m),\n\u001b[0;32m 27\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msmoothing\u001b[39m\u001b[38;5;124m'\u001b[39m: (\u001b[38;5;28mbool\u001b[39m, \u001b[38;5;28mstr\u001b[39m, \u001b[38;5;28mdict\u001b[39m),\n\u001b[0;32m 28\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdefault_method\u001b[39m\u001b[38;5;124m'\u001b[39m: (\u001b[38;5;28mstr\u001b[39m,),\n\u001b[0;32m 29\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mnumtocat\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[38;5;28mlist\u001b[39m),\n\u001b[0;32m 30\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcatgroups\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[38;5;28mint\u001b[39m, \u001b[38;5;28mdict\u001b[39m),\n\u001b[0;32m 31\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mseed\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[38;5;28mint\u001b[39m),\n\u001b[0;32m 32\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mk\u001b[39m\u001b[38;5;124m'\u001b[39m: (NONE_TYPE, \u001b[38;5;28mint\u001b[39m)}\n",
1088+
"\u001b[1;31mNameError\u001b[0m: name 'np' is not defined"
10851089
]
10861090
}
10871091
],
@@ -1095,7 +1099,7 @@
10951099
},
10961100
{
10971101
"cell_type": "code",
1098-
"execution_count": 11,
1102+
"execution_count": null,
10991103
"metadata": {},
11001104
"outputs": [
11011105
{
@@ -1271,7 +1275,7 @@
12711275
"name": "python",
12721276
"nbconvert_exporter": "python",
12731277
"pygments_lexer": "ipython3",
1274-
"version": "3.11.9"
1278+
"version": "3.11.0"
12751279
}
12761280
},
12771281
"nbformat": 4,

notebooks/GC_LawSchoolAdmissionBar.ipynb

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 10,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [
99
"import pandas as pd\n",
1010
"from sklearn.preprocessing import LabelEncoder\n",
11-
"from helper_functions_CART import *"
11+
"from helper_functions_GC import *"
1212
]
1313
},
1414
{
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 4,
23+
"execution_count": 2,
2424
"metadata": {},
2525
"outputs": [
2626
{
@@ -286,7 +286,7 @@
286286
},
287287
{
288288
"cell_type": "code",
289-
"execution_count": 5,
289+
"execution_count": 3,
290290
"metadata": {},
291291
"outputs": [
292292
{
@@ -364,7 +364,7 @@
364364
},
365365
{
366366
"cell_type": "code",
367-
"execution_count": null,
367+
"execution_count": 4,
368368
"metadata": {},
369369
"outputs": [
370370
{
@@ -443,7 +443,7 @@
443443
"4 2.0 white 3.5 a Passed 1st time"
444444
]
445445
},
446-
"execution_count": 6,
446+
"execution_count": 4,
447447
"metadata": {},
448448
"output_type": "execute_result"
449449
}
@@ -456,7 +456,7 @@
456456
},
457457
{
458458
"cell_type": "code",
459-
"execution_count": 7,
459+
"execution_count": 5,
460460
"metadata": {},
461461
"outputs": [
462462
{
@@ -468,7 +468,7 @@
468468
" 'bar': dtype('O')}"
469469
]
470470
},
471-
"execution_count": 7,
471+
"execution_count": 5,
472472
"metadata": {},
473473
"output_type": "execute_result"
474474
}
@@ -481,7 +481,7 @@
481481
},
482482
{
483483
"cell_type": "code",
484-
"execution_count": 8,
484+
"execution_count": 6,
485485
"metadata": {},
486486
"outputs": [
487487
{
@@ -490,7 +490,7 @@
490490
"{'sex': 'float', 'race1': 'category', 'ugpa': 'float', 'bar': 'category'}"
491491
]
492492
},
493-
"execution_count": 8,
493+
"execution_count": 6,
494494
"metadata": {},
495495
"output_type": "execute_result"
496496
}
@@ -503,20 +503,20 @@
503503
},
504504
{
505505
"cell_type": "code",
506-
"execution_count": 11,
506+
"execution_count": 7,
507507
"metadata": {},
508508
"outputs": [
509509
{
510510
"name": "stderr",
511511
"output_type": "stream",
512512
"text": [
513-
"/var/folders/v8/64zc34sn3b95klfm660085h80000gn/T/ipykernel_73471/158703987.py:5: SettingWithCopyWarning: \n",
513+
"C:\\Users\\maike\\AppData\\Local\\Temp\\ipykernel_40432\\158703987.py:5: SettingWithCopyWarning: \n",
514514
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
515515
"Try using .loc[row_indexer,col_indexer] = value instead\n",
516516
"\n",
517517
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
518518
" real_data[column] = label_encoders[column].fit_transform(real_data[column])\n",
519-
"/var/folders/v8/64zc34sn3b95klfm660085h80000gn/T/ipykernel_73471/158703987.py:5: SettingWithCopyWarning: \n",
519+
"C:\\Users\\maike\\AppData\\Local\\Temp\\ipykernel_40432\\158703987.py:5: SettingWithCopyWarning: \n",
520520
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
521521
"Try using .loc[row_indexer,col_indexer] = value instead\n",
522522
"\n",
@@ -600,7 +600,7 @@
600600
"4 2.0 4 3.5 0"
601601
]
602602
},
603-
"execution_count": 11,
603+
"execution_count": 7,
604604
"metadata": {},
605605
"output_type": "execute_result"
606606
}
@@ -632,9 +632,21 @@
632632
},
633633
{
634634
"cell_type": "code",
635-
"execution_count": 12,
635+
"execution_count": 9,
636636
"metadata": {},
637-
"outputs": [],
637+
"outputs": [
638+
{
639+
"ename": "NameError",
640+
"evalue": "name 'GaussianCopulaSynthesizer' is not defined",
641+
"output_type": "error",
642+
"traceback": [
643+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
644+
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
645+
"Cell \u001b[1;32mIn[9], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# Initialize synthesizer and fit it to the data\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m synthesizer \u001b[38;5;241m=\u001b[39m \u001b[43mGaussianCopulaSynthesizer\u001b[49m()\n\u001b[0;32m 3\u001b[0m synthesizer\u001b[38;5;241m.\u001b[39mfit(real_data)\n",
646+
"\u001b[1;31mNameError\u001b[0m: name 'GaussianCopulaSynthesizer' is not defined"
647+
]
648+
}
649+
],
638650
"source": [
639651
"# Initialize synthesizer and fit it to the data\n",
640652
"synthesizer = GaussianCopulaSynthesizer()\n",
@@ -643,7 +655,7 @@
643655
},
644656
{
645657
"cell_type": "code",
646-
"execution_count": 13,
658+
"execution_count": null,
647659
"metadata": {},
648660
"outputs": [
649661
{
@@ -686,7 +698,7 @@
686698
},
687699
{
688700
"cell_type": "code",
689-
"execution_count": 14,
701+
"execution_count": null,
690702
"metadata": {},
691703
"outputs": [
692704
{
@@ -735,7 +747,7 @@
735747
"name": "python",
736748
"nbconvert_exporter": "python",
737749
"pygments_lexer": "ipython3",
738-
"version": "3.11.9"
750+
"version": "3.11.0"
739751
}
740752
},
741753
"nbformat": 4,

0 commit comments

Comments
 (0)