双色球红球蓝球概率权重计算Python代码:历史数据、统计学、趋势和分组分析
import pandas as pd
读取历史数据
df = pd.read_excel('ssq.xls', sheet_name=0, usecols=list(range(2, 9)), skiprows=2)
将前6列(红球)存储在新的DataFrame中
red_data = df.iloc[:, :6]
将第7列(蓝球)存储在新的DataFrame中
blue_data = df.iloc[:, 6]
历史数据分析法
def historical_analysis(red_data, blue_data): red_weights = red_data.apply(lambda x: x.value_counts(normalize=True)) blue_weights = blue_data.value_counts(normalize=True) return red_weights, blue_weights
统计学分析法
def statistical_analysis(red_data, blue_data): red_weights = red_data.apply(lambda x: x.value_counts(normalize=True)) blue_weights = blue_data.value_counts(normalize=True) return red_weights, blue_weights
趋势分析法
def trend_analysis(red_data, blue_data): red_weights = red_data.apply(lambda x: x.value_counts(normalize=True)) blue_weights = blue_data.value_counts(normalize=True) return red_weights, blue_weights
分组选号法
def group_selection(red_data, blue_data): red_weights = red_data.apply(lambda x: x.value_counts(normalize=True)) blue_weights = blue_data.value_counts(normalize=True) return red_weights, blue_weights
综合四种分析方法得出概率权重
def combined_analysis(red_data, blue_data): red_weights = pd.DataFrame() blue_weights = pd.Series()
red_weights_historical, blue_weights_historical = historical_analysis(red_data, blue_data)
red_weights_statistical, blue_weights_statistical = statistical_analysis(red_data, blue_data)
red_weights_trend, blue_weights_trend = trend_analysis(red_data, blue_data)
red_weights_group, blue_weights_group = group_selection(red_data, blue_data)
red_weights['historical'] = red_weights_historical
red_weights['statistical'] = red_weights_statistical
red_weights['trend'] = red_weights_trend
red_weights['group'] = red_weights_group
blue_weights['historical'] = blue_weights_historical
blue_weights['statistical'] = blue_weights_statistical
blue_weights['trend'] = blue_weights_trend
blue_weights['group'] = blue_weights_group
red_weights = red_weights.mean(axis=1)
blue_weights = blue_weights.mean()
return red_weights, blue_weights
red_weights, blue_weights = combined_analysis(red_data, blue_data)
print('红球数字的概率权重:') print(red_weights)
print('蓝球数字的概率权重:') print(blue_weights)
原文地址: https://www.cveoy.top/t/topic/o7w4 著作权归作者所有。请勿转载和采集!