This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ---------- Law of Large Number ---------- | |
| # Install packages | |
| install.packages('ggplot2') | |
| library(ggplot2) | |
| # Parameters | |
| sample_mean = 100000 | |
| sample_size = 20 | |
| set.seed(1234) | |
| # Uniform Distribution |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def irisDataClassification(): | |
| # Import modules | |
| from sklearn import datasets | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.linear_model import LogisticRegression | |
| from sklearn.metrics import accuracy_score | |
| # Import some data to play with | |
| iris = datasets.load_iris() | |
| X, y = iris.data, iris.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check length of ID | |
| def checkLength(ID): | |
| length = len(str(ID)) | |
| # check length | |
| status = False | |
| if length == 16: | |
| status = True | |
| return (status, length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check DOB | |
| def checkDOB(ID): | |
| dob = str(ID)[6:12] | |
| dob_person = int(dob) | |
| # Check the woman's dob | |
| if dob_person > 400000: | |
| dob_person = dob_person - 400000 | |
| # Convert into datetime | |
| try: | |
| dob_date = datetime.strptime(str(dob_person), '%d%m%y') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check gender | |
| def checkGender(ID): | |
| gender = str(ID)[6:7] | |
| # Check status | |
| status = False | |
| sex = None | |
| if int(gender) in range(8): | |
| if int(gender) in range(4): | |
| sex = 'Man' | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Check computerized last number | |
| def checkComputerizedLastNumber(ID): | |
| last_num = str(ID)[12:] | |
| # Check last number | |
| status = False | |
| if status != '0000': | |
| status = True | |
| return (status, last_num) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def checkAdminArea(ID, data): | |
| admin_code = str(ID)[:6] | |
| # Check the admin area | |
| status = False | |
| prov, district, subdistrict = None, None, None | |
| bin_status = binary_search(a = data['code'], x = admin_code) | |
| if bin_status: | |
| status = True | |
| # Get the values | |
| prov, district, subdistrict = df[df['code'] == admin_code].values.tolist()[0][1:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class identificationID: | |
| def __init__(self, ID): | |
| self.ID = ID | |
| # Get value | |
| def get_value(self): | |
| return str(self.ID) | |
| # Check length of ID | |
| def checkLength(self): | |
| length = len(str(self.ID)) | |
| # check length |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.