<jupyter_start><jupyter_text>Play Around with Preprocessing<jupyter_code>attributes = pd.read_csv(f'/data/wiai-facility/processed/attributes.csv')

median_days = dict()
symptoms = ['cough', 'fever', 'shortness_of_breath']
for symptom in symptoms:
    median_days[symptom] = attributes[attributes[f'enroll_{symptom}'] == 'Yes'][f'enroll_days_with_{symptom}'].median()
    attributes.loc[attributes[f'enroll_{symptom}'] == 'No', f'enroll_days_with_{symptom}'] = 0
    attributes[f'enroll_days_with_{symptom}'].fillna( median_days[symptom], inplace=True)
    attributes[f'enroll_days_with_{symptom}'] = np.where(attributes[f'enroll_days_with_{symptom}'] > 100, median_days[symptom], \
                                                         attributes[f'enroll_days_with_{symptom}'])
    
median_age = attributes.loc[attributes['enroll_patient_age'] < 100, 'enroll_patient_age'].median()
attributes["enroll_patient_age"] = np.where(attributes["enroll_patient_age"] > 100, median_age, attributes['enroll_patient_age'])

continuous_var = ['enroll_patient_age', 'enroll_patient_temperature', 'enroll_days_with_cough', 'enroll_days_with_shortness_of_breath', 'enroll_days_with_fever']
categorical_var = ['enroll_travel_history', 'enroll_contact_with_confirmed_covid_case',
           'enroll_health_worker', 'enroll_fever', 'enroll_cough', 'enroll_shortness_of_breath']

# Normalizing it
for var in continuous_var:
    attributes[var] = (attributes[var] - attributes[var].mean()) / attributes[var].std()
    
for var in categorical_var:    
    le = LabelEncoder()
    attributes[var] = le.fit_transform(attributes[var])
attributes[continuous_var + categorical_var].head()<jupyter_output><empty_output><jupyter_text>Post Pre-Processing, Save the `attributes.csv` as a different file<jupyter_code>attributes.to_csv('/data/wiai-facility/processed/attributes_context_processed.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13413361169102297, 'fraction_numerical': 0.005219206680584551, 'mean_word_length': 6.761133603238866, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '640703', 'license': 'Apache-2.0', 'n_tokens_mistral': 672, 'n_tokens_neox': 645, 'n_words': 81, 'path': 'analysis/context-classification/process_attributes.ipynb', 'repo_name': 'WadhwaniAI/cac-test-release', 'size': '1916'}