1597089600

In this article, we’ll explore and visualize a classic mathematical model used for modeling the spread of infectious disease: the SIR model.

The model splits the population into three compartments:

- The
**susceptible**(S): Individuals who are yet to contract the disease. - The** infectious** (I): Individuals who have contracted the disease and are capable of spreading it to susceptible individuals.
- The **recovered **®: Individuals who have recovered from the disease and became immune to it.

The sum of these compartments represents the number of individuals in the population, which is denoted by *N*:

Our goal is to model how these compartments fluctuate over time, and so we’ll consider them to be functions with respect to time:

The SIRD model considers another compartment (D) for **deceased**individuals.

In the SIR model, the transition between compartments takes the following path: susceptible → infectious → recovered. Each transition happens at a different rate.

The rate at which susceptible individuals come into contact with infectious individuals, thus contracting the disease, is called the **infectious rate **(*β*). Once infected, the rate at which they recover is called the **recovery rate **(*γ*).

The SIRS model takes into account the possibility of recovered individuals becoming susceptible again, due to loss of immunity.

To model the fluctuation of the population compartments, we need to derive formulas to express the way they change with respect to time.

Let’s consider an initial moment _tₒ. _Each day, an infectious individual spreads the disease to a fraction of the susceptible individuals, which become infectious themselves.

At some moment *t*, the number of new infectious individuals is:

And so, by subtracting the new infectious individuals from the initially susceptible ones, we obtain:

To get the instantaneous rate of change, we divide by (_t- tₒ) _and take the limit as *t* approaches *tₒ*:

This limit is nothing but the derivative of *S* with respect to time at some point *tₒ*. And so:

Again, let’s consider an initial moment _tₒ. _Each day, new individuals become infectious, and some of the already infectious recover.

We saw previously that:

Furthermore,

By combining these observations, we can write:

To get the derivative of *I*, by dividing by (_t- tₒ) _and taking the limit as _t _→ _tₒ, _we get:

which means that:

Same as before, let’s consider an initial moment _tₒ. _Each day, a part of the infectious individuals recover.

We saw that:

And so

As we did previously, we’ll divide by (_t- tₒ) _and take the limit as _t _→ _tₒ _to get the derivative of *R*:

which leads us to:

Putting the three formulas together gives us the SIR model system of ODEs:

Or, by letting

the system becomes:

Put in this form, we can simply treat the system as an ODE.

We can observe that this system above is non-linear (analytic solutions can, however, be found in an implicit form). Nonetheless, since our purpose is to visualize the model, we’ll resort to a numerical method to solve the system.

The Euler method is a procedure for solving ordinary differential equations numerically given an initial value.

For our case, we’ll consider the number of individuals in each compartment to be known at *tₒ = 0*:

The Euler method consists of iterating through

where *h* is the chosen step. By performing this, we can approximate

Let’s write some code to find and plot the solution:

```
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
class SIR:
def __init__(self, beta, gamma, S0, I0, R0):
self.beta = beta
self.gamma = gamma
self.y0 = np.array([S0, I0, R0])
self.N = sum(self.y0)
def F(self, y):
S, I, R = y
return np.array([ -self.beta * I * S / self.N, self.beta * I * S / self.N - self.gamma * I, self.gamma * I])
def euler(self, tmax, h):
y0 = self.y0
t = 0
while t <= tmax:
y = y0 + h * self.F(y0)
yield t, y
y0 = y
t += h
def plot(self, days):
X, Y = [], []
h = .2
for t, y in self.euler(days, h):
X.append(t)
Y.append(y)
fig, ax = plt.subplots()
ax.set_xlim(0, days)
ax.set_ylim(0, self.N)
S_line, = ax.plot(0, 0, color='#4FA1E4')
I_line, = ax.plot(0, 0, color='#FE2020')
R_line, = ax.plot(0, 0, color='#40D752')
def iter(i):
S_line.set_xdata(X[:i])
I_line.set_xdata(X[:i])
R_line.set_xdata(X[:i])
Yt = np.transpose(Y[:i])
S_line.set_ydata(Yt[0])
I_line.set_ydata(Yt[1])
R_line.set_ydata(Yt[2])
return S_line, I_line, R_line,
anim = FuncAnimation(fig, func=iter, frames=range(1, int(days/h)), interval=50, repeat=False)
plt.xlabel('Day')
plt.ylabel('Population')
plt.legend(['Susceptible', 'Infected', 'Recovered'], frameon=False, loc='upper center', ncol=3)
plt.title('SIR model')
plt.show()
```

#simulation #mathematical-modeling #visualization #mathematics #differential-equations

1597089600

In this article, we’ll explore and visualize a classic mathematical model used for modeling the spread of infectious disease: the SIR model.

The model splits the population into three compartments:

- The
**susceptible**(S): Individuals who are yet to contract the disease. - The** infectious** (I): Individuals who have contracted the disease and are capable of spreading it to susceptible individuals.
- The **recovered **®: Individuals who have recovered from the disease and became immune to it.

The sum of these compartments represents the number of individuals in the population, which is denoted by *N*:

Our goal is to model how these compartments fluctuate over time, and so we’ll consider them to be functions with respect to time:

The SIRD model considers another compartment (D) for **deceased**individuals.

In the SIR model, the transition between compartments takes the following path: susceptible → infectious → recovered. Each transition happens at a different rate.

The rate at which susceptible individuals come into contact with infectious individuals, thus contracting the disease, is called the **infectious rate **(*β*). Once infected, the rate at which they recover is called the **recovery rate **(*γ*).

The SIRS model takes into account the possibility of recovered individuals becoming susceptible again, due to loss of immunity.

To model the fluctuation of the population compartments, we need to derive formulas to express the way they change with respect to time.

Let’s consider an initial moment _tₒ. _Each day, an infectious individual spreads the disease to a fraction of the susceptible individuals, which become infectious themselves.

At some moment *t*, the number of new infectious individuals is:

And so, by subtracting the new infectious individuals from the initially susceptible ones, we obtain:

To get the instantaneous rate of change, we divide by (_t- tₒ) _and take the limit as *t* approaches *tₒ*:

This limit is nothing but the derivative of *S* with respect to time at some point *tₒ*. And so:

Again, let’s consider an initial moment _tₒ. _Each day, new individuals become infectious, and some of the already infectious recover.

We saw previously that:

Furthermore,

By combining these observations, we can write:

To get the derivative of *I*, by dividing by (_t- tₒ) _and taking the limit as _t _→ _tₒ, _we get:

which means that:

Same as before, let’s consider an initial moment _tₒ. _Each day, a part of the infectious individuals recover.

We saw that:

And so

As we did previously, we’ll divide by (_t- tₒ) _and take the limit as _t _→ _tₒ _to get the derivative of *R*:

which leads us to:

Putting the three formulas together gives us the SIR model system of ODEs:

Or, by letting

the system becomes:

Put in this form, we can simply treat the system as an ODE.

We can observe that this system above is non-linear (analytic solutions can, however, be found in an implicit form). Nonetheless, since our purpose is to visualize the model, we’ll resort to a numerical method to solve the system.

The Euler method is a procedure for solving ordinary differential equations numerically given an initial value.

For our case, we’ll consider the number of individuals in each compartment to be known at *tₒ = 0*:

The Euler method consists of iterating through

where *h* is the chosen step. By performing this, we can approximate

Let’s write some code to find and plot the solution:

```
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
class SIR:
def __init__(self, beta, gamma, S0, I0, R0):
self.beta = beta
self.gamma = gamma
self.y0 = np.array([S0, I0, R0])
self.N = sum(self.y0)
def F(self, y):
S, I, R = y
return np.array([ -self.beta * I * S / self.N, self.beta * I * S / self.N - self.gamma * I, self.gamma * I])
def euler(self, tmax, h):
y0 = self.y0
t = 0
while t <= tmax:
y = y0 + h * self.F(y0)
yield t, y
y0 = y
t += h
def plot(self, days):
X, Y = [], []
h = .2
for t, y in self.euler(days, h):
X.append(t)
Y.append(y)
fig, ax = plt.subplots()
ax.set_xlim(0, days)
ax.set_ylim(0, self.N)
S_line, = ax.plot(0, 0, color='#4FA1E4')
I_line, = ax.plot(0, 0, color='#FE2020')
R_line, = ax.plot(0, 0, color='#40D752')
def iter(i):
S_line.set_xdata(X[:i])
I_line.set_xdata(X[:i])
R_line.set_xdata(X[:i])
Yt = np.transpose(Y[:i])
S_line.set_ydata(Yt[0])
I_line.set_ydata(Yt[1])
R_line.set_ydata(Yt[2])
return S_line, I_line, R_line,
anim = FuncAnimation(fig, func=iter, frames=range(1, int(days/h)), interval=50, repeat=False)
plt.xlabel('Day')
plt.ylabel('Population')
plt.legend(['Susceptible', 'Infected', 'Recovered'], frameon=False, loc='upper center', ncol=3)
plt.title('SIR model')
plt.show()
```

