import streamlit as st import pandas as pd from gimme5_predictor import generate_gimme5_prediction from la_predictor import generate_la_prediction, la_predict_star_ball from mb_predictor import generate_mb_prediction, mb_predict_star_ball from mm_predictor import generate_mm_prediction, mm_predict_star_ball from pb_predictor import generate_pb_prediction, pb_predict_star_ball from pb_predictor import clean_powerball_df from gimme5_predictor import get_hot_and_cold_numbers as g5_get_hot from la_predictor import get_hot_and_cold_numbers as la_get_hot from mb_predictor import get_hot_and_cold_numbers as mb_get_hot from mm_predictor import get_hot_and_cold_numbers as mm_get_hot from pb_predictor import get_hot_and_cold_numbers as pb_get_hot def display_wheel_table(hot_df, cold_df): """ 10 hot + 10 cold sayıdan oluşan wheel havuzunu tablo olarak gösterir. """ hot_numbers = [int(n) for n, _ in hot_df.values] cold_numbers = [int(n) for n, _ in cold_df.values] wheel_numbers = sorted(hot_numbers + cold_numbers) if len(wheel_numbers) == 20: wheel_labels = list("ABCDEFGHIJKLMNOPQRST") wheel_df = pd.DataFrame([wheel_numbers], columns=wheel_labels) # Comment out # with st.expander("🎡 Your 20 Numbers to Wheel"): # st.table(wheel_df.style.hide(axis="index")) def display_hot_cold_tables(hot_df, cold_df): """ Var olan hot_df ve cold_df tablolarını düzgünce gösterir. """ hot_df.index = range(1, len(hot_df)+1) hot_df.index.name = 'No' cold_df.index = range(1, len(cold_df)+1) cold_df.index.name = 'No' with st.expander("🔥 Hot Numbers (Top 10)"): st.table(hot_df) with st.expander("❄️ Cold Numbers (Bottom 10)"): st.table(cold_df) st.set_page_config(page_title="Multi Lotto AI Engine", layout="centered") st.title("🎯 Lotto AI Engine (V1.3)") with st.expander("🛠️ Requirements (click to view)"): st.markdown(""" 1- powerball (pb) and megamillions (mm) game will be added. they also should have sum_range. **pb = 65 - 265** **mm = 75 - 280** 2- their regular numbers: **pb = 1-69** **mm = 1-70** their powerball: **pb = 1-26** **mm = 1-24** 3- a wheel will be added. it will contain 10 hot and 10 cold numbers. so it will be 20 numbers. it will be sorted. and later by using txt file which Randy provided to us, it will return 76 ticket combinations. """) with st.expander("🛠️ App Features (click to view)"): st.markdown(""" This app generates predictions based on past drawing data and client-specified rules: **1- Machine Learning Backbone:** The prediction engine is powered by a lightweight Random Forest algorithm trained on historical draw results. The model takes into account not only number frequencies but also the day of the week on which each draw occurred — recognizing patterns tied to specific weekdays. To maintain prediction accuracy, it is important to keep the CSV data files updated with the latest draw results, as the model adapts to evolving trends over time. **2- Recent Draw Awareness:** Includes 1 number from the most recent draw — selected based on its historical recurrence. (Occasionally replaced to maintain parity balance.) **3- Parity Balance Enforcement:** Every combination ensures either 2 even + 3 odd or 3 even + 2 odd numbers — avoiding rare, statistically weak patterns. **4- Sequential Pair Logic:** If enabled, the model guarantees at least one pair of consecutive numbers in the prediction. However, even when this option is disabled, such sequences may still appear by chance — as they are statistically common in lottery draws. **5- Weighted Frequency System:** Numbers are chosen based on long-term frequency, with extra emphasis on trends from the last 30 days. **6- Total Sum Range Enforcement:** Each predicted combination must fall within a predefined total sum range — based on statistical analysis of past results. Gimme5: total must be between 40–160 LA (Lotto America): total must be between 70–210 MB (Megabucks): total must be between 45–165 This rule helps eliminate outlier combinations with abnormally low or high totals, which historically have a lower likelihood of being drawn. If a generated set falls outside the allowed range, the system regenerates a new one until the condition is satisfied. **7- Fortuna favet ludens, qui non ludit, non vincit, In ludo est spes** """) lotto_type = st.selectbox( "Select Lotto Type:", options=["LA (Lotto America)", "MB (Megabucks)", "G5 (Gimme 5)", "MM (Mega Millions)", "PB (Powerball)"], index=0 ) DATA_PATHS = { "G5 (Gimme 5)": "data/gimme5_results.csv", "LA (Lotto America)": "data/la_results.csv", "MB (Megabucks)": "data/mb_results.csv", "MM (Mega Millions)": "data/mm_results.csv", "PB (Powerball)": "data/pb_results.csv" } g5_df = pd.read_csv(DATA_PATHS["G5 (Gimme 5)"]) la_df = pd.read_csv(DATA_PATHS["LA (Lotto America)"]) mb_df = pd.read_csv(DATA_PATHS["MB (Megabucks)"]) mm_df = pd.read_csv(DATA_PATHS["MM (Mega Millions)"]) #POWERBALL SPECIAL CLEANING raw = pd.read_csv(DATA_PATHS["PB (Powerball)"]) pb_df = clean_powerball_df(raw) #DELETE ROWS WHICH CONTAINS "DOUBLE PLAY" #WE CALCULATE HOT-COLD NUMBERS HERE hot_g5, cold_g5 = g5_get_hot(g5_df) hot_la, cold_la = la_get_hot(la_df) hot_mb, cold_mb = mb_get_hot(mb_df) hot_mm, cold_mm = mm_get_hot(mm_df) hot_pb, cold_pb = pb_get_hot(pb_df) try: data_path = DATA_PATHS[lotto_type] # For the table layout st.markdown(""" """, unsafe_allow_html=True) #GIMME5 if lotto_type == "G5 (Gimme 5)": use_sequence = st.checkbox("🔗 Include Sequential Numbers", value=False) if st.button("🎰 Generate Prediction"): result = generate_gimme5_prediction(g5_df, allow_sequences=use_sequence) st.success(f"🧠 Predicted Numbers: {result}") st.success("ℹ️ No Additional Number for Gimme5") st.info(f"🔢 Total Sum of Picks: {sum(result)}") #HOT-COLD NUMBERS hot_df = pd.DataFrame(hot_g5, columns=["Number", "Frequency"]) cold_df = pd.DataFrame(cold_g5, columns=["Number", "Frequency"]) display_hot_cold_tables(hot_df, cold_df) display_wheel_table(hot_df, cold_df) #LOTTO AMERICA elif lotto_type == "LA (Lotto America)": use_sequence = st.checkbox("🔗 Include Sequential Numbers", value=False) if st.button("🎰 Generate Prediction"): main_numbers = generate_la_prediction(la_df, allow_sequences=use_sequence) star_ball = la_predict_star_ball(la_df) st.success(f"🧠 Predicted Numbers: {main_numbers}") st.success(f"🌟 Predicted Star Ball: [{star_ball}]") st.info(f"🔢 Total Sum of Picks: {sum(main_numbers)}") #HOT AND COLD NUMBERS hot_df = pd.DataFrame(hot_la, columns=["Number", "Frequency"]) cold_df = pd.DataFrame(cold_la, columns=["Number", "Frequency"]) display_hot_cold_tables(hot_df, cold_df) display_wheel_table(hot_df, cold_df) #MEGABUCKS elif lotto_type == "MB (Megabucks)": use_sequence = st.checkbox("🔗 Include Sequential Numbers", value=False) if st.button("🎰 Generate Prediction"): main_numbers = generate_mb_prediction(mb_df, allow_sequences=use_sequence) star_ball = mb_predict_star_ball(mb_df) st.success(f"🧠 Predicted Numbers: {main_numbers}") st.success(f"🌟 Predicted Megabucks Number: [{star_ball}]") st.info(f"🔢 Total Sum of Picks: {sum(main_numbers)}") #HOT AND COLD NUMBERS hot_df = pd.DataFrame(hot_mb, columns=["Number", "Frequency"]) cold_df = pd.DataFrame(cold_mb, columns=["Number", "Frequency"]) display_hot_cold_tables(hot_df, cold_df) display_wheel_table(hot_df, cold_df) #MEGA MILLIONS elif lotto_type == "MM (Mega Millions)": use_sequence = st.checkbox("🔗 Include Sequential Numbers", value=False) if st.button("🎰 Generate Prediction"): main_numbers = generate_mm_prediction(mm_df, allow_sequences=use_sequence) star_ball = mm_predict_star_ball(mm_df) st.success(f"🧠 Predicted Numbers: {main_numbers}") st.success(f"🌟 Predicted Mega Ball Number: [{star_ball}]") st.info(f"🔢 Total Sum of Picks: {sum(main_numbers)}") #HOT AND COLD NUMBERS hot_df = pd.DataFrame(hot_mm, columns=["Number", "Frequency"]) cold_df = pd.DataFrame(cold_mm, columns=["Number", "Frequency"]) display_hot_cold_tables(hot_df, cold_df) display_wheel_table(hot_df, cold_df) #POWER BALL elif lotto_type == "PB (Powerball)": use_sequence = st.checkbox("🔗 Include Sequential Numbers", value=False) if st.button("🎰 Generate Prediction"): main_numbers = generate_pb_prediction(pb_df, allow_sequences=use_sequence) star_ball = pb_predict_star_ball(pb_df) st.success(f"🧠 Predicted Numbers: {main_numbers}") st.success(f"🌟 Predicted Powerball Number: [{star_ball}]") st.info(f"🔢 Total Sum of Picks: {sum(main_numbers)}") #HOT AND COLD NUMBERS hot_df = pd.DataFrame(hot_pb, columns=["Number", "Frequency"]) cold_df = pd.DataFrame(cold_pb, columns=["Number", "Frequency"]) display_hot_cold_tables(hot_df, cold_df) display_wheel_table(hot_df, cold_df) except FileNotFoundError: st.error(f"❌ File not found: `{data_path}`") except Exception as e: st.error(f"⚠️ Error: {str(e)}")