DEV Community

Rock
Rock

Posted on

Building a Smart Capsule Wardrobe Generator with Python: A Data-Driven Approach to Outfit Recommendations

Building a personal style capsule doesn’t have to be complicated. Today, I want to share a simple, data-driven approach to curating a versatile wardrobe using Python.

Let’s say you have a list of clothing items, each with attributes like category, color, season, and formality. The goal is to automatically generate outfit combinations that are cohesive, season-appropriate, and mix-and-match friendly.

First, we’ll model each item as a dictionary:

items = [
    {"name": "White Blouse", "category": "top", "color": "white", "season": "all", "formality": "smart"},
    {"name": "Blue Jeans", "category": "bottom", "color": "blue", "season": "all", "formality": "casual"},
    {"name": "Black Dress", "category": "dress", "color": "black", "season": "fall", "formality": "formal"},
    {"name": "Floral Skirt", "category": "bottom", "color": "floral", "season": "spring", "formality": "smart"},
    {"name": "Knit Cardigan", "category": "layer", "color": "beige", "season": "fall", "formality": "casual"},
]
Enter fullscreen mode Exit fullscreen mode

Now, let’s create a function that filters items by season and formality, then pairs tops with bottoms (or dresses stand alone). We’ll also check color harmony using a simple rule: avoid clashing primary colors.

def generate_outfits(items, season="all", formality="any"):
    filtered = [item for item in items if (season == "all" or item["season"] == season or item["season"] == "all")]
    if formality != "any":
        filtered = [item for item in filtered if item["formality"] == formality]

    tops = [i for i in filtered if i["category"] == "top"]
    bottoms = [i for i in filtered if i["category"] == "bottom"]
    dresses = [i for i in filtered if i["category"] == "dress"]
    layers = [i for i in filtered if i["category"] == "layer"]

    outfits = []
    # Pair tops with bottoms
    for top in tops:
        for bottom in bottoms:
            # Simple color check: avoid same primary hue
            if top["color"] != bottom["color"]:
                outfit = [top, bottom]
                # Add a layer if available
                if layers:
                    outfit.append(layers[0])
                outfits.append(outfit)
    # Dresses can be standalone or with a layer
    for dress in dresses:
        outfit = [dress]
        if layers:
            outfit.append(layers[0])
        outfits.append(outfit)
    return outfits
Enter fullscreen mode Exit fullscreen mode

Running generate_outfits(items, season="fall", formality="smart") would return combinations like a white blouse with a floral skirt plus a cardigan, or the black dress with the cardigan.

This is a minimalist example, but you can extend it with color theory (e.g., complementary palettes), user preferences, or even a simple ML model to predict outfit ratings. The key is to treat your wardrobe as a dataset and let code do the heavy lifting.

If you want to see a full implementation with a small web interface, I’ve shared a sample on my GitHub. Until then, happy coding—and happy styling!

Top comments (2)

Collapse
 
frishay_ltd_a1987ef83aa1f profile image
Amelia

This really resonates with me—I've found that embracing the messy middle is where most of the real growth happens. Have you come across any particular strategies that helped you push through those tough spots?

Collapse
 
frishay_ltd_a1987ef83aa1f profile image
Amelia

Love this perspective! It's a good reminder that consistency often matters more than perfection. Do you have any rituals that keep you grounded when things get chaotic?