This repository contains a comprehensive Eurojackpot lottery analysis and prediction system including: - Historical data analysis and processing - ML-based prediction models - Automated weekly tip generation - Position and range analysis tools - Notification system for results 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
218 lines
8.3 KiB
Python
218 lines
8.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Eurojackpot Bereichsanalyse
|
|
|
|
Analysiert, in welchen Zahlenbereichen am häufigsten Zahlen gezogen wurden.
|
|
"""
|
|
|
|
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
import seaborn as sns
|
|
import numpy as np
|
|
from collections import Counter
|
|
|
|
def load_drawn_numbers(filepath):
|
|
"""Lädt die gezogenen Eurojackpot-Zahlen."""
|
|
try:
|
|
df = pd.read_csv(filepath, sep=';')
|
|
print(f"Gezogene Zahlen geladen: {len(df)} Ziehungen")
|
|
print(f"Spalten: {list(df.columns)}")
|
|
return df
|
|
except Exception as e:
|
|
print(f"Fehler beim Laden: {e}")
|
|
return None
|
|
|
|
def analyze_number_ranges(df):
|
|
"""Analysiert die Häufigkeit von Zahlen in verschiedenen Bereichen."""
|
|
|
|
# Alle gezogenen Zahlen sammeln (Z1-Z5)
|
|
all_numbers = []
|
|
for col in ['Z1', 'Z2', 'Z3', 'Z4', 'Z5']:
|
|
all_numbers.extend(df[col].tolist())
|
|
|
|
print(f"Gesamtanzahl gezogene Zahlen: {len(all_numbers)}")
|
|
|
|
# Häufigkeit jeder Zahl
|
|
number_counts = Counter(all_numbers)
|
|
|
|
# Bereiche definieren
|
|
ranges = {
|
|
'1-10': (1, 10),
|
|
'11-20': (11, 20),
|
|
'21-30': (21, 30),
|
|
'31-40': (31, 40),
|
|
'41-50': (41, 50)
|
|
}
|
|
|
|
# Analyse pro Bereich
|
|
range_analysis = {}
|
|
|
|
for range_name, (start, end) in ranges.items():
|
|
numbers_in_range = [num for num in all_numbers if start <= num <= end]
|
|
|
|
range_analysis[range_name] = {
|
|
'anzahl_ziehungen': len(numbers_in_range),
|
|
'prozent': (len(numbers_in_range) / len(all_numbers)) * 100,
|
|
'haeufigste_zahl': max(number_counts.items(),
|
|
key=lambda x: x[1] if start <= x[0] <= end else 0),
|
|
'durchschnitt': np.mean(numbers_in_range) if numbers_in_range else 0,
|
|
'zahlen_im_bereich': sorted(set(numbers_in_range))
|
|
}
|
|
|
|
return range_analysis, number_counts
|
|
|
|
def create_visualizations(range_analysis, number_counts, output_dir):
|
|
"""Erstellt Visualisierungen der Analyse."""
|
|
|
|
# 1. Balkendiagramm: Häufigkeit pro Bereich
|
|
plt.figure(figsize=(12, 8))
|
|
|
|
ranges = list(range_analysis.keys())
|
|
counts = [range_analysis[r]['anzahl_ziehungen'] for r in ranges]
|
|
percentages = [range_analysis[r]['prozent'] for r in ranges]
|
|
|
|
plt.subplot(2, 2, 1)
|
|
bars = plt.bar(ranges, counts, color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FECA57'])
|
|
plt.title('Anzahl gezogener Zahlen pro Bereich', fontsize=14, fontweight='bold')
|
|
plt.ylabel('Anzahl Ziehungen')
|
|
plt.xticks(rotation=45)
|
|
|
|
# Prozente auf Balken anzeigen
|
|
for bar, pct in zip(bars, percentages):
|
|
plt.text(bar.get_x() + bar.get_width()/2, bar.get_height() + 5,
|
|
f'{pct:.1f}%', ha='center', va='bottom', fontweight='bold')
|
|
|
|
# 2. Heatmap: Häufigkeit einzelner Zahlen
|
|
plt.subplot(2, 2, 2)
|
|
numbers = list(range(1, 51))
|
|
frequencies = [number_counts.get(num, 0) for num in numbers]
|
|
|
|
# Als 5x10 Matrix darstellen
|
|
freq_matrix = np.array(frequencies).reshape(5, 10)
|
|
|
|
sns.heatmap(freq_matrix, annot=True, fmt='d', cmap='YlOrRd',
|
|
xticklabels=list(range(1, 11)),
|
|
yticklabels=[f'{i*10+1}-{(i+1)*10}' for i in range(5)])
|
|
plt.title('Häufigkeit einzelner Zahlen', fontsize=14, fontweight='bold')
|
|
|
|
# 3. Liniendiagramm: Häufigkeit aller Zahlen
|
|
plt.subplot(2, 2, 3)
|
|
plt.plot(numbers, frequencies, marker='o', linewidth=2, markersize=4)
|
|
plt.title('Häufigkeitsverteilung aller Zahlen (1-50)', fontsize=14, fontweight='bold')
|
|
plt.xlabel('Zahl')
|
|
plt.ylabel('Häufigkeit')
|
|
plt.grid(True, alpha=0.3)
|
|
|
|
# Bereiche farblich markieren
|
|
colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FECA57']
|
|
for i, (range_name, color) in enumerate(zip(range_analysis.keys(), colors)):
|
|
start = i * 10 + 1
|
|
end = (i + 1) * 10
|
|
plt.axvspan(start, end, alpha=0.2, color=color, label=range_name)
|
|
|
|
plt.legend()
|
|
|
|
# 4. Pie Chart: Prozentuale Verteilung
|
|
plt.subplot(2, 2, 4)
|
|
plt.pie(percentages, labels=ranges, autopct='%1.1f%%',
|
|
colors=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FECA57'],
|
|
startangle=90)
|
|
plt.title('Prozentuale Verteilung nach Bereichen', fontsize=14, fontweight='bold')
|
|
|
|
plt.tight_layout()
|
|
plt.savefig(f'{output_dir}/eurojackpot_bereichsanalyse.png', dpi=300, bbox_inches='tight')
|
|
plt.show()
|
|
|
|
def print_detailed_analysis(range_analysis, number_counts):
|
|
"""Gibt detaillierte Analyseergebnisse aus."""
|
|
|
|
print("\n" + "="*60)
|
|
print("🎯 EUROJACKPOT BEREICHSANALYSE")
|
|
print("="*60)
|
|
|
|
total_numbers = sum(analysis['anzahl_ziehungen'] for analysis in range_analysis.values())
|
|
|
|
for range_name, analysis in range_analysis.items():
|
|
print(f"\n📊 BEREICH {range_name}:")
|
|
print(f" Anzahl Ziehungen: {analysis['anzahl_ziehungen']:,}")
|
|
print(f" Prozentanteil: {analysis['prozent']:.2f}%")
|
|
print(f" Durchschnittswert: {analysis['durchschnitt']:.1f}")
|
|
|
|
# Top 3 Zahlen in diesem Bereich
|
|
start, end = map(int, range_name.split('-'))
|
|
range_numbers = [(num, count) for num, count in number_counts.items()
|
|
if start <= num <= end]
|
|
range_numbers.sort(key=lambda x: x[1], reverse=True)
|
|
|
|
print(f" Top 3 Zahlen: ", end="")
|
|
for i, (num, count) in enumerate(range_numbers[:3]):
|
|
print(f"{num} ({count}x)", end="")
|
|
if i < 2 and i < len(range_numbers) - 1:
|
|
print(", ", end="")
|
|
print()
|
|
|
|
# Allgemeine Statistiken
|
|
print(f"\n📈 ALLGEMEINE STATISTIKEN:")
|
|
print(f" Gesamte gezogene Zahlen: {total_numbers:,}")
|
|
print(f" Durchschnitt pro Bereich: {total_numbers/5:.1f}")
|
|
|
|
# Häufigste und seltenste Zahlen insgesamt
|
|
most_common = number_counts.most_common(5)
|
|
least_common = number_counts.most_common()[-5:]
|
|
|
|
print(f"\n🔥 HÄUFIGSTE ZAHLEN GESAMT:")
|
|
for i, (num, count) in enumerate(most_common, 1):
|
|
print(f" {i}. Zahl {num}: {count} mal gezogen")
|
|
|
|
print(f"\n❄️ SELTENSTE ZAHLEN GESAMT:")
|
|
for i, (num, count) in enumerate(reversed(least_common), 1):
|
|
print(f" {i}. Zahl {num}: {count} mal gezogen")
|
|
|
|
# Empfehlungen
|
|
print(f"\n💡 ERKENNTNISSE:")
|
|
best_range = max(range_analysis.keys(), key=lambda x: range_analysis[x]['prozent'])
|
|
worst_range = min(range_analysis.keys(), key=lambda x: range_analysis[x]['prozent'])
|
|
|
|
print(f" • Bester Bereich: {best_range} ({range_analysis[best_range]['prozent']:.1f}%)")
|
|
print(f" • Schwächster Bereich: {worst_range} ({range_analysis[worst_range]['prozent']:.1f}%)")
|
|
print(f" • Unterschied: {range_analysis[best_range]['prozent'] - range_analysis[worst_range]['prozent']:.1f} Prozentpunkte")
|
|
|
|
def main():
|
|
"""Hauptfunktion."""
|
|
|
|
# Pfade
|
|
input_file = "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/Eurojackpot/data/AlleEurojackpotzahlen.csv"
|
|
output_dir = "/Users/sebastianfrohlich/Library/Mobile Documents/com~apple~CloudDocs/Jupyter Notebooks/Eurojackpot"
|
|
|
|
# Daten laden
|
|
print("🔄 Lade Eurojackpot-Daten...")
|
|
df = load_drawn_numbers(input_file)
|
|
|
|
if df is None:
|
|
print("❌ Fehler beim Laden der Daten!")
|
|
return
|
|
|
|
# Analyse durchführen
|
|
print("\n🔍 Führe Bereichsanalyse durch...")
|
|
range_analysis, number_counts = analyze_number_ranges(df)
|
|
|
|
# Ergebnisse ausgeben
|
|
print_detailed_analysis(range_analysis, number_counts)
|
|
|
|
# Visualisierungen erstellen
|
|
print(f"\n📊 Erstelle Visualisierungen...")
|
|
try:
|
|
create_visualizations(range_analysis, number_counts, output_dir)
|
|
print(f"✅ Diagramm gespeichert: {output_dir}/eurojackpot_bereichsanalyse.png")
|
|
except Exception as e:
|
|
print(f"⚠️ Visualisierung konnte nicht erstellt werden: {e}")
|
|
print("💡 Installieren Sie matplotlib und seaborn: pip install matplotlib seaborn")
|
|
|
|
# CSV-Export der Analyse
|
|
results_df = pd.DataFrame.from_dict(range_analysis, orient='index')
|
|
results_df.to_csv(f'{output_dir}/bereichsanalyse_ergebnisse.csv', sep=';')
|
|
print(f"✅ Ergebnisse gespeichert: {output_dir}/bereichsanalyse_ergebnisse.csv")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|