<jupyter_start><jupyter_text>Marcel ProjectionThis is for development of a Marcel Projection system developed, but _not_ endorsed, by <NAME>.   About Marcel Projections<NAME> casually offered Marcel projections as a projection system for baseball stats that could be used to act as a baseline for player projections. I say that were casually offered; he said of them: "I do not stand behind these forecasts. These forecasts are the minimum level of competence that you should expect from any forecaster. Do not attach my name to these forecasts in any kind of evaluation experiment. They should only be referred to as Marcel The Monkey Forecasting System, or simply The Marcels." It is named for a monkey on a sitcom (I think it was "Friends.") Marcels have been shown to be reasonably accurate at projecting basbeall players despite being very simple.The point of these is not to forecast baseball for "serious" purposes. Rather, they act as a baseline.  How they WorkShort version: To project a player's stats in year N, add 5 times their previous season (N - 1), 4 times their N -2 season, and 3 times their N - 3 season. Then add two full seasons of major league average performance. Prorate that number to get an expected number of Plate Appearances or Innings pitched. In essence, it weighs a player's observed stats with the simplest possible expected value, the mean. (Pitcher's don't follow exactly this scheme.)Complete details at are [here](http://www.tangotiger.net/archives/stud0346.shtml). See Tango's comment 28 for pitcher details.<jupyter_code>import numpy as np
import pandas as pd
import os ##for looking at the names of files in this directory.
from marcel import MarcelForecaster
hitters = pd.read_csv('../data/hitters_since_1947.csv')
pitchers = pd.read_csv('../data/pitchers_since_1947.csv')
hitter_ages = pd.read_csv('../data/all_hitter_ages.csv')
pitcher_ages = pd.read_csv('../data/all_pitcher_ages.csv')

hitters = pd.merge(hitters, hitter_ages[['Season','playerid','Age']], how='left',on=['playerid','Season']).reset_index().drop(['index'],axis=1)
pitchers = pd.merge(pitchers, pitcher_ages[['Season','playerid','Age']], how='left',on=['playerid','Season']).reset_index().drop(['index'],axis=1)
pitchers.head()

marcel = MarcelForecaster(pitchers,hitters,as_pandas=True)
marcel.hitter_stat_cols
#marcel.pitcher_stat_cols

#scaled_hitters = marcel._hit_step1(2020)
hitters = marcel.project_hitters(2020)
#prorating = marcel._hit_step4_prorating(2020).sort_values(by='PA')
hitters[(hitters['Age'] <= 21)]
marcel.pitchers.columns
marcel.pitchers.head()
pitchers = marcel.project_pitchers(2020)
pitchers.sort_values(by='FIP', ascending=True).head()
marcel.expected_mean_pitcher(2020).to_dict()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10010921004732436, 'fraction_numerical': 0.016745540589734254, 'mean_word_length': 5.974619289340102, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '518112', 'license': 'MIT', 'n_tokens_mistral': 873, 'n_tokens_neox': 787, 'n_words': 300, 'path': 'forecast/MarcelForecast.ipynb', 'repo_name': 'philosofool/phi_baseball', 'size': '2753'}