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

Failed to get Data #60

Open
dragonysz opened this issue Feb 3, 2024 · 27 comments
Open

Failed to get Data #60

dragonysz opened this issue Feb 3, 2024 · 27 comments

Comments

@dragonysz
Copy link

When create League,for example, england, it could not connect to football-data server. maybe denied to access the website. How to tackle with this. Could you please provide me an example historical dataset to check the whole codes.? Great thanks for reply.

@kochlisGit
Copy link
Owner

Can you send me the cmd (command line) log (text)? Open the cmd, navigate to Prophitbet's folder and type python main.py and try to download a league. You will be able to see the error message. Then, upload a screenshot in order to provide more information about the problem.

@dragonysz
Copy link
Author

error
Is is possible to download data excels first and put them into special location to do further analysis? Or if possible, please send me a created league as example?

@dragonysz
Copy link
Author

But I can go to the webpage and download data. https://www.football-data.co.uk/
Uploading list data.jpg…

@kochlisGit
Copy link
Owner

Hmm, all right. I see. The issue is related to geo-political issues, as Google does not allow you for some reason to ping their server. So the app think you do not have access to the internet. You can bypass this by opening network/netutils.py and replace the "False" in line 9 with "True". It should work.

@dragonysz
Copy link
Author

I have changed the return "False" to "True". Still I cannot connect to internet to create league. Can you send me the related file after creating league ? maybe via email. 529598664@qq.com great thanks.

@kochlisGit
Copy link
Owner

All right, in the same file, replace the entire code with this one:

import requests


def check_internet_connection() -> bool:
    return True

It should work fine

@dragonysz
Copy link
Author

It didnot work. I still cannot get access to the Internet. Is three any other method to create league data? I can add data manually if possible. Please show me the data form or example csv file. Also I can get data from other similar website.

@kochlisGit
Copy link
Owner

No, unfortunately You cannot manually add a league flle for several reasons. Please provide me with the following:

  1. Send me a screenshot of the modified network/netutils.py files.
  2. The error that appears.
  3. The log of the cmd (command line) that is displayed when the error occurs. If you don't know what that is, I can help you open the cmd.

@dragonysz
Copy link
Author

network
log1
log2
Uploading log3.jpg…

@kochlisGit
Copy link
Owner

ok, I see that Return True line has 8 spaces for some reason. Can you change it to have 4 spaces? Just completely delete everyting in the file and paste the following:

def check_internet_connection() -> bool:
    return True

It should work! I mean, it does work on everyone else.

@dragonysz
Copy link
Author

It still not work. Thanks again for your patient suggestions.

@kochlisGit
Copy link
Owner

Does it still shows the same message?

@dragonysz
Copy link
Author

yes. the same error. Could not connect to the internet serve. Maybe location restriction.

@JoeyHsu9527
Copy link

微信截图_20240206145459

Does it still shows the same message?

when i trying to create league,it doesn't work,as the picture shows

@kochlisGit
Copy link
Owner

Can you also show me a screenshot of the create league window?

@kochlisGit
Copy link
Owner

dragonysz

Yes, but You said that you can connect to https://football-data.co.uk/ website. I really can't understand the cause of this. Try running a command line (cmd) and type the following:

python
import pandas as pd
df = pd.read_csv('https://www.football-data.co.uk/mmz4281/2324/E0.csv')
df

Does this code work? It should download the Premier League data. If not, it means that you are not allowed to have access to the server for some reason.

@dragonysz
Copy link
Author

When I use jupyter to run the above code, a list of excel was shown. when I typed the website, a csv has been downloaded. But I cannot creat league correctly.

@kochlisGit
Copy link
Owner

kochlisGit commented Feb 6, 2024

All right, let's try one last thing!

Go to file gui/dialogs/leagues/create.py and replace code with the one below:


from tkinter import messagebox, StringVar, BooleanVar, IntVar, END
from tkinter.ttk import Label, Combobox, Checkbutton, Entry, Button
from database.entities.leagues.league import LeagueConfig
from database.network.netutils import check_internet_connection
from database.repositories.league import LeagueRepository
from gui.dialogs.dialog import Dialog
from gui.task import TaskDialog
from gui.widgets.intslider import IntSlider
from gui.widgets.utils import create_tooltip_btn, validate_id_entry


