Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discounting a player #615

Open
mildfuzz opened this issue Aug 10, 2023 · 1 comment
Open

Discounting a player #615

mildfuzz opened this issue Aug 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@mildfuzz
Copy link

Fairly certain Harry Kane is going to leave, but my prediction keeps picking him. Is there a way to discount a player from the model?

@jack89roberts jack89roberts added the enhancement New feature or request label Aug 10, 2023
@jack89roberts
Copy link
Contributor

jack89roberts commented Aug 10, 2023

That's not functionality we have at the moment, but you can try this as a workaround and it's something we can consider adding in the future:

Save this as a file delete_points.py on your system:

import argparse

from airsenal.framework.schema import PlayerPrediction, session
from airsenal.framework.utils import get_latest_prediction_tag, get_player


def delete_points(player):
    print(f"Deleting latest predictions for {player}")
    tag = get_latest_prediction_tag()
    preds = (
        session.query(PlayerPrediction)
        .filter_by(tag=tag, player_id=player.player_id)
        .all()
    )
    for p in preds:
        p.predicted_points = 0

    session.commit()
    print("Done!")


def main():
    parser = argparse.ArgumentParser(
        description="Delete points predictions for a player"
    )
    parser.add_argument("player", help="Player name")
    args = parser.parse_args()
    player = get_player(args.player)
    delete_points(player)


if __name__ == "__main__":
    main()

Then follow these steps (from the directory you saved the delete_points.py file):

conda activate airsenalenv
airsenal_update_db
airsenal_run_prediction
python delete_points.py "Harry Kane"
airsenal_make_squad

You can vary the arguments to the prediction and make squad steps as normal. The delete_points.py script just sets all the predicted points for a player to zero in the database (could also run it multiple times with a different player each time if you wanted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants