aboutsummaryrefslogtreecommitdiff
path: root/solver2.py
diff options
context:
space:
mode:
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)