import joblib import pandas as pd with open("scaler.joblib", 'rb') as f: scaler = joblib.load(f) # data = { # "Pregnancies": [6], # "Glucose": [148] # "BloodPressure": [72], # "SkinThickness": [35] # "BMI": [33.6], # "DiabetesPedigreeFunction": [0.627] # "Age": [50] # } # df = pd.DataFrame(data) outs = scaler.transform([[6, 148, 72, 35, 33.6, 0.627, 50]]) for i in outs[0]: print(i) # def is_number(text): # try: # # Try to convert the text to a float # float(text) # return True # except ValueError: # # If conversion fails, it's not a number # return False # inp = "1.5" # if is_number(inp): # print(int(inp.split('.')[0])) # print(int(1.5)) # def diabetic_pedigree_function(mother, father, siblings): # """ # Calculate a scaled Diabetic Pedigree Function (DPF) for an individual, # aiming for an output range of approximately (0.078, 2.42). # Parameters: # mother (int): 1 if the mother has diabetes, 0 otherwise. # father (int): 1 if the father has diabetes, 0 otherwise. # siblings (list): A list of 0s and 1s representing siblings' diabetes status. # Returns: # float: The scaled diabetic pedigree function score. # """ # # Assign weights to each family member # mother_weight = 0.5 # father_weight = 0.5 # sibling_weight = 0.25 # # Calculate the weighted contributions # family_history = (mother * mother_weight) + (father * father_weight) + (sum(siblings) * sibling_weight) # # Add a scaling factor to shift the range # scaling_factor = 1.2 # bias = 0.078 # Minimum value in the desired range # # Final scaled DPF score # dpf_score = family_history * scaling_factor + bias # return round(dpf_score, 3) # Rounded for clarity # # Example usage: # mother_history = 1 # Mother has diabetes # father_history = 0 # Father doesn't have diabetes # siblings_history = [1, 0, 0] # One sibling has diabetes, two do not # dpf = diabetic_pedigree_function(mother_history, father_history, siblings_history) # print(f"The Diabetic Pedigree Function score is: {dpf}")