AI/ML
Model Accuracy Card - ML Performance Metrics
Track machine learning model accuracy, precision, recall, and F1 scores. Monitor model performance degradation and retraining needs.
Model Accuracy Card
The Model Accuracy Card displays model accuracy scores and trends over time, helping teams monitor model performance.
Preview
Installation
npx shadcn@latest add https://vectormotion.vercel.app/registry/model-accuracy-card.jsonModel Accuracy Card
'use client'import React from 'react';import { Target, Trophy, TrendingUp } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx"import { twMerge } from "tailwind-merge"import { ResponsiveContainer, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Radar, Tooltip } from 'recharts';function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs))}interface AccuracyData { metric: string; value: number; fullMark: number; [key: string]: any;}interface ModelAccuracyCardProps { className?: string; title?: string; subtitle?: string; data?: AccuracyData[]; accuracyValue?: string; f1ScoreValue?: string;}const DEFAULT_DATA: AccuracyData[] = [ { metric: 'Accuracy', value: 94, fullMark: 100 }, { metric: 'Precision', value: 92, fullMark: 100 }, { metric: 'Recall', value: 89, fullMark: 100 }, { metric: 'F1 Score', value: 90, fullMark: 100 }, { metric: 'AUC', value: 96, fullMark: 100 },];const DEFAULT_TITLE = "Model Performance";const DEFAULT_SUBTITLE = "Classification Metrics";const DEFAULT_ACCURACY_VALUE = "94.2%";const DEFAULT_F1_SCORE_VALUE = "0.90";export const ModelAccuracyCard: React.FC<ModelAccuracyCardProps> = ({ className = "", title = DEFAULT_TITLE, subtitle = DEFAULT_SUBTITLE, data = DEFAULT_DATA, accuracyValue = DEFAULT_ACCURACY_VALUE, f1ScoreValue = DEFAULT_F1_SCORE_VALUE,}) => { return ( <motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.5 }} className={cn( "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all hover:border-purple-300 dark:hover:border-purple-700 hover:shadow-md flex flex-col h-full", className )} > <div className="p-5 flex flex-col h-full relative z-10"> <div className="mb-4 flex items-start justify-between"> <div> <h3 className="font-bold text-lg text-foreground"> {title} </h3> <p className="text-sm text-muted-foreground font-medium"> {subtitle} </p> </div> <div className="rounded-lg border-2 border-purple-100 dark:border-purple-800 p-2 text-purple-500 dark:text-purple-400 flex items-center justify-center"> <Target className="h-5 w-5" /> </div> </div> <div className="flex items-center gap-2 flex-1 min-h-[160px]"> {/* Left Side: Radar Chart */} <div className="flex-1 h-[180px] -ml-4 relative"> <ResponsiveContainer width="100%" height="100%"> <RadarChart cx="50%" cy="50%" outerRadius="70%" data={data}> <PolarGrid stroke="#e4e4e7" strokeOpacity={0.5} /> <PolarAngleAxis dataKey="metric" tick={{ fontSize: 9, fill: '#71717a', fontWeight: 600 }} /> <PolarRadiusAxis angle={30} domain={[0, 100]} tick={false} axisLine={false} /> <Radar name="Model" dataKey="value" stroke="#a855f7" strokeWidth={2} fill="#a855f7" fillOpacity={0.3} /> <Tooltip cursor={false} 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-purple-600 dark:text-purple-400"> {payload[0].payload.metric}: </span> {payload[0].value}% </div> ); } return null; }} /> </RadarChart> </ResponsiveContainer> </div> {/* Right Side: Key Stats */} <div className="w-1/3 flex flex-col gap-3 z-10"> <div className="p-2 rounded-lg bg-purple-50 dark:bg-purple-900/20 border border-purple-100 dark:border-purple-800/50"> <div className="flex items-center gap-1.5 text-purple-600 dark:text-purple-400 mb-0.5"> <Trophy className="w-3 h-3" /> <span className="text-[10px] uppercase font-bold tracking-wide">Acc</span> </div> <div className="text-xl font-bold text-foreground">{accuracyValue}</div> </div> <div className="p-2 rounded-lg bg-muted border border-zinc-100 dark:border-zinc-700"> <div className="flex items-center gap-1.5 text-muted-foreground mb-0.5"> <TrendingUp className="w-3 h-3" /> <span className="text-[10px] uppercase font-bold tracking-wide">F1</span> </div> <div className="text-xl font-bold text-foreground">{f1ScoreValue}</div> </div> </div> </div> <div className="absolute -bottom-4 -right-4 z-0 opacity-5 pointer-events-none"> <Target className="w-40 h-40 text-purple-500" /> </div> </div> </motion.div> );};Props
Prop
Type
Usage
This component is a demo card displaying model accuracy data with animated visualizations and dark mode support.