In this first practical application assignment of the program, you will seek to answer the question, “Will a customer accept the coupon?” The goal of this project is to use what you know about visualizations and probability distributions to distinguish between customers who accepted a driving coupon versus those that did not. Use the Practical Application 1 Jupyter Notebook Links to an external site.to complete this assignment.
This data comes to us from the UCI Machine Learning repository and was collected via a survey on Amazon Mechanical Turk. The survey describes different driving scenarios, including the destination, current time, weather, passenger, etc., and then asks people whether they will accept the coupon if they are the driver. Answers given that the users will drive there “right away” or “later before the coupon expires” are labeled as “Y = 1”, and answers “no, I do not want the coupon” are labeled as “Y = 0”. There are five different types of coupons—less expensive restaurants (under $20), coffee houses, carry out and take away, bars, and more expensive restaurants ($20–$50).
Your final product should be a brief report that highlights the differences between customers who did and did not accept the coupons. To explore the data, you will utilize your knowledge of plotting, statistical summaries, and visualization using Python. You will publish your findings in a public facing GitHub repository as your first portfolio piece.
Learning outcomes achieved by this module's learning activities:
- Navigate files and directories using your terminal
- Create, alter, and delete files using your terminal
- Create .git repositories locally in your terminal
- Create GitHub repositories online
- Connect local .git repositories to GitHub
- Use the add, commit, push commands to update work in a remote repository
- Apply exploratory data analysis, plotting, statistical summarization, and data visualization skills and techniques to a machine learning problem.
so we have:
The goal of this project is to use what you know about visualizations and probability distributions to distinguish between customers who accepted a driving coupon versus those that did not.
Then, First:
Follow these steps to clone the repository and run it in Jupyter Notebook:
-
Clone the repository
Open a terminal and clone the repository using Git:
git clone https://github.com/gitcoffee/coupons
Navigate to the project directory:
cd nombre-del-repositorio -
Create a virtual environment (optional, but recommended)
Create a virtual environment to manage the project's dependencies:
python -m venv env
Activate the virtual environment:
-
On Windows:
.\env\Scripts\activate
-
On macOS/Linux:
source env/bin/activate
-
-
Install dependencies
Install the required dependencies using
pip:pip install -r requirements.txt
-
Install Jupyter Notebook (if not installed)
If you don't have Jupyter Notebook installed, install it with:
pip install notebook
-
Start Jupyter Notebook
Launch Jupyter Notebook from the terminal:
jupyter notebook
This will open Jupyter in your web browser.
-
Open the notebook
In the Jupyter Notebook interface, navigate to the project folder and open the
.ipynbfile you want to run. -
Run the notebook
Execute the notebook cells by clicking the Run button or using the
Shift + Enterkeyboard shortcut.
To collapse all the code:
And the result is:
Now you will find the solutions and outputs to the questions posed, as well as:
Based on the observations obtained, several hypotheses can be proposed about drivers who accepted bar coupons. The following hypotheses are detailed based on the different segments of analyzed data:
-
Frequency of Bar Visits and Age:
- Drivers who never go to the bar or go less than once a month and are 21 years old or younger tend to accept coupons at a rate of 59.4%.
- Drivers who go to the bar between 1 and 8 times a month or more, and are 26 years old or older, tend to accept coupons at a rate of 62.15%.
Hypothesis: Younger drivers who do not frequent bars have a lower coupon acceptance rate compared to older drivers who visit bars more regularly.
-
Frequency of Bar Visits, Companions, and Occupation:
- Drivers who go to the bar between 1 and 8 times a month or more, are accompanied by friends, a partner, or alone, and have occupations other than farming, fishing, or forestry, accept coupons at a rate of 62.31%.
Hypothesis: The coupon acceptance rate is higher among drivers who frequent bars and do not have occupations related to agriculture, fishing, or forestry.
-
Frequency of Bar Visits, Companions, and Marital Status:
- Drivers who go to the bar between 1 and 8 times a month or more, are accompanied by friends, a partner, or alone, and are not widowed, accept coupons at a rate of 62.31%.
Hypothesis: The marital status of drivers (excluding widowed individuals) does not seem to have a significant impact on coupon acceptance among those who frequent bars.
-
Frequency of Bar Visits and Age (Different Group):
- Drivers who go to the bar between 1 and 8 times a month or more, and are 21, 26, or under 21 years old, accept coupons at a rate of 62.81%.
Hypothesis: Younger drivers (up to 26 years old) who frequent bars tend to accept coupons at a higher rate compared to the general young segment.
-
Frequency of Restaurant Visits and Income Level:
- Drivers who visit restaurants between 4 and 8 times a month or more, and have an annual income between $12,500 and $49,999, accept coupons at a rate of 60.07%.
Hypothesis: Drivers with moderate to low incomes who frequently visit restaurants also show a higher tendency to accept coupons.
The acceptance of bar coupons seems to be influenced by several factors, such as the frequency of bar visits, age, companions, occupation, marital status, and income level. Overall, it is observed that:
- Drivers who frequent bars (1-8 times a month or more) tend to accept coupons at higher rates.
- Younger drivers who do not frequent bars have a lower acceptance rate compared to older drivers who do.
- Occupations unrelated to agriculture, fishing, or forestry, and the absence of widowhood do not significantly affect the acceptance rate among drivers who frequent bars.
- Drivers with moderate to low incomes who frequently visit restaurants also show a higher tendency to accept coupons.
These hypotheses can serve as a basis for marketing strategies aimed at increasing the coupon acceptance rate among different segments of drivers.
This covariance matrix can help understand the interdependencies between variables in the dataset and identify patterns that may be important for further analysis or predictive modeling.
The result is:
The covariance matrix shows the relationships between variables in the dataset. Here are some key points:
-
Strong Negative Covariances:
temperaturewith many variables (destination,weather,Bar), indicating that as the temperature increases, these variables tend to decrease and vice versa.
-
Strong Positive Covariances:
destinationandtime(0.622): Destinations and time have a positive relationship, suggesting that certain combinations of destinations and time are more common together.couponanddestination(0.150): There is a positive relationship between coupons and destinations.
-
Notable Relationships:
ageandmaritalStatus(0.447): Age has a positive relationship with marital status.educationandoccupation(0.133): Education has a positive relationship with occupation.toCoupon_GEQ25minanddirection_same(0.111): There is a small positive relationship between the time to the coupon and the same direction.
You can find the detailed to summary of findings and link to notebook in the prompt_solution.ipynb file.
If you want to contribute to the project, (Note: Only the professor):
This project is licensed under the MIT License - see the LICENSE file for details.