class CreateLeagueDialog(Dialog):
    def __init__(self, root, league_repository: LeagueRepository):
        self._league_repository = league_repository
        self._all_leagues_dict = league_repository.all_leagues_dict

        self._cb_country_values = list(self._all_leagues_dict.keys())
        for i, config_list in enumerate(self._all_leagues_dict.values()):
            self._cb_country_values[i] += f' ({config_list[0].category})'

        self._odd_features = ['1', 'X', '2']
        self._home_features = ['HW', 'HL', 'HGF', 'HGA', 'HWGD', 'HLGD', 'HW%', 'HL%']
        self._away_features = ['AW', 'AL', 'AGF', 'AGA', 'AWGD', 'ALGD', 'AW%', 'AL%']
        self._matches_df = None
        self._league_config = None

        self._selected_league_cb = None
        self._league_id_entry = None
        self._year_star_cb = None
        self._selected_country_var = StringVar()
        self._league_id_var = StringVar()
        self._match_history_window_var = IntVar(value=3)
        self._goal_diff_margin_var = IntVar(value=3)
        self._odd_vars = {col: BooleanVar(value=True) for col in self._odd_features}
        self._home_vars = {col: BooleanVar(value=True) for col in self._home_features}
        self._away_vars = {col: BooleanVar(value=True) for col in self._away_features}
        self._year_start_var = IntVar(value=2015)
        self._all_vars = {**self._odd_vars, **self._home_vars, **self._away_vars}

        super().__init__(root=root, title='Create League', window_size=self._compute_required_window_size())

    def _compute_required_window_size(self) -> dict[str, int]:
        x = 400
        y = len(self._home_features)*60 + 220
        return {'width': x, 'height': y}

    def _create_widgets(self):
        Label(self.window, text='--- League Settings ---', font=('Arial', 14)).place(x=100, y=10)

        Label(self.window, text='Select Country:', font=('Arial', 14)).place(x=15, y=45)
        country_cb = Combobox(
            self.window,
            values=self._cb_country_values,
            width=21,
            font=('Arial', 10),
            state='readonly',
            textvariable=self._selected_country_var
        )
        country_cb.current(0)
        country_cb.bind('<<ComboboxSelected>>', self._adjust_league_settings)
        country_cb.place(x=165, y=50)

        Label(self.window, text='Select League:', font=('Arial', 14)).place(x=15, y=85)
        self._selected_league_cb = Combobox(
            self.window,
            width=21,
            font=('Arial', 10),
            state='readonly'
        )
        self._selected_league_cb.bind('<<ComboboxSelected>>', self._adjust_stats_settings)
        self._selected_league_cb.place(x=165, y=90)

        Label(self.window, text='League ID:', font=('Arial', 14)).place(x=15, y=125)
        self._league_id_entry = Entry(
            self.window,
            width=28,
            font=('Arial', 10),
            textvariable=self._league_id_var
        )
        self._league_id_entry.place(x=135, y=130)
        create_tooltip_btn(
            root=self.window,
            text='Identifier (ID) of this league. Each league should have unique ID.'
        ).place(x=350, y=130)

        Label(self.window, text='--- Stats Settings ---', font=('Arial', 14)).place(x=110, y=175)

        Label(self.window, text='Match History Window:', font=('Arial', 14)).place(x=15, y=215)
        IntSlider(

            self.window,
            from_=3,
            to=5,
            variable=self._match_history_window_var,
            compound='bottom'
        ).place(x=220, y=215)
        create_tooltip_btn(
            root=self.window,
            text='Number of past matches to examine to compute team stats'
        ).place(x=330, y=215)

        Label(self.window, text='Goal Margin Diff:', font=('Arial', 14)).place(x=15, y=255)
        IntSlider(
            self.window,
            from_=2,
            to=3,
            variable=self._goal_diff_margin_var,
            compound='bottom'
        ).place(x=180, y=255)
        create_tooltip_btn(
            root=self.window,
            text='Goal Difference Margin to compute HGD, HGA, AGD, AGA stats'
        ).place(x=290, y=255)

        Label(self.window, text='--- Stats Columns ---', font=('Arial', 14)).place(x=100, y=300)
        Checkbutton(
            self.window,
            text='Odd-1',
            onvalue=True,
            offvalue=False,
            variable=self._odd_vars['1']
        ).place(x=70, y=340)
        Checkbutton(
            self.window,
            text='Odd-X',
            onvalue=True,
            offvalue=False,
            variable=self._odd_vars['X']
        ).place(x=170, y=340)
        Checkbutton(
            self.window,
            text='Odd-2',
            onvalue=True,
            offvalue=False,
            variable=self._odd_vars['2']
        ).place(x=270, y=340)

        for i, col in enumerate(self._home_features):
            Checkbutton(
                self.window,
                text=col,
                onvalue=True,
                offvalue=False,
                variable=self._home_vars[col]
            ).place(x=90, y=370 + i*30)

        for i, col in enumerate(self._away_features):
            Checkbutton(
                self.window,
                text=col,
                onvalue=True,
                offvalue=False,
                variable=self._away_vars[col]
            ).place(x=240, y=370 + i*30)

        Label(self.window, text='Start Year:', font=('Arial', 14)).place(x=80, y=self.window_size['height'] - 85)
        self._year_star_cb = Combobox(
            self.window,
            width=10,
            font=('Arial', 10),
            state='readonly',
            textvariable=self._year_start_var
        )
        self._year_star_cb.place(x=190, y=self.window_size['height'] - 80)

        Button(
            self.window,
            text='Create League',
            command=self._create_league
        ).place(x=150, y=self.window_size['height'] - 40)

    def _adjust_league_settings(self, event):
        country = self._selected_country_var.get().split(' ')[0]
        self._selected_league_cb['values'] = [league.name for league in self._all_leagues_dict[country]]
        self._selected_league_cb.current(0)
        self._league_id_entry.delete(0, END)
        self._league_id_entry.insert(0, f'{country}-{self._all_leagues_dict[country][0].name}-0')

        self._adjust_stats_settings(event=event)

    def _adjust_stats_settings(self, event):
        country = self._selected_country_var.get().split(' ')[0]
        league_config = self._all_leagues_dict[country][self._selected_league_cb.current()]
        year_start = league_config.year_start
        self._year_star_cb['values'] = [year_start + i for i in range(0, 2020-year_start + 1)]
        self._year_start_var.set(value=2015)

    def _create_league(self):
        if True:
            if validate_id_entry(parent=self._window, text=self._league_id_var.get()):
                league_id = self._league_id_var.get()

                if league_id not in self._league_repository.get_created_leagues():
                    country = self._selected_country_var.get().split(' ')[0]
                    features = [col for col, var in self._all_vars.items() if var.get()]
                    league = self._all_leagues_dict[country][self._selected_league_cb.current()]
                    league.year_start = self._year_start_var.get()

                    league_config = LeagueConfig(
                        league_id=league_id,
                        league=league,
                        match_history_window=self._match_history_window_var.get(),
                        goal_diff_margin=self._goal_diff_margin_var.get(),
                        features=features
                    )
                    self._matches_df = TaskDialog(
                        master=self.window,
                        title=self.title,
                        task=self._league_repository.create_league,
                        args=(league_config,)
                    ).start()

                    if self._matches_df is not None:
                        self._league_config = league_config
                    else:
                        messagebox.showerror(
                            parent=self.window,
                            title='Failed',
                            message='Failed to create league. Check command line (cmd) for more details.'
                        )

                    self.close()
                else:
                    messagebox.showerror(
                        parent=self.window,
                        title='League-ID exists',
                        message=f'A league with ID: "{league_id}" already exists. Enter a unique ID.'
                    )

    def _init_dialog(self):
        self._window.bind('<Return>', self._get_dialog_result)
        self._adjust_league_settings(event=None)

    def _get_dialog_result(self, event=None) -> tuple:
        return self._matches_df, self._league_config

