Reader small image

You're reading from  Hands-On Predictive Analytics with Python

Product typeBook
Published inDec 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789138719
Edition1st Edition
Languages
Right arrow
Author (1)
Alvaro Fuentes
Alvaro Fuentes
author image
Alvaro Fuentes

Alvaro Fuentes is a senior data scientist with a background in applied mathematics and economics. He has more than 14 years of experience in various analytical roles and is an analytics consultant at one of the ‘Big Three' global management consulting firms, leading advanced analytics projects in different industries like banking, technology, and consumer goods. Alvaro is also an author and trainer in analytics and data science and has published courses and books, such as 'Become a Python Data Analyst' and 'Hands-On Predictive Analytics with Python'. He has also taught data science and related topics to thousands of students both on-site and online through different platforms such as Springboard, Simplilearn, Udemy, and BSG Institute, among others.
Read more about Alvaro Fuentes

Right arrow

Implementing a Model with Dash

This is the penultimate chapter of the book. It is about the last phase of the predictive analytics process—model communication and deployment. The point of building a model is using it in some way to solve a problem, so we always need to implement the model; despite this necessity, this stage is often forgotten and overlooked in many courses and resources on machine learning and predictive modeling. This chapter aims to fill this gap.

First, we will talk about the model communication and deployment phase—we will explain the main ways in which we implement a predictive analytics solution—a technical report, a feature of an existing application, or an analytic application. In this section, we talk about some important tips and considerations when communicating the results of a predictive modeling project.

In the following sections...

Technical requirements

  • Python 3.6 or higher
  • Jupyter Notebook
  • Recent versions of the following Python libraries: NumPy, pandas, matplotlib, Seaborn, scikit-learn, and Keras
  • Basic libraries for Dash (see the next section for installation instructions)

Model communication and/or deployment phase

The goal of building a predictive model is to put it to use to solve a business problem. This is the step that many books and courses on the subject of predictive analytics and machine learning don't talk about. In the end, we don't analyze data and build predictive models just for the sake of building them; when applying these techniques in the real world, we always have a goal in mind.

There are three main ways in which a predictive analytics project can be implemented:

  • A technical report
  • A feature of an existing product
  • An analytic application

Let's briefly discuss these three common cases.

Using a technical report

Often, you will be asked to produce a technical...

Introducing Dash

In this section, we will provide a brief, hands-on introduction to the Dash library by building a couple of simple applications. This will, of course, be an incomplete introduction, as we will be learning just enough to be able to show how we can produce a prototype of an application that can serve the predictions of one of the models we have created.

What is Dash?

This is the last library we will talk about in this book. Dash is a Python framework for building web applications quickly and easily, without knowing JavaScript, CSS, HTML, server-side programming, or related technologies that belong to the web development world. Let's look at some of its features:

  • Framework for building data visualization...

Implementing a predictive model as a web application

Now we know the basics of building an interactive web application with Dash, we are ready to build an application to deploy our model so it can be used to make predictions. This will be a very simple and basic prototype, but, as we said before, building an enterprise-level application will take a team of engineers many weeks.

Even though this application will be very simple, I have delivered similar minimal applications to my clients in my consulting practice (doing it with either Python's Dash or R's Shiny), and they have found it very useful, so these applications can actually be used in real-world projects.

Producing the predictive model objects

Let&apos...

Summary

In this chapter, we learned the basics of Dash and showed how to deploy a model with a hands-on example. Some key points that we discussed were the model implementation phase, three main ways in which a predictive analytics report can be implemented, use of predictive analytics models, and how to use trained models to build an application.

We also learned how to use the Dash framework and Plotly library to build an application. And we learned how to provide interactivity in Dash by writing decorators in functions that take inputs and modify outputs for the application.

Finally, always keep in mind that the point of predictive analytics is to solve problems. When deploying a predictive model, think about the users of your solution first and how to build the solution that works best for them.

Further reading

  • Knaflic, C N (2015). Storytelling with data: A data visualization guide for business professionals by John Wiley & Sons, Inc.
  • Provost, F, & Fawcett, T (2013). Data Science for Business: What you need to know about data mining and data-analytic thinking by O'Reilly Media.
  • Siegel, E. (2013). Predictive analytics: The power to predict who will click, buy, lie, or die, by John Wiley and Sons, Inc.
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Predictive Analytics with Python
Published in: Dec 2018Publisher: PacktISBN-13: 9781789138719
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Alvaro Fuentes

Alvaro Fuentes is a senior data scientist with a background in applied mathematics and economics. He has more than 14 years of experience in various analytical roles and is an analytics consultant at one of the ‘Big Three' global management consulting firms, leading advanced analytics projects in different industries like banking, technology, and consumer goods. Alvaro is also an author and trainer in analytics and data science and has published courses and books, such as 'Become a Python Data Analyst' and 'Hands-On Predictive Analytics with Python'. He has also taught data science and related topics to thousands of students both on-site and online through different platforms such as Springboard, Simplilearn, Udemy, and BSG Institute, among others.
Read more about Alvaro Fuentes