Skip to content

Commit

Permalink
Sparse wouldn't be representative
Browse files Browse the repository at this point in the history
  • Loading branch information
thornoe committed Feb 7, 2024
1 parent f73cd90 commit 626aae2
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions gis/coastal_CV.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,26 @@ def AccuracyScore(y_true, y_pred):
# Empty DataFrame for storing distribution of typology in
VPstats = pd.DataFrame(columns=["All VP3", "Sparse"])

# Df for storing number of observed coastal waters and yearly distribution by dummies
d = pd.DataFrame(dfEcoObs.count(), index=dfEcoObs.columns, columns=["n"]).astype(int)

# Yearly distribution of observed coastal waters by typology and district
for c in cols:
d[c] = 100 * dfTypology[dfTypology[c] == 1].count() / dfTypology.count()
d.loc["All VP3", c] = 100 * len(dfTypology[dfTypology[c] == 1]) / len(dfTypology)
d.loc["All VP3", "n"] = len(dfTypology)
d.to_csv("output/coastal_VP_stats.csv")
d.rename(columns=dicts).loc["All VP3", :] # report in percent
for a, b in zip([dfEcoObs, sparse], [dfTypology, dfSparse]):
# df for storing number of observed coastal waters and yearly distribution by dummies
d = pd.DataFrame(a.count(), index=a.columns, columns=["n"]).astype(int)

# Yearly distribution of observed coastal waters by typology and district
for c in cols:
d[c] = 100 * b[b[c] == 1].count() / b.count()
d.loc["All VP3", c] = 100 * len(b[b[c] == 1]) / len(b)
d.loc["All VP3", "n"] = len(b)

# Rename columns to the full names of dummies
d = d.rename(columns=dicts)

if b is dfSparse:
VPstats["Sparse"] = d.loc["All VP3", :] # save distribution
else:
VPstats["All VP3"] = d.loc["All VP3", :] # save distribution
d.to_excel("output/coastal_VP_stats.xlsx")
VPstats # report distribution - sparse only includes Fjords and Bælthav (inner straits)

########################################################################################
# 2. Multivariate feature imputation
Expand Down

0 comments on commit 626aae2

Please sign in to comment.