You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
from db import * |
|
from util import * |
|
|
|
|
|
# last_data = get_last_data() |
|
# print(last_data) |
|
# |
|
# date_id_data = get_data_by_date_id('2023068') |
|
# print(date_id_data) |
|
|
|
# 获取全部数据 |
|
def get_all_data(): |
|
return db_get_all_data() |
|
|
|
|
|
# 获取所有篮球的统计数据 |
|
def get_all_blue(): |
|
all_blue = dict() |
|
all_data = db_get_all_data() |
|
if all_data is not False: |
|
for data in all_data: |
|
if data['blue'] in all_blue.keys(): |
|
all_blue[data['blue']] += 1 |
|
else: |
|
all_blue[data['blue']] = 1 |
|
return dict_sort(all_blue) |
|
else: |
|
return False |
|
|
|
|
|
# 获取蓝球统计次数与平均值的额偏差 |
|
def get_delta_blue(_blue_data): |
|
total = 0 |
|
if _blue_data is not False: |
|
for _num in _blue_data.values(): |
|
total += _num |
|
average = total / len(_blue_data.keys()) |
|
print(average) |
|
_delta_blue_dict = dict() |
|
for _key, _val in _blue_data.items(): |
|
_delta_blue_dict[_key] = _blue_data[_key] - average |
|
return _delta_blue_dict |
|
|
|
|
|
print(get_delta_blue(get_all_blue())) |
|
|
|
|
|
# 获取预测的数据 |
|
def get_blue_forecast(_blue_data, _method, _num): |
|
last_blue = db_get_last_data()['blue'] |
|
if last_blue is False: |
|
return False |
|
if _method == 'prv': # 当前一期往前推num期,包含此期数据 |
|
prv_blue_id_list = [] |
|
for _data in _blue_data: |
|
if _data['blue'] == last_blue: |
|
print(_data) |
|
prv_blue_id_list.append(_data['id']) |
|
print(prv_blue_id_list) |
|
elif _method == 'post': # 当前一期往后num期,不包含此期的数据 |
|
pass |
|
else: |
|
return False |
|
|
|
|
|
get_blue_forecast(get_all_data(), 'prv', 5)
|
|
|