Video summary
Data Science Project 33 : Customer Revenue Prediction App || Deploy On Heroku
Main summary
Key takeaways
Summary
The project builds an end-to-end application to predict whether a website visitor will complete a purchase and generate revenue. It uses shopping-site metadata to train a deep-learning model, serves predictions through a Django web app, and deploys the app to Heroku.
1. Customer revenue and project goal
- Customer revenue can come from one-time purchases or recurring payments, such as a car purchase or a subscription.
- The project predicts whether a visitor completes a purchase. The dataset’s
revenuefield is Boolean: True or False. - The dataset contains shopping website metadata. The presenter describes it as having 12,330 rows and 18 columns.
2. Data exploration and preparation
The presenter explores the data before training the model:
- Uses Pandas’
head,describe, andshapemethods, and checks for null values. - Explains several website analytics features:
- Bounce rate: The proportion of visitors who leave after entering the site rather than viewing additional pages.
- Exit rate: How often visitors leave from a particular page.
- Page value: An indication of how much a page contributes to visitors reaching the purchase, or “goal,” page.
- Notes that numeric columns can have very different ranges and says standardization or normalization may be useful.
- Checks for missing values and reports that the dataset has none.
- Uses a correlation heat map to examine relationships among numerical features. The presenter suggests considering removing one feature from a highly correlated pair, including pairs with strongly negative correlations.
- Examines categorical features with value counts and uses one-hot encoding (
get_dummies) for visitor type. - Converts the Boolean
weekendfeature to numeric values:Falseto0andTrueto1. - Separates the
revenuetarget from the input features. The presenter reports that the data has 15 columns after the described feature handling.
3. Deep-learning model
- Builds a TensorFlow/Keras sequential model using dense layers, with three hidden layers described in the project overview.
- Uses a two-unit output layer with softmax to represent the two classes: purchase completed or not completed.
- Compiles the model with the Adam optimizer and accuracy as a metric, then trains it using the prepared dataset.
- Reports approximately 83–84% accuracy, with training accuracy reaching around 90–91%. The presenter considers this acceptable for the project and suggests exploring other layers or configurations to improve the result.
- Saves the trained model so the Django application can load it for predictions.
4. Django web application
The app collects visitor information through an HTML form and returns the model’s prediction.
Setup and development
- Create a project directory and a separate environment for the project.
- Install dependencies from
requirements.txtusing pip. - Create a Django project and app. The examples use a project named
mysiteand an app namedpolls. - Run
python manage.py migrateto create Django’s database tables. - Run
python manage.py runserverto test the app locally.
Prediction flow
- The HTML page presents a form with inputs for the relevant visitor and session features.
- Django’s view receives the submitted request, stores the inputs, and assembles them into a DataFrame.
- The view loads the saved deep-learning model, calls its prediction function, and passes the result back to the page using the render context.
- The presenter distinguishes between a view, which handles requests and renders a page, and a helper function, which only manipulates data.
5. Preparing for production
Before deployment, the presenter says to:
- Add the required production files, including
requirements.txt,runtime.txt, and aProcfile. - Set Django’s
DEBUGsetting to False for production. - Configure
ALLOWED_HOSTSfor the intended domain or server. - Configure
STATIC_ROOTand collect static files for production. - Use the
Procfileto specify which commands Heroku should run. The example uses Gunicorn to serve the application through its WSGI entry point.
6. Deploying to Heroku
- Create a Heroku app.
- Add the Python buildpack in the app’s settings.
- Connect the Heroku app to a GitHub account and select the project repository.
- Choose the branch containing the code—the example uses
master—and start a manual deployment. - Let Heroku install the runtime and dependencies, collect and compress static files, and build the application.
- Open the deployed app and test it by entering sample form values.
The example deployment uses Python 3.7.10. The presenter notes that installing large dependencies such as TensorFlow can make deployment take longer. A sample submission produces a prediction that the customer will generate revenue.
Speakers and sources featured
- Speaker: One unnamed presenter or narrator; no other speakers are identifiable in the subtitles.
- Data source: Shopping-site metadata. The dataset link is mentioned but not named in the subtitles.
- Referenced tools and platforms: TensorFlow/Keras, Django, Heroku, GitHub, and Django documentation.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.