红球预测增加与上次有n个数一样的逻辑

main
RogerWork 10 months ago
parent 3f65f15a7f
commit 468511ddd9
  1. 15
      orm/blue_forecast.py
  2. 4
      orm/db.py
  3. 5
      orm/main.py
  4. 16
      orm/orm_db.py
  5. 38
      orm/red_forecast.py

@ -138,20 +138,24 @@ def get_interval_blue():
return dict_sort(blue_dict, 'val', True)
def print_blue_data(_history, _prv_five, _post_five, _prv_three, _post_three, _interval):
def print_blue_data(_history, _prv_five, _post_five, _prv_three, _post_three, _prv_one, _post_one, _interval):
_history_list = list(_history.items())
_prv_five_list = list(_prv_five.items())
_post_five_list = list(_post_five.items())
_prv_three_list = list(_prv_three.items())
_post_three_list = list(_post_three.items())
_prv_one_list = list(_prv_one.items())
_post_one_list = list(_post_one.items())
_interval_list = list(_interval.items())
print('篮球数据表:')
for i in range(16):
print(f"{_history_list[i][0]} [{_history_list[i][1]}]\t"
f" {_prv_five_list[i][0]} [{_prv_five_list[i][1]}]\t"
f"{_post_five_list[i][0]} [{_post_five_list[i][1]}]\t"
f"{_prv_one_list[i][0]} [{_prv_one_list[i][1]}]\t"
f"{_prv_three_list[i][0]} [{_prv_three_list[i][1]}]\t"
f" {_prv_five_list[i][0]} [{_prv_five_list[i][1]}]\t"
f"{_post_one_list[i][0]} [{_post_one_list[i][1]}]\t"
f"{_post_three_list[i][0]} [{_post_three_list[i][1]}]\t"
f"{_post_five_list[i][0]} [{_post_five_list[i][1]}]\t"
f"{_interval_list[i][0]} [{_interval_list[i][1]}]")
@ -162,10 +166,13 @@ def forecast_blue():
post_five = get_blue_forecast(get_all_data(), 'post', 5)
prv_three = get_blue_forecast(get_all_data(), 'prv', 3)
post_three = get_blue_forecast(get_all_data(), 'post', 3)
prv_one = get_blue_forecast(get_all_data(), 'prv', 1)
post_one = get_blue_forecast(get_all_data(), 'post', 1)
interval_blue = get_interval_blue()
insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_five), json.dumps(post_five), 5)
insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_three), json.dumps(post_three), 3)
print_blue_data(history_total, prv_five, post_five, prv_three, post_three, interval_blue)
insert_blue_data(all_data, json.dumps(history_total), json.dumps(prv_one), json.dumps(post_one), 1)
print_blue_data(history_total, prv_five, post_five, prv_three, post_three, prv_one, post_one, interval_blue)
if __name__ == "__main__":

@ -1,6 +1,6 @@
import json
from orm_db import History, BlueForecastFiveAll, BlueForecastThreeAll, RedForecastAll, IndexGroup
from orm_db import History, BlueForecastFiveAll, BlueForecastThreeAll, BlueForecastOneAll, RedForecastAll, IndexGroup
from sqlalchemy import engine
from sqlalchemy.orm import sessionmaker, declarative_base
from sqlalchemy import select, insert, update, desc, asc, and_
@ -75,6 +75,8 @@ def db_blue_insert(_data, _num):
_table = BlueForecastFiveAll
elif _num == 3:
_table = BlueForecastThreeAll
elif _num == 1:
_table = BlueForecastOneAll
else:
print('_num值错误')
blue_insert_stmt = insert(_table).values(_data)

@ -1,8 +1,9 @@
from blue_forecast import forecast_blue
from red_forecast import red_forecast
from red_forecast import red_forecast, red_forecast_with_same
from real_index import update_real_data
if __name__ == "__main__":
update_real_data()
forecast_blue()
red_forecast()
# red_forecast()
red_forecast_with_same(2)

@ -54,6 +54,22 @@ class BlueForecastThreeAll(Base):
history_index = Column(Integer, comment='历史中的蓝球索引')
class BlueForecastOneAll(Base):
__tablename__ = 'blue_forecast_one_all' # 定义表名
# 定义表结构
id = Column(Integer, autoincrement=True, primary_key=True)
dateId = Column(String(20), nullable=False, comment='期号')
real_blue = Column(String(10), comment='真实的蓝球数据')
prv = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中往前推5期,计算蓝球出现概率')
prv_index = Column(Integer, comment='根据实际结果计算蓝球的index位置')
post = Column(String(500), nullable=False,
comment='根据当前一期的蓝球,从历史数据中往后推5期,计算蓝球出现概率')
post_index = Column(Integer, comment='根据实际结果计算蓝球的index位置')
history = Column(String(500), nullable=False, comment='根据当前一期的蓝球,从历史数据中计算每个蓝球出现的概率')
history_index = Column(Integer, comment='历史中的蓝球索引')
class RedForecastAll(Base):
__tablename__ = 'red_forecast_all' # 定义表名

@ -78,18 +78,18 @@ def get_random_index(_mode='history', _index_type='history'):
random_high, random_middle, random_low = get_index_from_db(_index_type)
else:
random_high, random_middle, random_low = get_random_index_group()
print('分布区间(高概率区,中概率区,低概率区):', random_high, random_middle, random_low)
# print('分布区间(高概率区,中概率区,低概率区):', random_high, random_middle, random_low)
red_index_group = [int(random_high), int(random_middle), int(random_low)]
high_red_index_list = [(n[0] - 1) for n in new_num(1, 11, random_high)[0:random_high]]
middle_red_index_list = [(n[0] - 1) for n in new_num(12, 22, random_middle)[0:random_middle]]
low_red_index_list = [(n[0] - 1) for n in new_num(23, 33, random_low)[0:random_low]]
print(high_red_index_list)
print(middle_red_index_list)
print(low_red_index_list)
# print(high_red_index_list)
# print(middle_red_index_list)
# print(low_red_index_list)
red_index_list = sorted(high_red_index_list + middle_red_index_list + low_red_index_list)
red_index_list = [int(n) for n in red_index_list]
print(f"排序后索引")
print(red_index_list)
# print(f"排序后索引")
# print(red_index_list)
return red_index_group, red_index_list
@ -100,8 +100,7 @@ def get_forecast_red(_red_data, _index_type):
for i in index_list:
forecast_red_list.append(_red_data_list[i][0])
forecast_red_list = sorted(forecast_red_list)
print('随机红球推荐:')
print(forecast_red_list)
print('随机红球推荐:', forecast_red_list)
return {'forecast': forecast_red_list, 'group': index_group, 'index': index_list}
@ -138,6 +137,27 @@ def red_forecast():
insert_red_data(all_data, history_red_delta, forecast_red_history_data, last_red_delta, forecast_red_last_data)
def red_forecast_with_same(_num):
all_data = get_all_data()
last_red = json.loads(db_history_get_last_data()['red'])
history_red_delta = get_all_red_delta(all_data)
# print(all_red_delta)
last_red_delta = get_last_red_delta(get_all_red_in_last(all_data))
# print(last_red_delta)
print_data([history_red_delta, last_red_delta])
history_switch = True
while history_switch:
forecast_red_history_data = get_forecast_red(history_red_delta, 'history')
if len(list(set(forecast_red_history_data['forecast']) & set(last_red))) == _num:
history_switch = False
last_switch = True
while last_switch:
forecast_red_last_data = get_forecast_red(last_red_delta, 'last')
if len(list(set(forecast_red_last_data['forecast']) & set(last_red))) == _num:
last_switch = False
insert_red_data(all_data, history_red_delta, forecast_red_history_data, last_red_delta, forecast_red_last_data)
if __name__ == "__main__":
# all_data = get_all_data()
# history_red_delta = get_all_red_delta(all_data)
@ -148,5 +168,5 @@ if __name__ == "__main__":
# forecast_red_history_data = get_forecast_red(history_red_delta, 'history')
# forecast_red_last_data = get_forecast_red(last_red_delta, 'last')
# insert_red_data(all_data, history_red_delta, forecast_red_history_data, last_red_delta, forecast_red_last_data)
red_forecast_with_same(2)
pass

Loading…
Cancel
Save