Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp20008-project-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samantha Garrick
comp20008-project-2
Commits
3810c374
Commit
3810c374
authored
4 years ago
by
Samantha Garrick
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
c2132dcc
No related branches found
No related tags found
No related merge requests found
Pipeline
#82942
failed
4 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mutual_info.py
+29
-0
29 additions, 0 deletions
mutual_info.py
with
29 additions
and
0 deletions
mutual_info.py
0 → 100644
+
29
−
0
View file @
3810c374
import
pandas
as
pandas
import
math
data
=
pandas
.
read_csv
(
"
dataframe_for_MI.csv
"
)
df
=
data
#Asthma data and PM10 data were binned based on domain knowledge
#Asthma was binned into 2 bins; percentages under 10% and over 10%
#PM10 was binned into 3 bins; readings under 40, between 40 and 80 between 80 and 120
#This was according to air quality categories of good, fair and poor respectively provided by the EPA
#https://www.epa.vic.gov.au/for-community/environmental-information/air-quality/pm10-particles-in-the-air
asthma_entropy
=
-
0.5
*
math
.
log
(
0.5
,
2
)
-
0.5
*
math
.
log
(
0.5
,
2
)
print
(
"
Entropy value for asthma percentage data:
"
+
str
(
asthma_entropy
))
pm10_entropy
=
-
0.25
*
math
.
log
(
0.25
,
2
)
-
0.625
*
math
.
log
(
0.625
,
2
)
-
0.125
*
math
.
log
(
0.125
,
2
)
print
(
"
Entropy value for PM10 data:
"
+
str
(
pm10_entropy
))
pm10_given_asthma
=
0.5
*
(
-
0.5
*
math
.
log
(
0.5
,
2
)
-
0.5
*
math
.
log
(
0.5
,
2
)
+
-
0.25
*
math
.
log
(
0.25
,
2
)
-
0.75
*
math
.
log
(
0.75
,
2
))
print
(
"
Conditional entropy for PM10 data given values for asthma:
"
+
str
(
pm10_given_asthma
))
asthma_given_pm10
=
0.625
*
(
-
0.4
*
math
.
log
(
0.4
,
2
)
+
-
0.6
*
math
.
log
(
0.6
,
2
))
print
(
"
Conditional entropy for asthma data given values for PM10:
"
+
str
(
asthma_given_pm10
))
mutual_info
=
pm10_entropy
-
pm10_given_asthma
normalised_mutual_info
=
mutual_info
/
asthma_entropy
print
(
"
Normalised mutual information between the PM10 and asthma data:
"
+
str
(
normalised_mutual_info
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment