Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commited changes to make the code more efficient and reduce complexity. #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shashwat623
Copy link

As an enthusiastic aspirant for GSOC 2020, I would like to contribute in this project. Below are a few changes which I believe would make the code simpler and efficient. THANK YOU!!

-> if dt.get(df.iloc[i]['patientunitstayid'], [0,0])[0]==0: Updated to- if dt.get(df.iloc[i]['patientunitstayid'])=="None": as get() will return "None" by default if key doesn't match.

-> drugs = df.iloc[i]['drugname'].split()
drugs = [drug.lower() for drug in drugs]
Updated to- drug = (df.iloc[i]['drugname'].split()[0]).lower() as feverDrugs[] contains only the first name of medicines. According to the original code, the post fix names of each medicine would be considered as different medicines. Example: "WARFARIN SODIUM" would be split into 2 different drugs namely "WARFARIN" and "SODIUM", which is ambiguous and is only adding extra For loops to match the first name with the drugs in feverDrugs[]

-> if sum([int(feverDrug==drug) for feverDrug in feverDrugs for drug in drugs])>0:
Updated to- if drug in feverDrugs: (for obvious reasons after the previous changes)

-> [1, df.iloc[i]['drugstartoffset']] Updated To- [df.iloc[i]['drugstartoffset']]
as 1 is no longer requried to be one of the values of the key for comparison in the IF statement

-> if dt.get(df.iloc[i]['patientunitstayid'], [0,0])[0]==0:  *Updated to*-  if dt.get(df.iloc[i]['patientunitstayid'])=="None":  as get() will return "None" by default if key doesn't match.

-> drugs = df.iloc[i]['drugname'].split()
        drugs = [drug.lower() for drug in drugs]
*Updated to*-   drug = (df.iloc[i]['drugname'].split()[0]).lower()   as feverDrugs[] contains only the first name of medicines. According to the original code, the post fix names of each medicine would be considered as different medicines. Example: "WARFARIN SODIUM" would be split into 2 different drugs namely "WARFARIN" and "SODIUM", which is ambiguous and is only adding extra For loops to match the first name with the drugs in feverDrugs[]
 
-> if sum([int(feverDrug==drug) for feverDrug in feverDrugs for drug in drugs])>0:
           *Updated to*-     if drug in feverDrugs:       (for obvious reasons after the previous changes)

-> [1, df.iloc[i]['drugstartoffset']]  *Updated To*-   [df.iloc[i]['drugstartoffset']] 
      as 1 is no longer requried to be one of the values of the key for comparison in the IF statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant