import datetime as dt

from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler

from football_trading.src.models.templates.sklearn_model import SKLearnModel
from football_trading.src.utils.logging import get_logger

logger = get_logger()


class LogisticRegressionModel(SKLearnModel):
    """Everything specific to LogisticRegression models goes in this class
    """
    def __init__(
        self,
        test_mode=False,
        load_model=False,
        load_model_date=None,
        save_trained_model=True,
        upload_historic_predictions=None,
    ):
        # Call the __init__ method of the parent class
        super().__init__(
            test_mode=test_mode,
            upload_historic_predictions=upload_historic_predictions,
        )
        # Define the model object
        self.model_object = LogisticRegression
        # The name of the model you want ot use
        self.model_type = self.model_object.__name__
예제 #2
0
from dash.dependencies import Input, Output

from football_trading.settings import model_dir, tmp_dir, LOCAL, DB_DIR, S3_BUCKET_NAME, \
    AWS_SECRET_ACCESS_KEY, AWS_ACCESS_KEY_ID, training_data_dir
from football_trading.src.utils.logging import get_logger
from football_trading.src.utils.dashboard import (
    get_form_dif_view, get_team_home_away_performance, get_performance_by_season,
    get_cumulative_profit_view, get_cumulative_profit_from_bof, get_historic_features,
    load_production_model)
from football_trading.src.utils.db import run_query
from football_trading.src.utils.s3_tools import download_from_s3


active_graphs = ['profit-by-date', 'accuracy_home_away', 'accuracy_over_time', 'form_diff_acc']

logger = get_logger(logger_name='dashboard')


def get_dashboard_app(server=None):

    session = boto3.session.Session(
        aws_access_key_id=AWS_ACCESS_KEY_ID,
        aws_secret_access_key=AWS_SECRET_ACCESS_KEY
    )

    if not LOCAL:
        logger.info('Attempting to download DB from S3..')
        try:
            if not os.path.exists(f"{DB_DIR}"):
                download_from_s3(local_path=f"{DB_DIR}", s3_path='db.sqlite', bucket=S3_BUCKET_NAME)
        except Exception as e: