Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/wiz21b/TechnoInfoCom into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Champailler committed Mar 14, 2021
2 parents a4afe49 + 95ee436 commit 2ef27b4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions p1_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,20 @@ def medical_diagnosis():

print(f"{vname} & {e} \\\\")



# Question 8

obesity_age = marginalize(jpd, ["obesity", "age"], True)

print(mutual_information(obesity_age, "obesity", "age"))
print(mutual_information(obesity_age, "age", "obesity")) # swap variabkes to checking for bugs

# Try with different variables to see if the results are the same than in question 9
obesity_dic = marginalize(jpd, ["obesity", "DIS"], True)
print(mutual_information(obesity_dic, "obesity", "DIS"))
print(mutual_information(obesity_dic, "DIS", "obesity"))

# Question 9

print("-"*80)
Expand Down Expand Up @@ -362,6 +369,30 @@ def medical_diagnosis():
# import code
# code.interact(local=dict(globals(), **locals()))

# Question 11


print("-"*80)
print("Question 11")

#age2 = df[ df.age == 'morethan40']
#print(age2)

jpd = df[df.age.isin(['morethan40'])].groupby(
list(df.columns)).size().reset_index()

dis_age = marginalize(jpd, ["DIS", "age"], True)
print(mutual_information(dis_age, "DIS", "age"))


jpd = df[df.age.isin(['lessorequalthan40'])].groupby(
list(df.columns)).size().reset_index()

dis_age = marginalize(jpd, ["DIS", "age"], True)
print(mutual_information(dis_age, "DIS", "age"))




if __name__ == "__main__":

Expand Down

0 comments on commit 2ef27b4

Please sign in to comment.