kochlisGit / ProphitBet-Soccer-Bets-Predictor

ProphitBet is a Machine Learning Soccer Bet prediction application. It analyzes the form of teams, computes match statistics and predicts the outcomes of a match using Advanced Machine Learning (ML) methods. The supported algorithms in this application are Neural Networks, Random Forests & Ensembl Models.
MIT License
339 stars 121 forks source link

Error importing Mexico league #45

Closed keith0811 closed 1 year ago

keith0811 commented 1 year ago

Manage to create for other leagues, but facing issue for mexico one.

Exception in thread Thread-1 (_store_league): Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run self._target(*self._args, **self._kwargs) File "/Users//Documents/soccer-predict/gui/dialogs/league.py", line 115, in _store_league matches_df, league = self._league_repository.create_league( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//Documents/soccer-predict/database/repositories/league.py", line 90, in create_league return self._store_league( ^^^^^^^^^^^^^^^^^^^ File "/Users//Documents/soccer-predict/database/repositories/league.py", line 56, in _store_league ).compute_statistics(statistic_columns=league_config['statistic_columns']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//Documents/soccer-predict/preprocessing/statistics.py", line 51, in compute_statistics matches_df[column] = self._statistics_mapper[column]() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users//Documents/soccer-predict/preprocessing/statistics.py", line 57, in _compute_last_n_home_wins return self._compute_last_results(team_index=1, target_result_value='H') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/Documents/soccer-predict/preprocessing/statistics.py", line 71, in _compute_last_results for season in range(self._max_season, self._min_season - 1, -1):


TypeError: unsupported operand type(s) for -: 'str' and 'int'

[<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link id=Main-File rel=Main-File
href="file:////Users/keithkong/Library/Group%20Containers/UBF8T346G9.Office/TemporaryItems/msohtmlclip/clip.htm">
<link rel=File-List
href="file:////Users/keithkong/Library/Group%20Containers/UBF8T346G9.Office/TemporaryItems/msohtmlclip/clip_filelist.xml">
<style>
<!--table
    {mso-displayed-decimal-separator:"\.";
    mso-displayed-thousand-separator:"\,";}
@page
    {margin:1.0in .75in 1.0in .75in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;}
tr
    {mso-height-source:auto;}
col
    {mso-width-source:auto;}
br
    {mso-data-placement:same-cell;}
td
    {padding-top:1px;
    padding-right:1px;
    padding-left:1px;
    mso-ignore:padding;
    color:black;
    font-size:12.0pt;
    font-weight:400;
    font-style:normal;
    text-decoration:none;
    font-family:Calibri, sans-serif;
    mso-font-charset:0;
    mso-number-format:General;
    text-align:general;
    vertical-align:bottom;
    border:none;
    mso-background-source:auto;
    mso-pattern:auto;
    mso-protection:locked visible;
    white-space:nowrap;
    mso-rotate:0;}
-->
</style>
</head>

<body link="#0563C1" vlink="#954F72">

Mexico | Liga-Mx | https://www.football-data.co.uk/new/MEX.csv | 2012 | extra | https://footystats.org/mexico/liga-mx
-- | -- | -- | -- | -- | --

</body>

</html>

]
ZockerFox commented 1 year ago

The Problem is, that the column 'Season' is in the form '2012/13' and not in the form '2012' in the other leagues. But you can change the procedure _download in the file database/network/footballdata/extra.py to

    def _download(self, league: League) -> pd.DataFrame:
        extra_df = pd.read_csv(league.url)
        if '/' in str(extra_df['Season'][0]):
           extra_df['Season'] = extra_df['Season'].apply(lambda x: int(x.split('/')[0]))

        return extra_df
KnightRider37 commented 1 year ago

the issue with some leagues is that they have season asta yyyy/yyyy, for exemple 2012/2013, while most of them has the season as yyyy, 2012 only. Mexico, Denmark, Romania and some other leagues have yyyy/yyyy and not possible to create league. maybe someone managed to solve it...

keith0811 commented 1 year ago

The Problem is, that the column 'Season' is in the form '2012/13' and not in the form '2012' in the other leagues. But you can change the procedure _download in the file database/network/footballdata/extra.py to

    def _download(self, league: League) -> pd.DataFrame:
        extra_df = pd.read_csv(league.url)
        if '/' in str(extra_df['Season'][0]):
           extra_df['Season'] = extra_df['Season'].apply(lambda x: int(x.split('/')[0]))

        return extra_df

Thanks. It works well.

KnightRider37 commented 1 year ago

Works great! Thanks!