Skip to content

Commit

Permalink
validation plot working
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRook committed Aug 16, 2016
1 parent 84acee5 commit d2d368c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Binary file modified doc/source/_static/validation_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions doc/source/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ For Developers
This section of the documentation covers things that will be useful for those already contributing to NFLWin.

.. note::
Unless stated otherwise assume that all filepaths given in this section start at the root directory for the repo.

Unless stated otherwise assume that all filepaths given in this section start at the root directory for the repo.

Testing Documentation
------------------------------------------
Expand All @@ -24,7 +23,13 @@ NFLWin comes with a pre-trained model, but if the code generating that model is
$ python make_default_model.py

.. note::
This script hardcodes in the seasons to use for training and testing samples. After each season those will likely need to be updated to use the most up-to-date data.
This script hardcodes in the seasons to use for training and
testing samples. After each season those will likely need to be
updated to use the most up-to-date data.

.. note::
This script requires ``matplotlib`` in order to run, as it produces a
validation plot for the documentation.

Cutting a New Release
----------------------------------
Expand Down
3 changes: 0 additions & 3 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,3 @@ Resources
Developer Documentation <dev.rst>
Full API Documentation <modules.rst>

* :ref:`Full API Documentation <modindex>`
* :ref:`Search NFLWin's Documentation <search>`

22 changes: 18 additions & 4 deletions make_default_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@
def main():
start = time.time()
win_probability_model = model.WPModel()
win_probability_model.train_model(training_seasons=[2009, 2010, 2011, 2012, 2013, 2014])

training_seasons = [2009, 2010, 2011, 2012, 2013, 2014]
validation_seasons = [2015]
season_types = ["Regular", "Postseason"]

win_probability_model.train_model(training_seasons=training_seasons,
training_season_types=season_types)
print("Took {0:.2f}s to build model".format(time.time() - start))

start = time.time()
max_deviation, residual_area = win_probability_model.validate_model(validation_seasons=[2015])
max_deviation, residual_area = win_probability_model.validate_model(validation_seasons=validation_seasons,
validation_season_types=season_types)
print("Took {0:.2f}s to validate model, with a max residual of {1:.2f} and a residual area of {2:.2f}"
.format(time.time() - start, max_deviation, residual_area))

Expand All @@ -24,8 +31,15 @@ def main():
"residual total area={1:.2f}"
"".format(max_deviation, residual_area))
curr_datetime = dt.datetime.now()
ax.set_title("model generated at: " + curr_datetime.strftime("%Y-%m-%d %H:%M:%S"))
ax.legend(loc="lower right")
ax.set_title("Model Generated At: " + curr_datetime.strftime("%Y-%m-%d %H:%M:%S"))
ax.legend(loc="lower right", fontsize=10)
ax.text(0.02, 0.98, ("Data from: {0:s}\n"
"Training season(s): {1:s}\n"
"Validation season(s): {2:s}"
"".format(", ".join(season_types),
", ".join(str(year) for year in training_seasons),
", ".join(str(year) for year in validation_seasons))),
ha="left", va="top", fontsize=10, transform=ax.transAxes)

this_filepath = os.path.dirname(os.path.abspath(__file__))
save_filepath = os.path.join(this_filepath, "doc", "source", "_static", "validation_plot.png")
Expand Down

0 comments on commit d2d368c

Please sign in to comment.