<jupyter_start><jupyter_text>Activity 1: Missing values<jupyter_code>data = pd.read_csv('house_prices.csv')
data.info()
data.describe().T
mask = data.isnull()
total = mask.sum()
percent = 100*mask.mean()

missing_data = pd.concat([total, percent], axis=1,join='outer',
                         keys=['count_missing', 'perc_missing'])
missing_data.sort_values(by='perc_missing', ascending=False, inplace=True)

missing_data[missing_data.count_missing > 0]
nullable_columns = data.columns[mask.any()].tolist()
msno.matrix(data[nullable_columns].sample(500))
plt.show()
msno.heatmap(data[nullable_columns], figsize=(18,18))
plt.show()
data = data.loc[:,missing_data[missing_data.perc_missing < 80].index]
data['FireplaceQu'] = data['FireplaceQu'].fillna('NA')<jupyter_output><empty_output><jupyter_text>Activity 2: Distribution of Values<jupyter_code>plt.figure(figsize=(8,6))

plt.hist(data.SalePrice, bins=range(0,800000,50000))

plt.ylabel('Number of data points')
plt.xlabel('flag_tsunami')
plt.show()
object_variables = data.select_dtypes(include=[np.object])
object_variables.nunique().sort_values()
counts = data.HouseStyle.value_counts(dropna=False)
counts.reset_index().sort_values(by='index')
plt.figure(figsize=(10,10))
plt.pie(counts, labels=counts.index)
plt.title('Pie chart showing counts for\ndamage_description categories')
plt.show()
numeric_variables = data.select_dtypes(include=[np.number])
numeric_variables.nunique().sort_values(ascending=False)
plt.figure(figsize=(10,7))
sns.distplot(data.LotArea.dropna(), , bins=range(0,100000,1000))
plt.xlim(0,100000)
plt.show()
data.skew().sort_values()
data.kurt()<jupyter_output><empty_output><jupyter_text>Activity 3: Relationships within data<jupyter_code>plt.figure(figsize = (12,10))
sns.heatmap(data[sorted(data.columns)].corr(), square=True, cmap="RdBu", vmin=-1, vmax=1)
plt.show()
feature_subset = [
    'GarageArea', 'GarageCars','GarageCond','GarageFinish','GarageQual','GarageType',
    'GarageYrBlt','GrLivArea','LotArea','MasVnrArea','SalePrice'
]
plt.figure(figsize = (12,10))
sns.heatmap(data[feature_subset].corr(), square=True, annot=True, cmap="RdBu", vmin=-1, vmax=1)
plt.show()
sns.pairplot(data[feature_subset].dropna(), kind ='scatter', diag_kind='kde')
plt.show()
plt.figure(figsize=(10, 10))
sns.boxplot(x='GarageCars', y="SalePrice", data=data)
plt.show()
plt.figure(figsize=(10,7))
sns.lineplot(x=data.YearBuilt, y=data.SalePrice, ci=None)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17949756888168558, 'fraction_numerical': 0.030388978930307942, 'mean_word_length': 8.955645161290322, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '251809', 'license': 'MIT', 'n_tokens_mistral': 1018, 'n_tokens_neox': 927, 'n_words': 114, 'path': 'Chapter 2 - Exploratory Data Analysis and Visualisation/Activities.ipynb', 'repo_name': 'doc-E-brown/Applied-Supervised-Learning-with-Python', 'size': '2468'}