aboutsummaryrefslogtreecommitdiff
path: root/solver2.py
diff options
context:
space:
mode:
authorTa180m2020-05-02 15:28:34 -0500
committerTa180m2020-05-02 15:28:34 -0500
commit11f475fd15363b1dcc1ffa430bae70196dbc5254 (patch)
tree13f9a7e24561ec4e3f6a652d288b114fcb51c5ae /solver2.py
parent2485953be4d3b81ae65244b5b31cb5bf2b5f9524 (diff)
Fixed formatting
Diffstat (limited to 'solver2.py')
-rw-r--r--solver2.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/solver2.py b/solver2.py
index 4511d12..52e245e 100644
--- a/solver2.py
+++ b/solver2.py
@@ -147,8 +147,8 @@ class Learner(object):
print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}')
df = compose_df(prediction, extended_actual, correction_factor, new_index)
with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file:
- file.write(f'Beta: {beta}\nGamma: {gamma}\nR0: {beta/gamma}\n')
- file.write(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}\nActual I: {extended_actual[-1] * correction_factor}')
+ file.write(f'Beta, {beta}\nGamma, {gamma}\nR0, {beta/gamma}\n')
+ file.write(f'Predicted I, {prediction.y[1][-1] * int(args.popmodel)}\nActual I, {extended_actual[-1] * correction_factor}')
elif args.mode == 'SIR':
optimal = minimize(
loss_sir,
@@ -163,8 +163,8 @@ class Learner(object):
print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}')
df = compose_df(prediction, extended_actual, correction_factor, new_index)
with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file:
- file.write(f'Beta: {beta}\nGamma: {gamma}\nR0: {beta/gamma}\n')
- file.write(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}\nActual I: {extended_actual[-1] * correction_factor}')
+ file.write(f'Beta, {beta}\nGamma, {gamma}\nR0, {beta/gamma}\n')
+ file.write(f'Predicted I, {prediction.y[1][-1] * int(args.popmodel)}\nActual I, {extended_actual[-1] * correction_factor}')
elif args.mode == 'ESIR':
optimal = minimize(
loss_esir,
@@ -179,8 +179,8 @@ class Learner(object):
print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}')
df = compose_df(prediction, extended_actual, correction_factor, new_index)
with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file:
- file.write(f'Beta: {beta}\nGamma: {gamma}\nMu: {mu}\nR0: {beta/(gamma + mu)}\n')
- file.write(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}\nActual I: {extended_actual[-1] * correction_factor}')
+ file.write(f'Beta, {beta}\nGamma, {gamma}\nMu, {mu}\nR0, {beta/(gamma + mu)}\n')
+ file.write(f'Predicted I, {prediction.y[1][-1] * int(args.popmodel)}\nActual I, {extended_actual[-1] * correction_factor}')
elif args.mode == 'SEIR':
# exposed_data = self.load_exposed(self.country)
@@ -197,8 +197,8 @@ class Learner(object):
print(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}, Actual I: {extended_actual[-1] * correction_factor}')
df = compose_df(prediction, extended_actual, correction_factor, new_index)
with open(f'out/{args.disease}-{args.mode}-data.csv', 'w+') as file:
- file.write(f'Beta: {beta}\nGamma: {gamma}\nMu: {mu}\nSigma: {sigma}\nR0: {(beta * sigma)/((mu + gamma) * (mu + sigma))}\n')
- file.write(f'Predicted I: {prediction.y[1][-1] * int(args.popmodel)}\nActual I: {extended_actual[-1] * correction_factor}')
+ file.write(f'Beta, {beta}\nGamma, {gamma}\nMu, {mu}\nSigma, {sigma}\nR0, {(beta * sigma)/((mu + gamma) * (mu + sigma))}\n')
+ file.write(f'Predicted I, {prediction.y[1][-1] * int(args.popmodel)}\nActual I, {extended_actual[-1] * correction_factor}')
fig, ax = plt.subplots(figsize=(15, 10))
ax.set_title(f'{args.disease} cases over time ({args.mode} Model)')
df.plot(ax=ax)