Compare commits

..
14 Commits
8 changed files with 64 additions and 28 deletions
+2 -7
View File
@@ -9,7 +9,7 @@ Previously there were records dating back to 1992 that were removed by the websi
I am welcoming anyone who wants to to port it to their own state/country to do so. I currently have a website www.wvlotterypredictor.xyz hosting my numbers to be refreshed daily. Collaboration and suggestion to a more accurate algorithm is also welcome. I can be contacted about the project through my site email, on here, or on the Twitter linked on my site.
# How the site works
- Each game has its own script. It pulls every past draw from the WV Lottery results api (the same one wvlottery.com uses for its past draws page), adds the older records from the excel files where there are any, and counts how often each number has been drawn.
- Each game has its own script. It pulls every past draw from the WV Lottery results api (the same one wvlottery.com uses for its past draws page), adds the older records from the excel files where there are any, and counts how often each number has been drawn. The chance shown is the actual odds of that ticket hitting, every ticket has the same odds so the forecast is just going with the numbers that have been called the most.
- On the site the scripts write their numbers to a csv instead of printing them. cron runs each one about 45 minutes after that game's drawing so the new numbers are already posted.
- The site itself is Django served by gunicorn behind nginx. It reads the csv files for the home page and caches the page in redis, which gets cleared every hour.
@@ -17,10 +17,5 @@ I am welcoming anyone who wants to to port it to their own state/country to do s
# CHANGELOG
- September 26th 2026: wvlottery.com was rebuilt and the old history tables are gone, so every script now pulls past draws from the json results api the new site uses. Added Cash Pop. Updated Mega Millions odds for the 2025 changes.
- September 26th 2026 (later): The excel records were never actually getting counted (they use - and the site used –), they are now. Numbers that cant be drawn anymore since the ball ranges changed get skipped. Chance is now the real odds of the forecast ticket winning instead of the frequency number, Daily3 and Daily4 are the odds for a box play.
- June 29th 2022: Added support for old data that was previously scrubbed from the lottery site. It is more accurate and includes more data than the previous one. Chance for daily3 is now bugged however due to the large amount of numbers and dates. This will be fixed soon.
# TODO:
- Correct chance numbers for Daily3
+9 -3
View File
@@ -1,5 +1,6 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from math import comb
import pandas as pd
import requests
from collections import Counter
@@ -38,11 +39,15 @@ def get_data():
date, nums = get_data()
# Formatting
# Site numbers come split by – and the excel records by - so it splits on both
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
hyphenfree.append(x.replace('–',', ').replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only count numbers that can still be called, the ball ranges have changed over the years
# so the old records have some numbers that dont exist in the game anymore
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 25]
for n in range(0, 25):
most_common= Counter(sep).most_common(6)
@@ -50,8 +55,9 @@ for n in range(0, 25):
frequency = [v[-1] for v in most_common]
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency)
Chance = frac(total_freq, 177100) # Chance = number call freq / all possible numbers i.e. 177100
# Chance = 1 / every possible ticket, 25 choose 6 = 177100
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
Chance = frac(1, comb(25, 6))
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} \n"
+2
View File
@@ -34,6 +34,8 @@ for x in nums:
hyphenfree.append(x.replace('–',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only keep 1 - 15, just in case anything weird comes back from the site
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 15]
for n in range(0, 15):
most_common= Counter(sep).most_common(3)
+13 -6
View File
@@ -6,6 +6,10 @@ from collections import Counter
def get_data():
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
df_old = pd.read_excel('./excel_lotto_records/daily3.xlsx')
salvaged = df_old[['Date', 'Numbers']]
url = 'https://gateway.loyalty.wvlottery.com/services/jackpot/api/v1/jackpot-results?gameId=9&jackpotStatus=PAYABLE&size=500&sort=externalId,drawDate,desc&page='
header = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36",
@@ -25,7 +29,7 @@ def get_data():
dfs = [pd.DataFrame(web)]
pd.set_option('display.max_rows', None)
# Specifies no max rows, otherwise only shows 10 records
df = dfs[0]
df = pd.concat([dfs[0], salvaged], ignore_index=True)
df2 = df[['Date', 'Numbers']]
date = list(df2['Date'])
nums = list(df2['Numbers'].astype('str'))
@@ -34,11 +38,14 @@ def get_data():
date, nums = get_data()
# Formatting
# Site numbers come split by – and the excel records by - so it splits on both
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
hyphenfree.append(x.replace('–',', ').replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only keep actual digits, gets rid of any blanks from the excel records
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
for n in range(0, 10):
most_common= Counter(sep).most_common(3)
@@ -46,10 +53,10 @@ for n in range(0, 10):
frequency = [v[-1] for v in most_common]
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency)
Chance = frac(total_freq, 15000) # Chance = number call freq / all possible numbers i.e. 1000
# Chance = playing the forecast as a box (any order), 3 different digits can come up 6 ways out of 1000 = 3/500
# playing it straight (exact order) is 1/1000
Chance = frac(6, 1000)
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} \n"
f"With percent chance of winning being {Chance} \n"
f"DISCLAIMER: This set's chance is innacurate due to how many numbers are drawn per day.")
f"With percent chance of winning being {Chance}")
+7 -3
View File
@@ -38,11 +38,14 @@ def get_data():
date, nums = get_data()
# Formatting
# Site numbers come split by – and the excel records by - so it splits on both
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
hyphenfree.append(x.replace('–',', ').replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only keep actual digits, gets rid of any blanks from the excel records
sep = [x for x in sep if x.isdigit() and int(x) <= 9]
for n in range(0, 9):
most_common= Counter(sep).most_common(4)
@@ -50,8 +53,9 @@ for n in range(0, 9):
frequency = [v[-1] for v in most_common]
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency)
Chance = frac(total_freq, 10000) # Chance = number call freq / all possible numbers i.e. 10000
# Chance = playing the forecast as a box (any order), 4 different digits can come up 24 ways out of 10000 = 3/1250
# playing it straight (exact order) is 1/10000
Chance = frac(24, 10000)
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} \n"
+11 -3
View File
@@ -1,11 +1,13 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from math import comb
import pandas as pd
import requests
from collections import Counter
def get_data():
# Old records from the excel sheets, wvlottery.com took these down but they go back to the early 90s on some games
df_old = pd.read_excel('./excel_lotto_records/lotto_america.xlsx')
salvaged = df_old[['Date', 'Numbers', 'SB']]
@@ -39,11 +41,16 @@ def get_data():
date, nums, SBs = get_data()
# Formatting
# Site numbers come split by – and the excel records by - so it splits on both
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
hyphenfree.append(x.replace('–',', ').replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only count numbers that can still be called, the ball ranges have changed over the years
# so the old records have some numbers that dont exist in the game anymore
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 52]
SBs = [x for x in SBs if 1 <= x <= 10]
for n in range(0, 52):
most_common= Counter(sep).most_common(5)
@@ -56,8 +63,9 @@ for n in range(0, 10):
frequency_sb = [v[-1] for v in most_common_sb]
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency + frequency_sb)
Chance = frac(total_freq, 25989600) # Chance = number call freq / all possible numbers i.e. 25,989,600
# Chance = 1 / every possible ticket, 52 choose 5 white balls times 10 star balls = 25989600
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
Chance = frac(1, comb(52, 5) * 10)
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} SB: {SB}\n"
+10 -3
View File
@@ -1,5 +1,6 @@
# WVLottopy: Matteo DiBiagio
from fractions import Fraction as frac
from math import comb
import pandas as pd
import requests
from collections import Counter
@@ -41,11 +42,16 @@ def get_data():
date, nums, PBs = get_data()
# Formatting
# Site numbers come split by – and the excel records by - so it splits on both
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
hyphenfree.append(x.replace('–',', ').replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only count numbers that can still be called, the ball ranges have changed over the years
# so the old records have some numbers that dont exist in the game anymore
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 69]
PBs = [x for x in PBs if 1 <= x <= 26]
for n in range(0, 69):
most_common = Counter(sep).most_common(5)
@@ -58,8 +64,9 @@ for n in range(0, 26):
frequency_pb = [v[-1] for v in most_common_pb]
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency + frequency_pb)
Chance = frac(total_freq, 292201338) # Chance = number call freq / all possible numbers i.e. 292201338
# Chance = 1 / every possible ticket, 69 choose 5 white balls times 26 powerballs = 292201338
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
Chance = frac(1, comb(69, 5) * 26)
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} PB: {PB}\n"
+10 -3
View File
@@ -1,5 +1,6 @@
# WVLottopy megamil: Matteo DiBiagio
from fractions import Fraction as frac
from math import comb
import pandas as pd
import requests
from collections import Counter
@@ -40,11 +41,16 @@ def get_data():
date, nums, MBs = get_data()
# Formatting
# Site numbers come split by – and the excel records by - so it splits on both
hyphenfree = []
for x in nums:
hyphenfree.append(x.replace('–',', '))
hyphenfree.append(x.replace('–',', ').replace('-',', '))
splitlist = ", ".join(hyphenfree)
sep = splitlist.split(", ")
# Only count numbers that can still be called, the ball ranges have changed over the years
# so the old records have some numbers that dont exist in the game anymore
sep = [x for x in sep if x.isdigit() and 1 <= int(x) <= 70]
MBs = [x for x in MBs if 1 <= x <= 24]
for n in range(0, 70):
most_common= Counter(sep).most_common(5)
@@ -57,8 +63,9 @@ for n in range(0, 25):
frequency_mb = [v[-1] for v in most_common_mb]
sorted_nums = sorted(likely_nums, key=lambda x: (len(x), x))
total_freq = sum(frequency + frequency_mb)
Chance = frac(total_freq, 290472336) # Chance = number call freq / all possible numbers i.e. 290472336
# Chance = 1 / every possible ticket, 70 choose 5 white balls times 24 mega balls = 290472336
# every ticket has the same odds, the forecast just goes with the numbers that get called the most
Chance = frac(1, comb(70, 5) * 24)
Forecast = str(" - ".join(sorted_nums))
print(f"Likely numbers are . . . {Forecast} MB: {MB}\n"