472,328 Members | 1,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Help with Iteration

i have a python script that is computing ratings of sports teams.

what i'm trying to do is setup an iteration for the rating so that the
python program recomputes the rating if any of the value difference is
0.00005. it's common for sports ratings to run such iterations...
any tips, pointers on where to look on how to do this the best way?

right now i'm getting the ratings from the file, limiting my results
to 1 entry, the biggest number, if it's 0.00005, then i want it to
compute the ratings again. if it is < 0.00005 then it just goes on to
the next step in the file.

thnx in advance.
Oct 18 '08 #1
6 1108
On Oct 17, 10:44*pm, Chris McComas <mccomas.ch...@gmail.comwrote:
i have a python script that is computing ratings of sports teams.

what i'm trying to do is setup an iteration for the rating so that the
python program recomputes the rating if any of the value difference is
0.00005. it's common for sports ratings to run such iterations...

any tips, pointers on where to look on how to do this the best way?

right now i'm getting the ratings from the file, limiting my results
to 1 entry, the biggest number, if it's 0.00005, then i want it to
compute the ratings again. if it is < 0.00005 then it just goes on to
the next step in the file.

thnx in advance.
Can you cut and paste a few lines? Otherwise I assume your file looks
like this:

A 0.00001
B 0.00003
C 0.00006

You interpret the file like this:

name= A, rating= 0.00001
name= B, rating= 0.00003
name= C, rating= 0.00006
--recompute--

new values:
name= A, rating= 0.00001
name= B, rating= 0.00002
name= C, rating= 0.00004

new file:
A 0.00001
B 0.00002
C 0.00004

Am I right so far?
Oct 18 '08 #2
On Oct 18, 12:43 am, "Aaron \"Castironpi\" Brady"
<castiro...@gmail.comwrote:
On Oct 17, 10:44 pm, Chris McComas <mccomas.ch...@gmail.comwrote:
i have a python script that is computing ratings of sports teams.
what i'm trying to do is setup an iteration for the rating so that the
python program recomputes the rating if any of the value difference is
0.00005. it's common for sports ratings to run such iterations...
any tips, pointers on where to look on how to do this the best way?
right now i'm getting the ratings from the file, limiting my results
to 1 entry, the biggest number, if it's 0.00005, then i want it to
compute the ratings again. if it is < 0.00005 then it just goes on to
the next step in the file.
thnx in advance.

Can you cut and paste a few lines? Otherwise I assume your file looks
like this:

A 0.00001
B 0.00003
C 0.00006

You interpret the file like this:

name= A, rating= 0.00001
name= B, rating= 0.00003
name= C, rating= 0.00006
--recompute--

new values:
name= A, rating= 0.00001
name= B, rating= 0.00002
name= C, rating= 0.00004

new file:
A 0.00001
B 0.00002
C 0.00004

Am I right so far?
actually i'm running it online, with a mysql db. so in the db there is
a table CollegeYear with the following fields:

name
rating
change
wp

then another table Games

date
year
team_1
team_1_score
team_2
team_2_score

it goes through and calculates everything, then when it's time to
compute the rating i have say this code:

http://dpaste.com/85300/

it goes through and computes them, then add the new rating and
absolute value of the changed rating to the db. what i need now is a
way to get the largest entry for 'change' and if it is greater than
0.00005 then do this code again. if it is less than 0.00005 then we're
done.
Oct 18 '08 #3
Chris McComas wrote:
actually i'm running it online, with a mysql db. so in the db there is
a table CollegeYear with the following fields:

name
rating
change
wp

then another table Games

date
year
team_1
team_1_score
team_2
team_2_score

it goes through and calculates everything, then when it's time to
compute the rating i have say this code:

http://dpaste.com/85300/

it goes through and computes them, then add the new rating and
absolute value of the changed rating to the db. what i need now is a
way to get the largest entry for 'change' and if it is greater than
0.00005 then do this code again. if it is less than 0.00005 then we're
done.
What about "SELECT MAX( rating ) FROM CollegeYear"?

Oct 18 '08 #4
On Oct 18, 3:46 pm, Aaron Brady <castiro...@gmail.comwrote:
Chris McComas wrote:
actually i'm running it online, with a mysql db. so in the db there is
a table CollegeYear with the following fields:
name
rating
change
wp
then another table Games
date
year
team_1
team_1_score
team_2
team_2_score
it goes through and calculates everything, then when it's time to
compute the rating i have say this code:
http://dpaste.com/85300/
it goes through and computes them, then add the new rating and
absolute value of the changed rating to the db. what i need now is a
way to get the largest entry for 'change' and if it is greater than
0.00005 then do this code again. if it is less than 0.00005 then we're
done.