#simulation #mathematical-modeling #visualization #mathematics #differential-equations

1620729846

Can you use WordPress for anything other than blogging? To your surprise, yes. WordPress is more than just a blogging tool, and it has helped thousands of websites and web applications to thrive. The use of WordPress powers around 40% of online projects, and today in our blog, we would visit some amazing uses of WordPress other than blogging.

**What Is The Use Of WordPress?**

WordPress is the most popular website platform in the world. It is the first choice of businesses that want to set a feature-rich and dynamic Content Management System. So, if you ask what WordPress is used for, the answer is – everything. It is a super-flexible, feature-rich and secure platform that offers everything to build unique websites and applications. Let’s start knowing them:

**1. Multiple Websites Under A Single Installation**

WordPress Multisite allows you to develop multiple sites from a single WordPress installation. You can download WordPress and start building websites you want to launch under a single server. Literally speaking, you can handle hundreds of sites from one single dashboard, which now needs applause.

It is a highly efficient platform that allows you to easily run several websites under the same login credentials. One of the best things about WordPress is the themes it has to offer. You can simply download them and plugin for various sites and save space on sites without losing their speed.

**2. WordPress Social Network**

WordPress can be used for high-end projects such as Social Media Network. If you don’t have the money and patience to hire a coder and invest months in building a feature-rich social media site, go for WordPress. It is one of the most amazing uses of WordPress. Its stunning CMS is unbeatable. And you can build sites as good as Facebook or Reddit etc. It can just make the process a lot easier.

To set up a social media network, you would have to download a WordPress Plugin called BuddyPress. It would allow you to connect a community page with ease and would provide all the necessary features of a community or social media. It has direct messaging, activity stream, user groups, extended profiles, and so much more. You just have to download and configure it.

If BuddyPress doesn’t meet all your needs, don’t give up on your dreams. You can try out WP Symposium or PeepSo. There are also several themes you can use to build a social network.

**3. Create A Forum For Your Brand’s Community**

Communities are very important for your business. They help you stay in constant connection with your users and consumers. And allow you to turn them into a loyal customer base. Meanwhile, there are many good technologies that can be used for building a community page – the good old WordPress is still the best.

It is the best community development technology. If you want to build your online community, you need to consider all the amazing features you get with WordPress. Plugins such as BB Press is an open-source, template-driven PHP/ MySQL forum software. It is very simple and doesn’t hamper the experience of the website.

Other tools such as wpFoRo and Asgaros Forum are equally good for creating a community blog. They are lightweight tools that are easy to manage and integrate with your WordPress site easily. However, there is only one tiny problem; you need to have some technical knowledge to build a WordPress Community blog page.

**4. Shortcodes**

Since we gave you a problem in the previous section, we would also give you a perfect solution for it. You might not know to code, but you have shortcodes. Shortcodes help you execute functions without having to code. It is an easy way to build an amazing website, add new features, customize plugins easily. They are short lines of code, and rather than memorizing multiple lines; you can have zero technical knowledge and start building a feature-rich website or application.

There are also plugins like Shortcoder, Shortcodes Ultimate, and the Basics available on WordPress that can be used, and you would not even have to remember the shortcodes.

**5. Build Online Stores**

If you still think about why to use WordPress, use it to build an online store. You can start selling your goods online and start selling. It is an affordable technology that helps you build a feature-rich eCommerce store with WordPress.

WooCommerce is an extension of WordPress and is one of the most used eCommerce solutions. WooCommerce holds a 28% share of the global market and is one of the best ways to set up an online store. It allows you to build user-friendly and professional online stores and has thousands of free and paid extensions. Moreover as an open-source platform, and you don’t have to pay for the license.

Apart from WooCommerce, there are Easy Digital Downloads, iThemes Exchange, Shopify eCommerce plugin, and so much more available.

