DEV Community

Cover image for Facials and Code: How to Create a Recommendation System with Python
dominik saenz
dominik saenz

Posted on

Facials and Code: How to Create a Recommendation System with Python

I know, you’re probably thinking: what on earth does skincare have to do with machine learning? But hear me out—because last weekend, I was sipping chamomile tea after a Bogota nano needling session (highly recommend, by the way) when it hit me: recommendation systems are like skin consultations, just with more Python and fewer essential oils.

That One Time I Got Too Many Options…

I’d been browsing facial treatments online, and honestly? Total analysis paralysis. You get bombarded with options—peels, microdermabrasion, hydro-whatever… it’s like choosing a Netflix show when you’re already exhausted. That’s when I realized: if salons had a proper recommendation system, we’d all be glowing and on time.

So, I decided to build one. With Python. From scratch. 😅

Key Ideas (But Make 'Em Chill)

If you're new to all this, don’t sweat it. You don’t need a PhD to start building smart tools. Just keep these five concepts in your back pocket:

  1. User-based filtering (a.k.a. "People like you also liked…")
  2. Item-based filtering (stuff that’s similar to what you picked)
  3. Cosine similarity (measuring how “close” preferences are)
  4. Pandas + Scikit-learn (your new BFFs)
  5. Cold start problem (when the system doesn’t know you yet)

So… How Do You Build One?

Let’s break it down casually, like we’re talking over a post-facial smoothie.

Step 1: Get Your Data

Start with a simple dataset — maybe a CSV of treatments and customer ratings.

import pandas as pd

# Load sample data
df = pd.read_csv('facials_reviews.csv')
print(df.head())
Enter fullscreen mode Exit fullscreen mode

Step 2: Create a User-Treatment Matrix

We'll pivot the table to make it easier to compare treatments.

# Create pivot table
pivot = df.pivot_table(index='user', columns='treatment', values='rating')
print(pivot.head())
Enter fullscreen mode Exit fullscreen mode

Step 3: Fill Missing Values and Compute Similarities

We'll use cosine similarity to find treatments that are "close" to each other.

from sklearn.metrics.pairwise import cosine_similarity

# Fill NaN values with 0
pivot_filled = pivot.fillna(0)

# Compute cosine similarity between treatments
similarities = cosine_similarity(pivot_filled.T)
similarity_df = pd.DataFrame(similarities, index=pivot.columns, columns=pivot.columns)
print(similarity_df.head())
Enter fullscreen mode Exit fullscreen mode

Step 4: Create a Recommendation Function

Now, let’s recommend treatments similar to one the user already liked.

def recommend_treatments(treatment_name, similarity_matrix, n=5):
    if treatment_name not in similarity_matrix.columns:
        print("Treatment not found in the data.")
        return []
    scores = similarity_matrix[treatment_name].sort_values(ascending=False)
    recommendations = scores.iloc[1:n+1]
    print(f"Top {n} treatments similar to {treatment_name}:")
    return recommendations

# Example usage
print(recommend_treatments("Hydrating Facial", similarity_df))
Enter fullscreen mode Exit fullscreen mode

Storytime: The Facial That Changed Everything

You know how some people get a gym membership and suddenly think they’re fitness coaches? Yeah. That was me after trying Facials Bogota il for the first time. I walked out of there glowing and convinced I could build an app that would match treatments to skin types based on reviews and reactions. Maybe I was overconfident... but also, maybe it’s exactly the kind of problem a rec system solves.

Real Talk: Why This Actually Helps

Let’s get practical here. Why should you care about all this?

  • You could help your friend’s spa get more bookings with smarter recommendations.
  • It’s a killer project to show off in job interviews—tech meets beauty? Big win.
  • You’ll understand how platforms like Netflix and Amazon actually work.
  • You’ll flex both your creative and logical muscles. Honestly? It’s fun.

And hey, if nothing else, you’ll sound super cool saying, “Oh yeah, I built a recommendation engine while getting lash extensions in Bogota. NBD.”

Final Thoughts (And A Tiny Nudge)

This week, carve out an hour to mess with some data. Use dummy reviews. Build something simple. Doesn’t have to be perfect. You’d be amazed what a bit of curiosity (and some pandas) can lead to.

And if you ever feel stuck? Get a facial. Seriously. Some of my best code ideas came to me mid-mask.

Go give it a try—your future self (and your skin) will thank you.


Let me know if you want a follow-up post on how to deploy this to a live site or turn it into a mobile app. Spoiler: it's easier than you'd think.

Top comments (0)