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

local variable 'mean_cv_score' referenced before assignment #42

Closed
tjc0726 opened this issue Feb 15, 2021 · 4 comments
Closed

local variable 'mean_cv_score' referenced before assignment #42

tjc0726 opened this issue Feb 15, 2021 · 4 comments

Comments

@tjc0726
Copy link

tjc0726 commented Feb 15, 2021


UnboundLocalError Traceback (most recent call last)
in
----> 1 model.fit( traindata=df_after, ts_column='Timestamp',target='Weighted_Price')

/usr/local/lib/python3.8/dist-packages/auto_ts/init.py in fit(self, traindata, ts_column, target, sep, cv)
750 print(f"Total time taken: {elapsed:.0f} seconds.")
751 print("-"*50 + "\n\n")
--> 752 print("Leaderboard with best model on top of list:\n",self.get_leaderboard())
753 return self
754

/usr/local/lib/python3.8/dist-packages/auto_ts/init.py in get_leaderboard(self, ascending)
904 # else: # Assuming List
905 # mean_cv_score = sum(cv_scores)/len(cv_scores)
--> 906 mean_cv_scores.append(mean_cv_score)
907
908 results = pd.DataFrame({"name": names, self.score_type: mean_cv_scores})

UnboundLocalError: local variable 'mean_cv_score' referenced before assignment


So I think the problem is around line 898 in init.py
897 elif isinstance(cv_scores, list): 898 if len(cv_scores) == 0: 899 mean_cv_score = np.inf 900 else: 901 mean_cv_score = self.__get_mean_cv_score(cv_scores) 902 # if isinstance(cv_scores, float): 903 # mean_cv_score = cv_scores 904 # else: # Assuming List 905 # mean_cv_score = sum(cv_scores)/len(cv_scores)
because it doesn't assign the value of mean_cv_score if len(cv_scores) is not equal to 0,I'm not an expert to this frame, but I saw a comment in line 905 says 'assuming list',maybe should put it below 899 like
897 elif isinstance(cv_scores, list): 898 if len(cv_scores) == 0: 899 mean_cv_score = np.inf 900 else: 901 mean_cv_score = sum(cv_scores)/len(cv_scores)

Just my guess

@AutoViML
Copy link
Owner

AutoViML commented Mar 3, 2021

I have fixed this error in the ;latest version. Please pip install upgrade like this:

$ pip install auto-ts --upgrade --user

This should fix it - if not, please reopen it.
Thx
Ram

@AutoViML AutoViML closed this as completed Mar 3, 2021
@ssth81456
Copy link

fe02913


UnboundLocalError Traceback (most recent call last)
in
4 target=target,
5 cv=3,
----> 6 sep=sep)

~\Anaconda3\envs\test\lib\site-packages\auto_ts_init_.py in fit(self, traindata, ts_column, target, sep, cv)
750 print(f"Total time taken: {elapsed:.0f} seconds.")
751 print("-"*50 + "\n\n")
--> 752 print("Leaderboard with best model on top of list:\n",self.get_leaderboard())
753 return self
754

~\Anaconda3\envs\test\lib\site-packages\auto_ts_init_.py in get_leaderboard(self, ascending)
904 # else: # Assuming List
905 # mean_cv_score = sum(cv_scores)/len(cv_scores)
--> 906 mean_cv_scores.append(mean_cv_score)
907
908 results = pd.DataFrame({"name": names, self.score_type: mean_cv_scores})

UnboundLocalError: local variable 'mean_cv_score' referenced before assignment

@AutoViML
Copy link
Owner

AutoViML commented Mar 14, 2021 via email

@ssth81456
Copy link

Thanks, updated to 0.0.36 and the issue is solved now.

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