<jupyter_start><jupyter_text>Milestone 2 - <NAME> Analyzing Health and Costs using the Medical_Cost dataset provided by UCI<jupyter_code># Relative Importing of Data
import sys
sys.path.append("..")
from project_functions import load_data
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

DATA_PATH = "../../data/raw/Medical_Cost.csv"<jupyter_output><empty_output><jupyter_text>Analyzing the Health and Medical Costs of Men with children v. Men without childrenWe want to create two data frames for comparison: `with_children` and `without_children`. But first, let's set some parameters for the men we want to compare as to narrow down potential variables. - Everyone should be in the age range of 25 to 50 (inclusive).   - This is to limit how much of a factor age is in our comparison - Everyone should not be a smoker   - This is to prevent any smoking related health differences from efffecting our comparison   Since the fields `sex` and `smoker` are going to be the same for everyone, we can drop these two fields from our DataFrame.<jupyter_code>params = {
    'is_male' : True,
    'older_than' : 24,
    'younger_than' : 51,
    'no_smokers' : True,
    'reset_index' : True,
    'drop' : ['sex', 'smoker']
}

with_children = load_data(
    DATA_PATH,
    has_children=True,
    **params
)

no_children = load_data(
    DATA_PATH,
    has_children=False,
    **params
)

print("Sample of Men with Children")
print(len(with_children.index))
print('--------------------------------------------------')
print("Sample of Men without Children")
print(no_children.sample(5))<jupyter_output>Sample of Men with Children
     age    bmi  children     region    charges
88    37  24.32         2  northwest  6198.7518
62    33  29.40         4  southwest  6059.1730
106   39  32.34         2  southeast  6338.0756
145   44  27.40         2  southwest  7726.8540
158   45  20.35         3  southeast  8605.3615
201
--------------------------------------------------
Sample of Men without Children
    age     bmi  children     region      charges
36   37  36.190         0  southeast  19214.70553
28   34  34.210         0  southeast   3935.17990
29   34  35.815         0  northwest   4320.41085
6    26  35.420         0  southeast   2322.62180
0    25  25.740         0  southeast   2137.65360
67<jupyter_text>Analyzing the distribution of the dataLet's plot the count of the ages on a graph to make sure their distributions are close enough to validly compare.<jupyter_code>data = with_children[['age', 'children']].append(no_children[['age', 'children']])
data['has_child'] = data['children'] > 0

ax = sns.displot(data, x='age', hue='has_child')<jupyter_output><empty_output><jupyter_text>O no! It seems like there is not enough data about men without children to come to any firm conclusions.Looks like we will have to free up our memory and start ananlyzing something else.<jupyter_code># Free up memory to help with Python's performance
import gc

del with_children
del no_children
del data
gc.collect()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10600130463144161, 'fraction_numerical': 0.06457925636007827, 'mean_word_length': 3.0355263157894736, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '108672', 'license': 'MIT', 'n_tokens_mistral': 1041, 'n_tokens_neox': 925, 'n_words': 352, 'path': 'analysis/Matthew/milestone2.ipynb', 'repo_name': 'JivrajGrewal23/course-project-group_1041', 'size': '3074'}