AI/ML
Prediction Distribution Card - Model Output Analysis
Visualize prediction distributions and output ranges from ML models. Analyze prediction confidence scores and classification probabilities.
Prediction Distribution Card
The Prediction Distribution Card displays the distribution of model predictions, helping teams identify prediction patterns and potential biases.
Preview
Installation
npx shadcn@latest add https://vectormotion.vercel.app/registry/prediction-dist-card.jsonPrediction Distribution Card
'use client'import React from 'react';import { BarChart3, TrendingUp, AlertCircle, Sigma } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx"import { twMerge } from "tailwind-merge"import { ResponsiveContainer, BarChart, Bar, XAxis, Tooltip, Cell, ReferenceLine } from 'recharts';function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs))}interface DistributionData { range: string; count: number; [key: string]: any;}interface PredictionDistCardProps { className?: string; title?: string; skewLabel?: string; sampleCount?: string; data?: DistributionData[]; meanValue?: string; medianValue?: string; lowConfValue?: string;}const DEFAULT_DATA: DistributionData[] = [ { range: '0-0.2', count: 50 }, { range: '0.2-0.4', count: 120 }, { range: '0.4-0.6', count: 300 }, { range: '0.6-0.8', count: 850 }, { range: '0.8-1.0', count: 1200 },];const DEFAULT_TITLE = "Predictions";const DEFAULT_SKEW_LABEL = "SKEW: -0.42";const DEFAULT_SAMPLE_COUNT = "2.5k Samples";const DEFAULT_MEAN_VALUE = "0.82";const DEFAULT_MEDIAN_VALUE = "0.85";const DEFAULT_LOW_CONF_VALUE = "5.2%";export const PredictionDistCard: React.FC<PredictionDistCardProps> = ({ className = "", title = DEFAULT_TITLE, skewLabel = DEFAULT_SKEW_LABEL, sampleCount = DEFAULT_SAMPLE_COUNT, data = DEFAULT_DATA, meanValue = DEFAULT_MEAN_VALUE, medianValue = DEFAULT_MEDIAN_VALUE, lowConfValue = DEFAULT_LOW_CONF_VALUE,}) => { return ( <motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.5, delay: 0.2 }} className={cn( "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all hover:border-cyan-300 dark:hover:border-cyan-700 hover:shadow-md flex flex-col h-full", className )} > <div className="p-5 flex flex-col h-full relative z-10"> <div className="flex items-start justify-between mb-2"> <div> <h3 className="font-bold text-lg text-foreground"> {title} </h3> <div className="flex items-center gap-2 mt-1"> <div className="px-2 py-0.5 rounded-full bg-cyan-50 dark:bg-cyan-900/20 border border-cyan-100 dark:border-cyan-800 text-[10px] font-bold text-cyan-600 dark:text-cyan-400"> {skewLabel} </div> <span className="text-xs text-muted-foreground">{sampleCount}</span> </div> </div> <div className="rounded-lg border-2 border-cyan-100 dark:border-cyan-800 p-2 text-cyan-500 dark:text-cyan-400 flex items-center justify-center"> <BarChart3 className="h-5 w-5" /> </div> </div> <div className="flex-1 w-full min-h-[100px] relative mt-2"> <ResponsiveContainer width="100%" height="100%"> <BarChart data={data}> <XAxis dataKey="range" axisLine={false} tickLine={false} tick={{ fontSize: 9, fill: '#71717a' }} interval={0} /> <Tooltip cursor={{ fill: 'transparent' }} content={({ active, payload }) => { if (active && payload && payload.length) { return ( <div className="rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 p-2 shadow-sm text-xs"> <span className="font-bold text-cyan-600 dark:text-cyan-400"> {payload[0].payload.range}: </span> {payload[0].value} samples </div> ); } return null; }} /> <ReferenceLine x="0.8-1.0" stroke="#f43f5e" strokeDasharray="3 3" label={{ value: 'Mean', position: 'top', fontSize: 10, fill: '#f43f5e' }} /> <Bar dataKey="count" radius={[4, 4, 0, 0]}> {data.map((entry, index) => ( <Cell key={`cell-${index}`} fill={index > 3 ? '#06b6d4' : '#e4e4e7'} /> ))} </Bar> </BarChart> </ResponsiveContainer> </div> <div className="grid grid-cols-3 gap-2 mt-4 pt-4 border-t border-border"> <div className="text-center"> <div className="text-[10px] text-muted-foreground font-medium mb-0.5 flex items-center justify-center gap-1"><Sigma className="w-3 h-3" /> Mean</div> <div className="text-sm font-bold text-foreground">{meanValue}</div> </div> <div className="text-center border-l border-r border-border"> <div className="text-[10px] text-muted-foreground font-medium mb-0.5 flex items-center justify-center gap-1"><TrendingUp className="w-3 h-3" /> Median</div> <div className="text-sm font-bold text-foreground">{medianValue}</div> </div> <div className="text-center"> <div className="text-[10px] text-muted-foreground font-medium mb-0.5 flex items-center justify-center gap-1"><AlertCircle className="w-3 h-3" /> Low Conf</div> <div className="text-sm font-bold text-foreground">{lowConfValue}</div> </div> </div> <div className="absolute -bottom-4 -right-4 z-0 opacity-5 pointer-events-none"> <BarChart3 className="w-40 h-40 text-cyan-500" /> </div> </div> </motion.div> );};Props
Prop
Type
Usage
This component is a demo card displaying prediction distribution data with animated visualizations and dark mode support.