class HeightStatsResponse(BaseModel): mean: float median: float min_height: float max_height: float std_dev: float total_models: int
def percentile_distribution(self) -> Dict: """Get height percentiles""" if not self.heights: return {} percentiles = [10, 25, 50, 75, 90, 95, 99] return { f"p{p}": round(statistics.quantiles(self.heights, n=100, method='exclusive')[p-1], 1) for p in percentiles if p-1 < len(statistics.quantiles(self.heights, n=100, method='exclusive')) } height of male models
@app.post("/analyze/upload-models") async def upload_models(models: List[ModelInput]): """Upload multiple male models for analysis""" model_objects = [MaleModel( id=f"M{idx:04d}", name=m.name, height_cm=m.height_cm, agency=m.agency, category=m.category ) for idx, m in enumerate(models)] category=m.category ) for idx
analyzer = MaleModelHeightAnalyzer(model_objects) return { "message": f"Successfully uploaded {len(model_objects)} models", "basic_stats": analyzer.basic_statistics(), "category_fit": analyzer.category_fit() } @app.get("/analyze/height-stats", response_model=HeightStatsResponse) async def get_height_statistics(min_height: Optional[float] = None, max_height: Optional[float] = None): """Get aggregated height statistics""" # Implementation would query database pass 0)} - Mean Height: {stats.get('mean'
class ModelInput(BaseModel): name: str height_cm: float agency: Optional[str] = None category: Optional[str] = None
def generate_height_report(self) -> str: """Generate comprehensive height analysis report""" stats = self.basic_statistics() percentiles = self.percentile_distribution() outliers = self.height_outliers() category_fit = self.category_fit() report = f""" ===== MALE MODEL HEIGHT ANALYSIS REPORT ===== BASIC STATISTICS: - Total Models: {stats.get('count', 0)} - Mean Height: {stats.get('mean', 'N/A')} cm - Median Height: {stats.get('median', 'N/A')} cm - Height Range: {stats.get('min', 'N/A')} - {stats.get('max', 'N/A')} cm - Standard Deviation: {stats.get('std_dev', 'N/A')} cm PERCENTILE DISTRIBUTION: {chr(10).join([f' - {k}: {v} cm' for k, v in percentiles.items()])} CATEGORY SUITABILITY: - Suitable for Runway: {sum(1 for v in category_fit.values() if v['is_ideal_runway'])} models - Below Industry Minimum: {sum(1 for v in category_fit.values() if 'short_for_industry' in v['suitable_categories'])} models - Above Industry Maximum: {sum(1 for v in category_fit.values() if 'tall_for_industry' in v['suitable_categories'])} models OUTLIERS DETECTED: {len(outliers)} {chr(10).join([f' - {o["name"]}: {o["height_ft_in"]} ({o["height_cm"]} cm) - {o["deviation"]} average' for o in outliers])} """ return report import matplotlib.pyplot as plt import seaborn as sns import numpy as np class HeightVisualizer: """Create visualizations for model height analysis"""