**6. Security Features**

WordPress takes security very seriously. It offers tons of external solutions that help you in safeguarding your WordPress site. While there is no way to ensure 100% security, it provides regular updates with security patches and provides several plugins to help with backups, two-factor authorization, and more.

By choosing hosting providers like WP Engine, you can improve the security of the website. It helps in threat detection, manage patching and updates, and internal security audits for the customers, and so much more.

#use of wordpress #use wordpress for business website #use wordpress for website #what is use of wordpress #why use wordpress #why use wordpress to build a website

1623906928

Model Stacking is a way to improve model predictions by combining the outputs of multiple models and running them through another machine learning model called a meta-learner. It is a popular strategy used to win kaggle competitions, but despite their usefulness they’re rarely talked about in data science articles — which I hope to change.

Essentially a stacked model works by running the output of multiple models through a “meta-learner” (usually a linear regressor/classifier, but can be other models like decision trees). The meta-learner attempts to minimize the weakness and maximize the strengths of every individual model. The result is usually a very robust model that generalizes well on unseen data.

The architecture for a stacked model can be illustrated by the image below:

#tensorflow #neural-networks #model-stacking #how to use “model stacking” to improve machine learning predictions #model stacking #machine learning

1594910524

In the time of COVID-19 the need for accurate predictions of both long-term and short-term evolution of epidemics has been made apparent. We propose to compare **traditional** **model-based** methods, such as Susceptible Infected Recovered model (SIR), with **emerging** **data-driven** models including recurrent neural networks (RNN) for time-series prediction. We compare these methods on influenza (flu) data which is more robust and then examine applications to COVID-19 data.

Our findings show that (i) Commonly used **model-based** methods (i.e. **SIR**) and **data-driven RNN** methods (i.e. vanilla-LSTM) do not provide accurate long-term predictions on flu data and require a constant update to be more accurate. (ii) We identify the **data-driven** **Seq2Seq RNN** model as the most promising data-driven approach for both short term and long term predictions. Since epidemics follow similar patterns, we propose that **Seq2Seq trained on flu data could be used as a model for COVID-19**. Such a model will require only a ‘few-shots’ retraining (several samples) to provide predictions.

right source:frankundfrei, via pixabay (CC0)

Code files are available from: https://github.com/shlizee/Seq2SeqEpidemics

The CDC has surveillance systems in place for tracking the seasonal spread of influenza. One such network is the US Outpatient Influenza-like Illness Surveillance Network (ILINet). Each week, outpatient healthcare providers in ILINET report the number of patients with **influenza-like illness (ILI) by age group.** ILINet provides data on a national, state, and regional level as well as percentages of visits due to ILI weighted by population and unweighted. **We will be looking at the national level data for weekly case counts.**

Plotting the data we can see that influenza epidemics follow a similar pattern. Furthermore, we can see that we are dealing with time-series which exhibits a yearly seasonal pattern. To make the data easier to work with, we change the format to be seasonal (i.e. looking at each yearly period with a center at week 14 — first week of April ).

Flu data from ILINet. Right: 2018–19 flu season number of cases used for evaluation of models

```
> python3 fludata.py
```

#time-series-forecasting #epidemic-prediction #neural-networks #data-science #sir-model

1617331277

The Association of Data Scientists (AdaSci), the premier global professional body of data science and ML practitioners, has announced a hands-on workshop on deep learning model deployment on February 6, Saturday.

Over the last few years, the applications of deep learning models have increased exponentially, with use cases ranging from automated driving, fraud detection, healthcare, voice assistants, machine translation and text generation.

Typically, when data scientists start machine learning model development, they mostly focus on the algorithms to use, feature engineering process, and hyperparameters to make the model more accurate. However, model deployment is the most critical step in the machine learning pipeline. As a matter of fact, models can only be beneficial to a business if deployed and managed correctly. Model deployment or management is probably the most under discussed topic.

In this workshop, the attendees get to learn about ML lifecycle, from gathering data to the deployment of models. Researchers and data scientists can build a pipeline to log and deploy machine learning models. Alongside, they will be able to learn about the challenges associated with machine learning models in production and handling different toolkits to track and monitor these models once deployed.

#hands on deep learning #machine learning model deployment #machine learning models #model deployment #model deployment workshop