Basketball Stats
by a-jay85
Basketball statistics formatting using BasketballStats\StatsFormatter for percentages, averages, and totals. Use when displaying stats, calculating averages, or formatting basketball numbers.
Skill Details
Repository Files
3 files in this skill directory
name: basketball-stats description: Basketball statistics formatting using BasketballStats\StatsFormatter for percentages, averages, and totals. Use when displaying stats, calculating averages, or formatting basketball numbers.
Basketball Statistics Formatting
Use BasketballStats\StatsFormatter for ALL statistic formatting. Never use number_format() directly.
Available Methods
formatPercentage($made, $attempted)
Shooting percentages with 3 decimal places.
echo StatsFormatter::formatPercentage($fgm, $fga); // "0.523"
echo StatsFormatter::formatPercentage($ftm, $fta); // "0.875"
echo StatsFormatter::formatPercentage($tgm, $tga); // "0.412"
formatPerGameAverage($total, $games)
Per-game stats with 1 decimal place.
echo StatsFormatter::formatPerGameAverage($points, $gamesPlayed); // "25.3" PPG
echo StatsFormatter::formatPerGameAverage($assists, $gamesPlayed); // "7.2" APG
echo StatsFormatter::formatPerGameAverage($rebounds, $gamesPlayed); // "10.1" RPG
formatPer36Stat($total, $minutes)
Per-36-minute stats with 1 decimal place.
echo StatsFormatter::formatPer36Stat($points, $totalMinutes); // "18.5"
echo StatsFormatter::formatPer36Stat($rebounds, $totalMinutes); // "8.3"
formatTotal($value)
Counting stats with comma separators.
echo StatsFormatter::formatTotal($careerPoints); // "12,345"
echo StatsFormatter::formatTotal($careerRebounds); // "5,678"
formatAverage($value)
General averages with 2 decimal places.
echo StatsFormatter::formatAverage($playerRating); // "85.23"
calculatePoints($fgm, $ftm, $tgm)
Calculate point totals from shot makes.
$points = StatsFormatter::calculatePoints($fgm, $ftm, $tgm);
// Formula: (2 * FGM) + FTM + TGM
safeDivide($numerator, $denominator)
Division with zero-division handling.
$avg = StatsFormatter::safeDivide($total, $games); // Returns 0 if games=0
Usage Example
use BasketballStats\StatsFormatter;
// Player stat line
$fgPct = StatsFormatter::formatPercentage($player['fgm'], $player['fga']);
$ppg = StatsFormatter::formatPerGameAverage($player['pts'], $player['gp']);
$rpg = StatsFormatter::formatPerGameAverage($player['reb'], $player['gp']);
echo "FG%: $fgPct | PPG: $ppg | RPG: $rpg";
// Output: "FG%: 0.485 | PPG: 18.5 | RPG: 7.2"
Input Validation
Use BasketballStats\StatsSanitizer for input validation:
use BasketballStats\StatsSanitizer;
$playerId = StatsSanitizer::sanitizeInt($_GET['pid']);
$rating = StatsSanitizer::sanitizeFloat($_POST['rating']);
$name = StatsSanitizer::sanitizeString($_POST['name']);
Examples
See examples/ for more patterns:
Related Skills
Attack Tree Construction
Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.
Grafana Dashboards
Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces.
Matplotlib
Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.
Scientific Visualization
Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.
Seaborn
Statistical visualization. Scatter, box, violin, heatmaps, pair plots, regression, correlation matrices, KDE, faceted plots, for exploratory analysis and publication figures.
Shap
Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Query Writing
For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Scientific Visualization
Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.
