TensorFlow, Neural Networks, Regression : Predicting Real Estate Prices

Amine Charot
6 min readJan 4, 2024

--

Hey there, fellow learners! Today, I’m excited to share my very first adventure into the world of machine learning. Picture this: predicting house prices. It may sound complex, but trust me, it’s like solving a puzzle, and I’m here to walk you through my journey!

Machine Learning & Deep Learning :

Before delving into the nitty-gritty, let’s tackle a fundamental question: What exactly is Machine Learning? In essence, it’s the art of transforming things into numbers and uncovering patterns within these numerical representations. While it might sound like a complex dance, the computer takes the lead in this choreography, guided by the steps of code and mathematics.

Now, how does this differ from our traditional approach to development?

In the conventional method, we provide input, which consists of predefined rules and data, and await an output. For example, crafting a pizza involves giving the ingredients and following a set of rules (tomatoes first, then cheese, into the oven), resulting in the desired output — a delicious pizza.

Now with Machine Learning, we will have :

Enter Machine Learning, where the paradigm shifts: when presented with the ingredients and the pizza itself, the output becomes the rules for preparing the pizza. It’s a reversal of roles, and you might wonder, why opt for Machine Learning? Consider this: If you were tasked with building a car, could you possibly enumerate every single rule governing its construction?

Navigating the Difference: Machine Learning vs. Deep Learning

  • Machine Learning: Embraces a broader spectrum of algorithms where computers learn to perform tasks without explicit programming. It encompasses various techniques like decision trees, support vector machines, and clustering algorithms, making it versatile for a range of applications.
  • Deep Learning: A subset of Machine Learning, Deep Learning involves neural networks with multiple layers (deep neural networks). It excels at handling vast amounts of unstructured data, making it particularly effective in image recognition, natural language processing, and complex pattern recognition.

What are Neural Networks ?

Now, let’s demystify Neural Networks. Picture it as a three-tiered structure:

  1. Input Layers: This is where the data enters.
  2. Hidden Layers: The realm where patterns are discerned and learned.
  3. Output Layer: The final output, representing the acquired knowledge.

How does it work ?

How does this intricate system operate? It all begins with our data, converted into numerical form. We then set our Neural Network into action, and voila — we obtain numbers that can be translated back into a comprehensible representation. It’s like a digital symphony, where the notes (data) transform into a harmonious melody (learned patterns) with the help of our Neural Network conductor.

And TensorFlow in the story I saw it in the title ? As you see, TensorFlow is devided to two things Tensor and Flow :

Tensors :

Here’s a quick rundown of what makes TensorFlow stand out:

Versatility in Languages:

  • Write lightning-fast deep learning code in Python or your preferred language.
  • Compatible with GPUs and TPUs for accelerated performance. Ready-

Made Models at Your Fingertips:

  • Access TensorFlow Hub, a treasure trove of pre-built deep learning models.
  • Save time by leveraging expertly crafted models for your projects.

Holistic Machine Learning Toolkit:

  • From data preprocessing to model deployment, TensorFlow covers it all.
  • A complete stack for your machine learning journey.

Open-Source Evolution:

  • Originally a secret weapon at Google, now TensorFlow is open-source.
  • Available to the entire community, making machine learning accessible to all.

Well Enough talking, let’s build our first model of Neural Network using TensorFlow

Neural Network Regression : Predict a house price

Let me first show you the notebook I have write, take your time read it, I left some comments on how I did it. After that I have some explanation !

Data Exploration and Preparation:

So, I stumbled upon this cool dataset with loads of info about houses. Stuff like when they were sold, how old they are, and how far they are from the nearest MRT station — you know, the important stuff. Before getting into the fancy machine learning stuff, I had to tidy up. Dropped some unnecessary info and made sure everything was playing nice together.

Building the First Model:

Now, let’s talk about the brain of the operation — the neural network. Sounds super sci-fi, right? But no worries, it’s just a fancy term for a smart computer that learns from data. My first attempt at this was pretty basic — just a few layers here and there. Think of it like the computer trying to learn the pattern of how all these house features relate to their prices.

Model Improvement Plan:

But hey, learning is a journey, right? I wanted my computer buddy to get even smarter. So, I made a plan. Added more layers, changed how it learns a bit, and let it study longer. It was like giving it a turbo boost! Each time I did this, the computer got better at predicting prices.

Results and Evaluation:

Now, let’s get to the good stuff — did it work? Well, kinda! There were a few bumps along the way, but I kept an eye on some numbers that tell me how well my computer buddy is doing. Things like “Mean Absolute Error” — basically, how close it gets to the real prices. And guess what? My third try was the charm! The computer was pretty good at guessing prices — not perfect, but really close.

Final Model and Predictions:

Once I had a good model, I put it to the test. I let it predict prices for some houses it had never seen before. It was like playing fortune teller, but with numbers. The computer did a decent job! I even made a graph to show off — the real prices vs. what the computer guessed. It was like magic!

Reflection and Next Steps:

Now, looking back, I see that learning this stuff is like leveling up in a game. You face challenges, you learn, and you get better. There’s still so much to explore — like trying fancier models and tweaking things here and there. I’m just getting started on this awesome journey!

Conclusion:

So, here’s the scoop — you don’t need to be a genius to dive into machine learning. It’s like teaching a computer to understand patterns. If I can do it, you definitely can too! If you’re curious, grab a dataset, give it a try, and let me know how it goes. Learning together is way more fun!

In the vast landscape of Machine Learning and Deep Learning, this is just the tip of the iceberg. As we journey deeper, we uncover the beauty of algorithms, the magic of Neural Networks, and the boundless possibilities they unlock. Stay tuned for more revelations in this exciting world of digital exploration!

--

--