What about "SELECT MAX( rating ) FROM CollegeYear"?
Aaron,

Thnx. To clarify I can get the max, that wasn't the issue, what I'm
failing to try and visualise/figure out is how do I say, okay if MAX >
0.00005 run this again, if MAX < 0.00005 you're done.
Oct 19 '08 #5
On Oct 19, 11:59*am, Chris McComas <mccomas.ch...@gmail.comwrote:
On Oct 18, 3:46 pm, Aaron Brady <castiro...@gmail.comwrote:
Chris McComas wrote:
actually i'm running it online, with a mysql db. so in the db there is
a table CollegeYear with the following fields:
name
rating
change
wp
then another table Games
date
year
team_1
team_1_score
team_2
team_2_score
it goes through and calculates everything, then when it's time to
compute the rating i have say this code:
>http://dpaste.com/85300/
What is the point of this:

if games.team_1_score games.team_2_score
t1_rating = t2_rating + t1_wp - .5
t2_rating = t1_rating + t2_wp - .5
elif games.team_1_score < games.team_2_score
t1_rating = t2_rating + t1_wp - .5
t2_rating = t1_rating + t2_wp - .5
elif games.team_1_score == games.team_2_score
t1_rating = t2_rating + t1_wp - .5
t2_rating = t1_rating + t2_wp - .5

You have the same code for each of the three conditions. Where are the
colons? Have you actually tried to execute this code? Any good reason
why the second elif is not an else?

>
it goes through and computes them, then add the new rating and
absolute value of the changed rating to the db. what i need now is a
way to get the largest entry for 'change' and if it is greater than
0.00005 then do this code again. if it is less than 0.00005 then we're
done.
What about "SELECT MAX( rating ) FROM CollegeYear"?

Aaron,

Thnx. To clarify I can get the max, that wasn't the issue, what I'm
failing to try and visualise/figure out is how do I say, okay if MAX >
0.00005 run this again, if MAX < 0.00005 you're done.
[Aside: if MAX == 0.00005, what? Go into a catatonic trance?]

Let me get this straight: Is this your first program? Are you asking
how to code a while loop?
Oct 19 '08 #6
Chris McComas wrote:
On Oct 18, 3:46 pm, Aaron Brady <castiro...@gmail.comwrote:
>Chris McComas wrote:
actually i'm running it online, with a mysql db. so in the db there is
a table CollegeYear with the following fields:
name
rating
change
wp
then another table Games
date
year
team_1
team_1_score
team_2
team_2_score
it goes through and calculates everything, then when it's time to
compute the rating i have say this code:
>http://dpaste.com/85300/
it goes through and computes them, then add the new rating and
absolute value of the changed rating to the db. what i need now is a
way to get the largest entry for 'change' and if it is greater than
0.00005 then do this code again. if it is less than 0.00005 then we're
done.

What about "SELECT MAX( rating ) FROM CollegeYear"?

Aaron,

Thnx. To clarify I can get the max, that wasn't the issue, what I'm
failing to try and visualise/figure out is how do I say, okay if MAX >
0.00005 run this again, if MAX < 0.00005 you're done.
I don't know.

while 1:
calculate_stuff( )
if stuff < 0.00005:
break

Oct 19 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xenophobe | last post by:
I'm having a brain freeze on how to go about creating the logic for evenly distributing a group of items in rotation through multiple iterations....
35
by: Raymond Hettinger | last post by:
Here is a discussion draft of a potential PEP. The ideas grew out of the discussion on pep-284. Comments are invited. Dart throwing is optional. ...
2
by: Abdullah Khaidar | last post by:
Is there any iteration style we must use to get faster processing time? I've tried with some style to concat number in list. But I still don't know...
2
by: LoserInYourFaceEngineer | last post by:
Hello All: I'm having trouble with a recursive function. The function is supposed to identify nested folders in a hierarchical folder...
7
by: Shane | last post by:
Hi, Thanks in advance for the help. I have been to many websites and tried several solutions to my problem, but have fixed part of it. It's...
5
by: Nikola | last post by:
I need to write a program that generates 5 random numbers and puts them into a linked list. (Print the list) From that list it forms another list in...
43
by: ZillionDollarSadist | last post by:
Hello, I'm working at a simple Access '97 + VB4 application, and I ran into a terrible problem: something I never modified now gives me a totally...
75
by: Sathyaish | last post by:
Can every problem that has an iterative solution also be expressed in terms of a recursive solution? I tried one example, and am in the process...
2
by: wuzertheloser | last post by:
Develop a program which computes the current value of the vector {x} based on the following forward iteration: {x}(n+1) = {x}(n), n = 0,1,2,...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.