-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_data.py
1368 lines (1216 loc) · 45.9 KB
/
generate_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from datetime import date, datetime, timedelta
import time
import pandas as pd
import random
import gspread
from faker import Faker
from faker.providers import BaseProvider
from configs import SERVICE_ACCOUNT_FILE, SHEET_CONFIG
# Custom Provider for Nigerian Names and Addresses
class NigerianSchoolDataProvider(BaseProvider):
"""
A custom provider to generate Nigerian-specific data for school-related information,
such as student and teacher names, addresses, and demographic details. This provider
extends the Faker library by adding culturally relevant methods specific to Nigerian contexts.
"""
def nigerian_first_name(self):
"""
Generates a Nigerian first name.
This method provides culturally specific first names commonly found in Nigeria, covering
diverse regions and ethnic backgrounds. It is useful for data generation in applications
requiring Nigerian names or simulated datasets for Nigerian populations.
Returns:
str: A string representing a Nigerian first name.
"""
first_names = [
"Chinedu",
"Ngozi",
"Yemi",
"Bola",
"Ifeanyi",
"Uche",
"Amina",
"Emeka",
"Nkechi",
"Tope",
"Chika",
"Bisi",
"Femi",
"Kunle",
"Gbenga",
"Tolu",
"Funmi",
"Ada",
"Olu",
"Sade",
"Dapo",
"Kehinde",
"Nnamdi",
"Kemi",
"Chinonso",
"Ebele",
"Obinna",
"Amara",
"Chidera",
"Olumide",
"Bankole",
"Ezinne",
"Chimamanda",
"Yinka",
"Ayo",
"Dele",
"Chiamaka",
"Omotola",
"Segun",
"Kolawole",
"Sikiru",
"Maryam",
"Fatimah",
"Toyin",
"Kudirat",
"Abdul",
"Rukayat",
"Efe",
"Mfon",
"Oghenekaro",
"Adebisi",
"Khadijah",
"Ahmed",
"Yusuf",
"Jide",
"Temitope",
"Tosin",
"Nafisat",
"Hadiza",
"Aisha",
"Taiwo",
"Bimbo",
"Gbadebo",
"Simisola",
"Zainab",
"Saheed",
"Ifeoma",
"Ndidi",
"Tajudeen",
"Emmanuella",
"Chukwuemeka",
"Onyeka",
"Ndubisi",
"Oluwatobiloba",
"Yemisi",
"Oluwasegun",
"Eunice",
"Suliat",
"Anike",
"Usman",
"Adebola",
"Oluwanifemi",
"Ayodeji",
"Mojirayo",
"Chisom",
"Efeoma",
"Muna",
"Obiageli",
"Yewande",
]
return self.random_element(first_names)
def nigerian_last_name(self):
"""
Generates a Nigerian last name.
This method provides Nigerian last names reflective of various ethnic backgrounds,
supporting data simulations that require surnames common across Nigeria. It serves
well for databases or test data tailored for Nigerian user bases.
Returns:
str: A string representing a Nigerian last name.
"""
last_names = [
"Okafor",
"Balogun",
"Olawale",
"Eze",
"Ibrahim",
"Adesina",
"Ogunleye",
"Nwosu",
"Osagie",
"Okonkwo",
"Chukwu",
"Alabi",
"Onyejekwe",
"Obi",
"Ojo",
"Adeola",
"Adebayo",
"Anyanwu",
"Ajayi",
"Ogbemudia",
"Awolowo",
"Ikenna",
"Akintola",
"Oni",
"Odugbemi",
"Adeyemi",
"Ikechukwu",
"Etuk",
"Okorie",
"Amaechi",
"Ogbonna",
"Agbaje",
"Chukwuma",
"Adegoke",
"Ogunmola",
"Musa",
"Sanusi",
"Oyeleke",
"Opeoluwa",
"Bello",
"Obafemi",
"Danjuma",
"Adamu",
"Muhammad",
"Ozor",
"Gadzama",
"Oboh",
"Ekechukwu",
"Olaniyan",
"Olojede",
"Orji",
"Nwachukwu",
"Umeh",
"Uzor",
"Anosike",
"Odeleye",
"Olatunji",
"Falade",
"Dare",
"Bakare",
"Fashola",
"Jaiyeola",
"Adigun",
"Adewole",
"Orjiakor",
"Onochie",
"Adeyinka",
"Olubiyi",
"Omoruyi",
"Idowu",
"Omoyeni",
"Obasanya",
"Olaide",
"Oluwole",
"Ogunsanwo",
"Oshin",
"Kasim",
"Obiano",
"Ejiogu",
]
return self.random_element(last_names)
def nigerian_address(self):
"""
Randomly generates a Nigerian address to simulate a residential or business location.
Addresses cover various cities and well-known streets, reflecting a mix of metropolitan
and regional areas across Nigeria. This is useful for creating localized data for testing
or simulation within Nigerian settings.
Returns:
str: A string representing a Nigerian address.
"""
addresses = [
"12 Adeola Avenue, Lagos",
"45 Ibrahim Street, Abuja",
"23 Balogun Close, Ikeja, Lagos",
"9 Aminu Kano Crescent, Wuse, Abuja",
"17 Glover Road, Ikoyi, Lagos",
"32 Nnamdi Azikiwe Drive, Enugu",
"18 Oluwole Street, Ibadan",
"15 Ogbemudia Street, Benin",
"22 Oniru Crescent, Victoria Island, Lagos",
"1 Awolowo Road, Ikoyi, Lagos",
"33 Ogundana Street, Ikeja, Lagos",
"10 Marina Road, Victoria Island, Lagos",
"14 Opebi Road, Ikeja, Lagos",
"27 Ahmadu Bello Way, Victoria Island, Lagos",
"5 Okonjo-Iweala Street, Abuja",
"30 Asokoro Avenue, Asokoro, Abuja",
"7 Maitama Crescent, Maitama, Abuja",
"8 Aguiyi Ironsi Street, Maitama, Abuja",
"21 Awka Road, Onitsha, Anambra",
"35 New Haven Road, Enugu",
"42 Ngwo Street, Enugu",
"15 Herbert Macaulay Way, Yaba, Lagos",
"12 Bankole Street, Lagos Island, Lagos",
"19 Alimosho Road, Egbeda, Lagos",
"6 Surulere Avenue, Surulere, Lagos",
"2 Allen Avenue, Ikeja, Lagos",
"25 Bode Thomas Street, Surulere, Lagos",
"11 Wetheral Road, Owerri, Imo",
"16 Tetlow Road, Owerri, Imo",
"23 Egbu Road, Owerri, Imo",
"9 Olu Obasanjo Road, Port Harcourt, Rivers",
"22 Old Aba Road, Port Harcourt, Rivers",
"17 Elelenwo Street, Port Harcourt, Rivers",
"4 Sani Abacha Way, Kano",
"29 Yankari Close, Kano",
"7 Shehu Shagari Way, Kano",
"18 Makurdi Road, Kaduna",
"33 Yakubu Gowon Way, Kaduna",
"12 Tafawa Balewa Way, Bauchi",
"19 Ahmadu Bello Street, Bauchi",
"15 Jos Road, Bauchi",
"23 Muhammadu Buhari Way, Minna",
"27 Paiko Road, Minna",
"14 Airport Road, Benin",
"32 Ugbor Road, Benin",
"8 Boundary Road, Benin",
"5 Orelope Street, Osogbo, Osun",
"17 Gbongan Road, Osogbo, Osun",
"30 Mokola Road, Ibadan, Oyo",
"9 Dugbe Street, Ibadan, Oyo",
"11 Ring Road, Ibadan, Oyo",
"7 Iwo Road, Ibadan, Oyo",
"3 Queen Elizabeth Road, Ilorin, Kwara",
"16 Taiwo Road, Ilorin, Kwara",
"25 Asa Dam Road, Ilorin, Kwara",
"8 Stadium Road, Calabar, Cross River",
"13 Marian Road, Calabar, Cross River",
"21 Moore Road, Calabar, Cross River",
]
return self.random_element(addresses)
def state_of_origin(self):
"""
Randomly selects a Nigerian state as a state of origin for an individual.
States are representative of all geopolitical regions within Nigeria, providing a diverse
range for regional distribution of data, which may be useful for simulations or testing
localized demographic information.
Returns:
str: A string representing a Nigerian state.
"""
states_of_origin = [
"Abia",
"Adamawa",
"Akwa Ibom",
"Anambra",
"Bauchi",
"Bayelsa",
"Benue",
"Borno",
"Cross River",
"Delta",
"Ebonyi",
"Edo",
"Ekiti",
"Enugu",
"FCT",
"Gombe",
"Imo",
"Jigawa",
"Kaduna",
"Kano",
"Katsina",
"Kebbi",
"Kogi",
"Kwara",
"Lagos",
"Nasarawa",
"Niger",
"Ogun",
"Ondo",
"Osun",
"Oyo",
"Plateau",
"Rivers",
"Sokoto",
"Taraba",
"Yobe",
"Zamfara",
]
return self.random_element(states_of_origin)
def home_language(self):
"""
Randomly selects a language commonly spoken at home in Nigeria, representing
cultural and linguistic diversity.
Languages include major regional languages and dialects, supporting data
generation for projects that require linguistic demographics or simulate multilingual
settings in Nigeria.
Returns:
str: A string representing a home language.
"""
languages = [
"English",
"Yoruba",
"Igbo",
"Hausa",
"Efik",
"Ibibio",
"Ijaw",
"Tiv",
"Edo",
"Fulfulde",
"Kanuri",
"Nupe",
"Gwari",
"Itsekiri",
"Urhobo",
"Ikwere",
"Jukun",
"Idoma",
]
return self.random_element(languages)
def income_bracket(self):
"""
Randomly selects an income bracket that represents the socio-economic
status of individuals based on annual income levels in Nigeria.
Brackets range from low to high income, with descriptions:
- "Below 100,000 Naira": Low income
- "100,000 - 500,000 Naira": Lower-middle income
- "500,000 - 1,000,000 Naira": Middle income
- "1,000,000 - 3,000,000 Naira": Upper-middle income
- "Above 3,000,000 Naira": High income
Returns:
str: A string representing an income bracket.
"""
brackets = [
"Below 100,000 Naira",
"100,000 - 500,000 Naira",
"500,000 - 1,000,000 Naira",
"1,000,000 - 3,000,000 Naira",
"Above 3,000,000 Naira",
]
return self.random_element(brackets)
def education_level(self):
"""
Randomly selects an education level to represent the highest educational
attainment of individuals, capturing a range from primary to doctoral levels.
Levels include:
- "Primary School": Basic education
- "Secondary School": Intermediate education
- "Technical/Vocational": Specialized non-academic training
- "Diploma": Post-secondary but pre-bachelor's education
- "Bachelor": Undergraduate degree
- "Master": Graduate degree
- "PhD": Doctoral degree
- "Uneducated": No formal education
Returns:
str: A string representing an education level.
"""
education_levels = [
"Primary School",
"Secondary School",
"Technical/Vocational",
"Diploma",
"Bachelor",
"Master",
"PhD",
"Uneducated",
]
return self.random_element(education_levels)
def employment_type(self):
"""
Randomly selects an employment type to represent the employment status and
work arrangement of individuals in various sectors.
Types include:
- "Full-Time": Regular, long-term employment
- "Part-Time": Reduced hours
- "Self-Employed": Own business or freelance work
- "Unemployed": Not currently employed
- "Contract": Short-term or project-based employment
- "Freelancer": Independent contractor with variable projects
- "Informal Sector": Non-traditional or unregulated work
Returns:
str: A string representing an employment type.
"""
employment_types = [
"Full-Time",
"Part-Time",
"Self-Employed",
"Unemployed",
"Contract",
"Freelancer",
"Informal Sector",
]
return self.random_element(employment_types)
def industry(self):
"""
Randomly selects an industry representing the professional sector
in which individuals are employed.
Common industries include:
- "Education": Schools, colleges, universities, etc.
- "Healthcare": Hospitals, clinics, pharmaceuticals
- "Finance": Banks, insurance, financial services
- "Retail": Shopping, sales, consumer goods
- "Technology": IT, software, telecommunications
- "Agriculture": Farming, livestock, forestry
- "Government": Public administration and services
- "Manufacturing": Production of goods
- "Entertainment": Media, film, music, sports
Returns:
str: A string representing an industry sector.
"""
industries = [
"Education",
"Healthcare",
"Finance",
"Retail",
"Construction",
"Agriculture",
"Transportation",
"Technology",
"Hospitality",
"Telecommunications",
"Oil & Gas",
"Government",
"Manufacturing",
"Entertainment",
"Mining",
"Legal",
"Other",
]
return self.random_element(industries)
def nigerian_job(self):
"""
Randomly selects a job title from a wide range of common professions in Nigeria.
Jobs cover various sectors and roles, including:
- "Teacher", "Doctor", "Engineer" for professional roles
- "Civil Servant", "Banker" for institutional roles
- "Trader", "Farmer", "Tailor" for informal sector jobs
- "Software Developer", "Data Analyst" for modern industry roles
Returns:
str: A string representing a job title.
"""
jobs = [
"Teacher",
"Doctor",
"Engineer",
"Accountant",
"Nurse",
"Banker",
"Civil Servant",
"Lawyer",
"Pharmacist",
"Lecturer",
"Police Officer",
"Journalist",
"Entrepreneur",
"Software Developer",
"Mechanic",
"Electrician",
"Farmer",
"Tailor",
"Fashion Designer",
"Chef",
"Driver",
"Plumber",
"Architect",
"Scientist",
"Environmentalist",
"Social Worker",
"Graphic Designer",
"Consultant",
"Data Analyst",
"Digital Marketer",
"Project Manager",
"HR Manager",
"Business Analyst",
"Sales Representative",
"Real Estate Agent",
"Photographer",
"Event Planner",
"Security Officer",
"Financial Advisor",
"Fitness Trainer",
"Insurance Agent",
"Bank Teller",
"Medical Lab Scientist",
"Radiologist",
"Administrative Assistant",
"Procurement Officer",
"Public Relations Officer",
"Community Health Worker",
"Veterinarian",
"Public Health Specialist",
"Trader",
"Clergy",
]
return self.random_element(jobs)
def nigerian_phone_number(self):
"""
Generates a realistic Nigerian phone number.
The phone number consists of a randomly selected Nigerian prefix followed by
eight random digits. Common Nigerian prefixes include "070", "080", "081", "090",
and "091".
Returns:
str: A string representing a Nigerian phone number in the format "0XXXXXXXXX".
"""
# Nigerian phone number prefixes
prefixes = ["070", "080", "081", "090", "091"]
# Select a random prefix and append 8 random digits
phone_number = f"{random.choice(prefixes)}{random.randint(10000000, 99999999)}"
return phone_number
def blood_group(self):
"""
Randomly selects a blood group from the commonly known blood types.
Blood groups include both positive and negative types for groups A, B, AB, and O.
Returns:
str: A string representing a blood group (e.g., "A+", "O-").
"""
blood_groups = ["A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"]
return self.random_element(blood_groups)
def subject(self):
"""
Randomly selects a subject from a predefined list of school subjects.
Subjects cover a range of areas, including core subjects (e.g., English, Mathematics)
and specialized areas (e.g., Technical Drawing, Commerce).
Returns:
str: A string representing the name of a school subject.
"""
subjects = [
"English Language",
"Mathematics",
"Civic Education",
"Biology",
"Physics",
"Chemistry",
"Further Mathematics",
"Health Education",
"Computer Science",
"Technical Drawing",
"Food and Nutrition",
"Agricultural Science",
"Financial Accounting",
"Book Keeping",
"Commerce",
"Data Processing",
"Office Practice",
"Typewriting",
"Economics",
"Government",
"Literature in English",
"Christian Religion Knowledge",
"Geography",
"Fine Art",
]
return self.random_element(subjects)
def genotype(self):
"""
Randomly selects a genotype from a list of common human genotypes.
Genotypes include "AA", "AS", "SS", and "AC", representing possible genetic
traits for blood.
Returns:
str: A string representing a human genotype (e.g., "AA", "SS").
"""
genotypes = ["AA", "AS", "SS", "AC"]
return self.random_element(genotypes)
def marital_status(self):
"""
Randomly selects a marital status from common options.
This includes statuses like "Married", "Single", "Divorced", "Separated", and "Widowed".
Returns:
str: A string representing a marital status.
"""
marital_status = ["Married", "Single", "Divorced", "Separated", "Widowed"]
return self.random_element(marital_status)
def qualification(self):
"""
Randomly selects a professional or educational qualification from common levels.
Qualifications include various academic degrees like "B.Ed.", "M.Sc.", "B.Sc.",
and other certifications relevant to professional fields.
Returns:
str: A string representing an educational or professional qualification.
"""
qualifications = ["B.Ed.", "M.Sc.", "B.Sc.", "PGDE", "M.A.", "M.Ed."]
return self.random_element(qualifications)
def stream_name(self):
"""
Randomly selects a stream (academic focus area) from a predefined list of streams
representing different areas of study in secondary education.
Each stream includes a list of subjects associated with it. Examples of streams include:
- "Basic Science and Maths": Focused on scientific and mathematical subjects like Biology and Physics.
- "Technical and Agricultural": Focused on technical skills and agricultural knowledge.
- "Commercial": Centered around financial and business-related subjects.
- "Liberal Arts and Social Science": Emphasizes social sciences, arts, and humanities.
Returns:
str: The name of a randomly selected stream.
"""
streams = {
"Basic Science and Maths": [
"Biology",
"Physics",
"Chemistry",
"Further Mathematics",
"Health Education",
"Computer Science",
],
"Technical and Agricultural": [
"Technical Drawing",
"Food and Nutrition",
"Agricultural Science",
"Physics",
"Chemistry",
"Biology",
],
"Commercial": [
"Financial Accounting",
"Book Keeping",
"Commerce",
"Data Processing",
"Office Practice",
"Typewriting",
],
"Liberal Arts and Social Science": [
"Economics",
"Government",
"Literature in English",
"Christian Religion Knowledge",
"Geography",
"Fine Art",
],
}
return self.random_element(list(streams.keys()))
def remark(self):
"""
Randomly selects a teacher remark from a list of possible comments to provide feedback on a student’s performance.
Remarks are designed to capture a range of teacher observations, from high praise to areas for improvement.
Examples include:
- "Excellent performance!"
- "Needs improvement"
- "Great improvement"
- "Struggles with some concepts"
Returns:
str: A string representing a teacher's feedback remark.
"""
teacher_remarks = [
"Excellent performance!",
"Needs improvement",
"Good effort",
"Outstanding!",
"Satisfactory",
"Below expectations",
"Keep up the good work",
"Poor attendance",
"Well done",
"Great improvement",
"Average performance",
"Shows potential",
"Struggles with some concepts",
]
return self.random_element(teacher_remarks)
# Initialize Faker and add custom provider
fake = Faker()
fake.add_provider(NigerianSchoolDataProvider)
# Define constants and configuration
gc = gspread.service_account(filename=SERVICE_ACCOUNT_FILE)
YEAR_OF_ADMISSION = "2022"
core_subjects = ["English Language", "Mathematics", "Civic Education"]
streams = {
"Basic Science and Maths": [
"Biology",
"Physics",
"Chemistry",
"Further Mathematics",
"Health Education",
"Computer Science",
],
"Technical and Agricultural": [
"Technical Drawing",
"Food and Nutrition",
"Agricultural Science",
"Physics",
"Chemistry",
"Biology",
],
"Commercial": [
"Financial Accounting",
"Book Keeping",
"Commerce",
"Data Processing",
"Office Practice",
"Typewriting",
],
"Liberal Arts and Social Science": [
"Economics",
"Government",
"Literature in English",
"Christian Religion Knowledge",
"Geography",
"Fine Art",
],
}
academic_years = {"SS1": "2022/2023", "SS2": "2023/2024", "SS3": "2024/2025"}
terms = ["First", "Second", "Third"]
grade_levels = ["SS1", "SS2", "SS3"]
class_arms = {
"Basic Science and Maths": "A",
"Technical and Agricultural": "B",
"Commercial": "C",
"Liberal Arts and Social Science": "D",
}
terms_sessions = [
{"term": term, "session": grade}
for grade in grade_levels
for term in terms
if not (grade == "SS3" and term == "Third")
]
# Score distributions
performance_profiles = {
"Poor": {"ca_mean": 5, "ca_std_dev": 3, "exam_mean": 30, "exam_std_dev": 10},
"Average": {"ca_mean": 8, "ca_std_dev": 3, "exam_mean": 40, "exam_std_dev": 5},
"Above Average": {
"ca_mean": 12,
"ca_std_dev": 3,
"exam_mean": 50,
"exam_std_dev": 10,
},
}
# Assign probabilities for each profile
profile_probabilities = ["Poor"] * 15 + ["Average"] * 65 + ["Above Average"] * 20
# Helper function to create unique student ID
def create_student_id(year, count, stream_abbr):
"""
Generates a unique student ID based on the admission year, sequential count,
and stream abbreviation.
Args:
year (str): Admission year in the format 'YYYY'.
count (int): Sequential number representing the student's order in their stream.
stream_abbr (str): Abbreviation of the stream name (e.g., 'BS' for Basic Science).
Returns:
str: A unique student ID.
"""
return f"{year}{count:04d}{stream_abbr}"
# Helper: Add Timestamps
def current_timestamp():
"""
Returns the current date and time in a standardized string format.
Returns:
str: Current timestamp in 'YYYY-MM-DD HH:MM:SS' format.
"""
return datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# Function to generate names and IDs for students and parents
def generate_student_parent_pairs(stream_name, num_students=30):
"""
Generates data for students and their respective parents, including unique IDs,
names, and additional demographic information for each.
Args:
stream_name (str): The name of the stream (e.g., 'Basic Science and Maths').
num_students (int): The number of student-parent pairs to generate.
Returns:
tuple: Two DataFrames, one for student data and one for parent data.
"""
student_data = []
parent_data = []
# Generate unique data for each student-parent pair
for i in range(1, num_students + 1):
# Abbreviate stream name to form part of student ID
stream_abbr = "".join([word[0] for word in stream_name.split()]).upper()
student_id = create_student_id(YEAR_OF_ADMISSION, i, stream_abbr)
# Randomly generate Nigerian names for students
first_name = random.choice([fake.nigerian_first_name(), fake.first_name()])
middle_name = random.choice([fake.nigerian_first_name(), fake.first_name()])
last_name = fake.nigerian_last_name()
full_name = f"{first_name} {middle_name} {last_name}"
# Generate parent ID and details
parent_id = f"PAR{random.randint(1000, 9999)}"
parent_first_name = fake.nigerian_first_name()
parent_middle_name = random.choice(
[fake.nigerian_first_name(), fake.first_name()]
)
parent_gender = random.choice(["Male", "Female"])
# Generate additional demographic details for students
gender = random.choice(["Male", "Female"])
date_of_birth = fake.date_of_birth(minimum_age=13, maximum_age=20)
address = fake.nigerian_address()
blood_group = fake.blood_group()
genotype = fake.genotype()
state_of_origin = fake.state_of_origin()
registration_date = fake.date_between(
start_date=date(2022, 8, 1), end_date=date(2022, 10, 31)
)
profile = performance_profiles[random.choice(profile_probabilities)]
# Append generated student data to list
student_data.append(
{
"Student ID": student_id,
"First Name": first_name,
"Middle Name": middle_name,
"Last Name": last_name,
"Gender": gender,
"Date of Birth": date_of_birth,
"Stream": stream_name,
"Grade Level": "SS3",
"Blood Group": blood_group,
"Genotype": genotype,
"State of Origin": state_of_origin,
"Address": address,
"Parent ID": parent_id,
"Registration Date": registration_date,
"Full Name": full_name,
"Profile": profile,
"Created At": current_timestamp(),
"Updated At": current_timestamp(),
}
)
# Generate additional engagement and socio-economic details for parents
engagement_level = random.randint(
1, 10
) # Engagement score based on interactions
relationship_type = random.choice(["Parent", "Relative", "Guardian"])
number_of_children = random.randint(1, 5)
email = f"{parent_first_name.lower()}.{last_name.lower()}{random.randint(10, 999)}@example.com"
# Interaction metrics for parent
parent_teacher_meeting_attendance = random.randint(0, 5)
volunteer_activities_count = random.randint(0, 3)
timestamp = datetime.strptime(current_timestamp(), "%Y-%m-%d %H:%M:%S")
recent_interaction_date = timestamp - timedelta(days=random.randint(1, 180))
# Append generated parent data to list
parent_data.append(
{
"Parent ID": parent_id,
"First Name": parent_first_name,
"Middle Name": parent_middle_name,
"Last Name": last_name,
"Gender": parent_gender,
"Marital Status": random.choice(
["Married", "Single", "Separated", "Divorced", "Widowed"]
),
"Phone Number": fake.nigerian_phone_number(),
"Email": email,
"Address": address,
"Relationship to Student": relationship_type,
"Income Bracket": fake.income_bracket(),
"Education Level": fake.education_level(),
"Occupation": fake.nigerian_job(),
"Employment Type": fake.employment_type(),
"Industry": fake.industry(),
"Engagement Level": engagement_level,
"Home Language": fake.home_language(),
"Number of Children": number_of_children,
"Alternate Contact Number": fake.nigerian_phone_number(),
"Parent-Teacher Meeting Attendance": parent_teacher_meeting_attendance,
"Volunteer Activities Count": volunteer_activities_count,
"Recent Interaction Date": recent_interaction_date,
"Created At": current_timestamp(),
"Updated At": current_timestamp(),
}
)
# Return student and parent data as DataFrames
return pd.DataFrame(student_data), pd.DataFrame(parent_data)
# Function to generate term scores based on performance profiles
def generate_term_scores(profile):
"""
Generates continuous assessment (CA) and exam scores based on a specified performance profile.
Each score is capped to realistic maximum values.
Args:
profile (dict): Performance profile containing mean and standard deviation values for CA and exam scores.
Returns:
tuple: CA1 score, CA2 score, and Exam score as integers.
"""
# Generate CA and Exam scores within defined performance profile limits
ca1 = int(random.gauss(profile["ca_mean"], profile["ca_std_dev"]))
ca2 = int(random.gauss(profile["ca_mean"], profile["ca_std_dev"]))
exam = int(random.gauss(profile["exam_mean"], profile["exam_std_dev"]))
# Return scores clamped within realistic ranges
return max(0, min(15, ca1)), max(0, min(15, ca2)), max(10, min(70, exam))