-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmortalitymosaiclcdtn.py
64 lines (52 loc) · 1.93 KB
/
mortalitymosaiclcdtn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""MortalityMosaicLCDTN.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1FLReFlU3L5ILTBN11Hw3pf8IaeqeDJOD
"""
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error
from google.colab import drive
drive.mount('/content/drive')
import google.colab
!pip install drive
file_path = '/content/drive/MyDrive/dscproject/LCD_TN.csv'
LCD_TN = pd.read_csv(file_path)
# Separate the DataFrame by each year
LCD_2019 = LCD_TN[LCD_TN['year'] == 2019]
LCD_2020 = LCD_TN[LCD_TN['year'] == 2020]
LCD_2021 = LCD_TN[LCD_TN['year'] == 2021]
import seaborn as sns
# Comparative Analysis of Leading Causes of Death
plt.figure(figsize=(12, 6))
sns.barplot(data= LCD_2019, x='COUNTY', y='NUMBER', hue='CAUSE')
plt.title('Comparative Analysis of Leading Causes of Death between Counties')
plt.xlabel('County')
plt.ylabel('Number of Deaths')
plt.xticks(rotation=45)
plt.legend(title='Cause', bbox_to_anchor=(1.05, 1), loc='upper left')
plt.tight_layout()
plt.show()
# Comparative Analysis of Leading Causes of Death
plt.figure(figsize=(12, 6))
sns.barplot(data= LCD_2020, x='COUNTY', y='NUMBER', hue='CAUSE')
plt.title('Comparative Analysis of Leading Causes of Death between Counties')
plt.xlabel('County')
plt.ylabel('Number of Deaths')
plt.xticks(rotation=45)
plt.legend(title='Cause', bbox_to_anchor=(1.05, 1), loc='upper left')
plt.tight_layout()
plt.show()
# Comparative Analysis of Leading Causes of Death
plt.figure(figsize=(12, 6))
sns.barplot(data=LCD_2021, x='COUNTY', y='NUMBER', hue='CAUSE')
plt.title('Comparative Analysis of Leading Causes of Death between Counties')
plt.xlabel('County')
plt.ylabel('Number of Deaths')
plt.xticks(rotation=45)
plt.legend(title='Cause', bbox_to_anchor=(1.05, 1), loc='upper left')
plt.tight_layout()
plt.show()