@dragonysz
Copy link
Author

Great thanks. The league selected has been successfully created.The date of data list was updated to 05/02/2024. I will understand the logic flow of your codes first and look forward to discussing with you on this topic in the future.

Additionally, if possible, similar matches(5-10) based on specific similarity index can be listed for each match when predicting.
Uploading similarity matches.jpg…

@JoeyHsu9527
Copy link

Can you also show me a screenshot of the create league window?

Can you also show me a screenshot of the create league window?

微信截图_20240206220054
微信截图_20240206220137
微信截图_20240206220304

@kochlisGit
Copy link
Owner

kochlisGit commented Feb 6, 2024

That's weird. I don't have any issue.

edede

@kochlisGit
Copy link
Owner

kochlisGit commented Feb 6, 2024

Can you also show me a screenshot of the create league window?

Can you also show me a screenshot of the create league window?

微信截图_20240206220054 微信截图_20240206220137 微信截图_20240206220304

it might be due to tkinter or pandas library. Open a cmd and type: pip show tk and pip show pandas and show me which versions you use.

@JoeyHsu9527
Copy link

Can you also show me a screenshot of the create league window?

Can you also show me a screenshot of the create league window?

微信截图_20240206220054 微信截图_20240206220137 微信截图_20240206220304

it might be due to tkinter or pandas library. Open a cmd and type: pip show tk and pip show pandas and show me which versions you use.

微信截图_20240207151454
when I used the old version,never had this problem.

@kochlisGit
Copy link
Owner

kochlisGit commented Feb 7, 2024

Yes, I see. The pandas version is different. Try re-installing this pandas version and try again:
pip install pandas==1.4.3

I also updated the requirements to make sure everyone updates their pandas version. Perhaps you should also check the requirements, to make sure your library versions match the suggested ones:
https://github.com/kochlisGit/ProphitBet-Soccer-Bets-Predictor/blob/main/requirements.txt

@JoeyHsu9527
Copy link

Yes, I see. The pandas version is different. Try re-installing this pandas version and try again: pip install pandas==1.4.3

I also updated the requirements to make sure everyone updates their pandas version. Perhaps you should also check the requirements, to make sure your library versions match the suggested ones: https://github.com/kochlisGit/ProphitBet-Soccer-Bets-Predictor/blob/main/requirements.txt

微信截图_20240208182558
微信截图_20240208182622
I don’t know why, but when i trying to install the specified version,it fails

@kochlisGit
Copy link
Owner

yes, I think it requires visual studio to be installed, because it says microsoft visual c++ is required

@JoeyHsu9527
Copy link

yes, I think it requires visual studio to be installed, because it says microsoft visual c++ is required

thanks a lot, i lower the python version to 3.9,it successfully worked. now im trying to figure out the parameters of these new models. the accuracy rate is only about 50%,any suggestions?

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

No branches or pull requests

3 participants