Automating Attendance-Based Revenue Predictions

Create a short program allowing a user to input attendance numbers and receive predicted concession revenue.

Learn how to build a simple program enabling ballpark employees to input attendance numbers and instantly receive concession revenue predictions. Understand the practical considerations and limitations of data-driven predictive modeling in real-world scenarios.

Key Insights

  • Demonstrates how to replace hard-coded predictive outputs with user-input functionality, allowing ballpark employees to independently enter attendance figures and automatically generate predicted concession revenues.
  • Clarifies that these predictions represent approximate estimates, emphasizing that actual concession revenue can vary significantly due to factors not captured by the simple predictive model.
  • Highlights best practices for programming usability, such as temporarily commenting out input prompts to avoid interruptions when running a notebook script from start to finish.

Note: These materials offer prospective students a preview of how our classes are structured. Students enrolled in this course will receive access to the full set of materials, including video lectures, project-based assignments, and instructor feedback.

Now imagine that we had a ballpark employee who wanted to be able to enter the numbers themselves. How could we do that? So instead of hard coding it, like "here's the answer for 25,000, " "here's the answer for 28,000"—you know, instead of having them come to the program and be like, "I want this number, I want this number, this number." Let's write you a very short program in this notebook that will handle that for you, that you can enter in yourself and leave us, the data scientists, alone. We can say that attendance for today equals—oh, let's make it an integer—the integer version of inputting the attendance: "What is the attendance today?" That'll give us the attendance for today.

And then we can say, okay, print out the attendance. The concessions, predicted concessions revenue for today is—let's put a little dollar sign. It’s a dollar figure.

And then we'll put in predict_concessions(attendance_for_today). We'll run this formula, this function, on whatever it is they give us here. Let's give that a try.

What is the attendance for today? Let's check some of the values we already entered. 25,000. Yep.

697,119. That works. And we can also try it with, you know, any value—35,000.

Data Analytics Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Well, that's quite a lot. Now, let's keep in mind this is not exact—these are predictions. These are not the actual values.

If we look at this attendance on this day, it was about halfway between 20,000 and 25,000. We’ll call it 22,500. And this one is like, you know, slightly different, right? Barely. I think it's slightly less.

And yet the concessions was way more that day. So this is a prediction. It is not the actual value.

And sometimes the value is going to be a little above our average prediction line here. And sometimes it's going to be below. We'll look at other ways to predict it as well.

But a prediction is always based on data. It's not necessarily going to be exact, just approximate. And getting the approximation as close as possible is a lot of what we're doing here.

Okay. We’ve got this concessions data. And for the sake of sanity, I would again like to comment that section out.

If I run this notebook, I'm not going to be bugged by the input boxes and interrupted running the notebook from it. Okay. Next, we're going to add this data of predicted concessions to our data frame.

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Machine Learning

Master Machine Learning with Hands-on Training. Use Python to Make, Modify, and Test Your Own Machine Learning Models.

Yelp Facebook LinkedIn YouTube Twitter Instagram