API Reference

Data

Player search and per-player career queries against the MLB Stats API.

data.refresh_cache()

Clear the in-memory cache; the next call re-fetches from MLB Stats API.

data.get_player_career_totals()

Return a career-totals dict for a player, suitable for similarity scoring.

data.search_player()

Substring-match player names against cached MLB rosters.

data.get_batting_career()

Return a per-season batting career DataFrame for a MLB player ID string.

data.get_pitching_career()

Return a per-season pitching career DataFrame for a MLB player ID string.

Model

Weighted quadratic aging-curve fit and career summaries.

model.is_lower_better()
model.fit_player_curve()
model.fit_aging_curve()

Fit a weighted quadratic in centered form.

model.predict_curve()
model.summarize_career()
model.BATTING_METRICS
model.PITCHING_METRICS

Similarity

Bill James similarity scores.

similarity.position_value()

Return the Bill James position value for an MLB position abbreviation.

similarity.similarity_score()

Bill James similarity score between two career-totals dicts.

similarity.find_similar_players()

Rank candidate players by similarity to target.

similarity.POSITION_VALUE

Plots

Matplotlib trajectory charts.

plots.predict_curve()
plots.plot_trajectory()

Scatter + fitted-curve plot.

plots.plot_empty()
plots.plot_trajectories_facet()

Small-multiples plot of multiple players’ aging curves.

plots.plot_peak_vs_curvature()

Scatter of fitted peak age vs curvature, with player labels.