Issue #2 - Exemplifying Simple Linear Regression
With the bites of modular SQL queries, Python DataTypes and The Gestalt Principles applied to DataViz.
Hey everyone! This is Josep, one more week 👋🏻
Today we have a new issue plenty of stuff 💥
Exemplifying Simple Linear Regression with a real-world example.
Imagine teaching a line to follow a trend like a dog follows a scent.
That's linear regression—finding the straight path through a data jungle.
First, we pick some data to work with. In this case, we will start with the classic Linear Regression dataset:
Height vs Weight
Next, we pick our tools: Gradient Descent, where we tweak the line's slope (rise/run) to fit snugly, or OLS (Ordinary Least Squares), where math magic gives us the perfect angle right away.
And for the coding wizards, Sci-Kit Learn in Python is like a data wand, conjuring up results with a flick of code.
And voilà, you've got a neat data story told in a single line! 📈🧙♂️✨
Final step?
Check the assumptions—our data should follow a linear relationship, should be independent, normally distributed, and equally varied.
You can read the whole example or you can find the Linear Regression cheat sheet in the following post.
🧩 Weekly Bites
#1. Exemplifying how to craft Reusable and Understandable SQL queries
When analyzing data, like Airbnb's listings in Barcelona, clarity is key!
Today let’s exemplify how to break down your complex SQL tasks into bite-sized areas: Neighborhoods, Listings, Hosts, and Key Metrics.
Instead of entangling these in a monstrous subquery spaghetti, use Common Table Expressions (CTEs) to keep things modular and maintainable.
CTEs allow you to build your query step by step, with a clear structure and named sections. It’s like creating a neat recipe for your data meal, where each ingredient is prepped separately before the final mix.
The result?
A comprehensive, yet simple-to-understand query that even your future self will thank you for.
Remember, use structured tables with descriptive names to guide you through the query, making it a breeze to follow and adjust as needed.
The final dish?
A delicious, digestible dataset that serves up exactly what you need!
You can go check the whole theory in the following article and you can find the cheat sheet in the following post.
#2. Data Types in a Nutshell: Booleans, Integers, and Floats
Welcome to Python's data type party, where Booleans, Integers, and Floats are the life of the code!
Booleans are your simple yes-or-no pals, always straight with a True or False.
Integers are whole numbers, solid and reliable, from 42 to a billion.
Floats are the dreamers with decimal points and exponents, like 3.1415 or 1.0e8.
Together, they form Python’s simplest data types and can morph into complex ones.
They mingle well, too; mix an Integer with a Float, and you get a Float, as Python loves to keep it precise.
Want to switch them up?
Cast away with int(), float(), and bool() functions to transform types.
Dive into these types, and you're ready to rock Python!
#3. The Art of Data Visualization: Gestalt Principles
Ever wonder why some charts send a clear message while others leave you scratching your head?
Enter the Gestalt Principles, the psychology behind the "Aha!" in data storytelling.
These principles guide our brain to see the forest and the trees in visual information.
Similarity: Our brain's a matchmaker, pairing elements that share features like shape or color. Use this to show related data points at a glance!
Closure: We love completing patterns, so enclose related data to say "these guys belong together."
Continuity: Our eyes love to follow the dots. Connect the points to guide viewers through the story of your data.
Proximity: Cozy elements are seen as a group. Space out unrelated data to avoid mix-ups.
Leverage these principles to turn your charts from confusing puzzles into enlightening insights.
It's not just about the data – it's about how you frame it!
And this is all for now!
Thank you for subscribing to my newsletter.
If you have something you want me to write or discuss, please comment or directly message me through my social media!
Remember you can also find me in X, Threads, Medium and LinkedIn 🤓
Great issue 🙌🙌