public DataPoint BuildDataPoint(List <Match> history, Match m, DataInterpretation inputInpertretation) { var datapoint = new DataPoint { Inputs = (BuildInputs(history, m, inputInpertretation)), Outputs = BuildOutputs(m).ToList(), Reference = m.ToTuple() }; return(datapoint); }
public static List <double> BuildInputs(List <Match> history, Match m, DataInterpretation interpretation = null) { if (interpretation == null) { interpretation = AFLDataInterpreter.BespokeLegacyInterpretation; } var input = AFLDataInterpreterTotal.New().BuildInputs(history, m, interpretation); return(input); }
public List <double> BuildInputs(List <Match> history, Match m, DataInterpretation interpretation) { var input = new List <double>(); //Scores By Team foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORES_BY_TEAM).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractTeamScoreInputSet(m, history, term, ExtractInputSetForScore)); } } //Scores By Ground foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORES_BY_GROUND).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractGroundScoreInputSet(m, history, term, ExtractInputSetForScore)); } } //Scores By State longerTerm foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORES_BY_STATE).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractStateScoreInputSet(m, history, term, ExtractInputSetForScore)); } } //Scores by Day foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORES_BY_DAY).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractDayScoreInputSet(m, history, term, ExtractInputSetForScore)); } } //Recent Shared Opponents foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORES_BY_SHARED_OPPONENTS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractSharedOpponentScoreSet(m, history, term, ExtractInputSetForScore)); } } //Scores by quality of recent Opponents foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORES_BY_QUALITY_OF_OPPONENTS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractQualityOfRecentOpponentScoreSet(m, history, term, ExtractInputSetForOppositionScore)); } } //Wins By Team foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.WINS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractTeamWinInputSet(m, history, term, ExtractInputSetForWin)); } } //Scoring shots foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.SCORING_SHOTS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractScoresInputSet(m, history, term)); } } //Kicks foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.KICKS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractKicksInputSet(m, history, term)); } } //Handballs foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.HANDBALLS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractHandballsInputSet(m, history, term)); } } //Marks foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.MARKS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractMarksInputSet(m, history, term)); } } //Hitouts foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.HITOUTS).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractHitoutsInputSet(m, history, term)); } } //Tackles foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.TACKLES).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractTacklesInputSet(m, history, term)); } } //Frees foreach (var term in interpretation.Rules.Where(r => r.Type == DataInterpretationRuleType.FREES).SelectMany(r => r.Periods)) { if (term > 0) { input.AddRange(ExtractFreesInputSet(m, history, term)); } } return(input); }
public static Data GetMatchDataBetween(List <Season> seasons, RoundShell fromRoundShell, RoundShell toRoundShell, DataInterpretation interpretation = null) { var data = new Data(); //TODO: It's a little messy to new this up here var league = new League(seasons); var rounds = league.GetRounds(0, 0, toRoundShell.Year, toRoundShell.Number).Where(x => x.Matches.Count > 0).ToList(); var matches = rounds.Where(r => (r.EffectiveId() > fromRoundShell.EffectiveId())) .SelectMany(r => r.Matches); foreach (var m in matches) { var dataPoint = new DataPoint(); var history = rounds.Where(r => !r.Matches.Any(rm => rm.Date >= m.Date)).SelectMany(r => r.Matches).ToList(); dataPoint.Inputs = (BuildInputs(history, m, interpretation)); dataPoint.Outputs = (new List <double>() { Numbery.Normalise(m.HomeScore().Total(), Util.MaxScore), Numbery.Normalise(m.AwayScore().Total(), Util.MaxScore) }); dataPoint.Reference = m.ToTuple(); data.DataPoints.Add(dataPoint); } return(data); }
public Data GetMatchDataFromLeagueBetween(RoundShell fromRoundShell, RoundShell toRoundShell, DataInterpretation interpretation = null) { return(GetMatchDataBetween(League.Seasons, fromRoundShell, toRoundShell, interpretation)); }
public List <PredictedMatch> PredictWinners(int year, int round, bool isFinal, DataInterpretation interpretation = null) { var predictions = new List <PredictedMatch>(); var rounds = League.GetRounds(0, 0, year, round).Where(x => x.Matches.Count > 0).ToList(); foreach (var m in rounds.Where(r => r.Year == year && r.Number == round && r.IsFinal == isFinal).SelectMany(r => r.Matches)) { //TODO: Are we ordering in the right direction? var history = rounds.Where(r => !r.Matches.Any(rm => rm.Date >= m.Date)).SelectMany(r => r.Matches).OrderBy(h => h.Date).ToList(); var test = BuildInputs(history, m, interpretation); var result = Net.Run(test); predictions.Add(new PredictedMatch(m.Home, m.Away, m.Ground, m.Date, Numbery.Denormalise(result[0], Util.MaxScore), Numbery.Denormalise(result[1], Util.MaxScore), round)); } return(predictions); }