zepen / predict_lottery_ticket Goto Github PK
View Code? Open in Web Editor NEW双色球+大乐透彩票AI预测
双色球+大乐透彩票AI预测
这模型能有效果?收敛吗?
因为每期都有开奖,如果调用api来获取预测结果,是不是先要跑训练模型,每次都要先抓最新的数据下来
如题,使用默认参数,经过多次训练后发现红球,蓝球每次都会在固定的数字附近徘徊,每次训练后的结果趋于固定的结果,请指教模型参数怎样调试
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacBook Air Apple M1 chip, macOS Monterey version 12.2
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
TensorFlow installed from (source or binary): binary
TensorFlow version: 2.1.0
Python version: 3.6.12
Installed using virtualenv? pip? conda?: pip3
Describe the problem
when i run
python train_model.py
[1] 59236 illegal hardware instruction python train_model.py
[5/5] RUN pip install --no-cache-dir -r requirements.txt:
#9 0.765 Collecting Flask==1.1.2
#9 1.189 Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
#9 1.765 ERROR: Could not find a version that satisfies the requirement tensorflow-cpu==2.6.1 (from versions: none)
#9 1.765 ERROR: No matching distribution found for tensorflow-cpu==2.6.1
executor failed running [/bin/sh -c pip install --no-cache-dir -r requirements.txt]: exit code: 1
Flask==1.1.2
tensorflow-cpu==2.6.2
tensorflow-addons==0.14.0
requests==2.22.0
beautifulsoup4==4.9.3
pandas==1.0.0
numpy==1.19.5
lxml==4.6.5
gunicorn==20.1.0
gevent==1.4.0
loguru==0.6.0
grpcio==1.46.0
protobuf==3.18.1
更新后按照这个配置能正常启动,麻烦楼主帮忙确认一下,是否有问题;
另外想请教下大神,当前的算法是基于之前出现的次数最少算出来的么。。模型有没有优化算法的想法或者计划。。
`2022-01-05 19:00:23.411489: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2022-01-05 19:00:23.411637: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2022-01-05 19:00:23.411655: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
2022-01-05 19:00:29.139770: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2022-01-05 19:00:29.139906: E tensorflow/stream_executor/cuda/cuda_driver.cc:351] failed call to cuInit: UNKNOWN ERROR (303)
2022-01-05 19:00:29.139977: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (leon): /proc/driver/nvidia/version does not exist
2022-01-05 19:00:29.159883: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2022-01-05 19:00:29.247429: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2904000000 Hz
2022-01-05 19:00:29.266784: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x6ec1b00 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2022-01-05 19:00:29.266858: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
[INFO] 已加载红球模型!
[INFO] 已加载蓝球模型!
其实彩票本身是一件随机事件,不过既然有数值,就有概率。我们可以排除一些概率最小的数字,建立一个排除列表,主要是红球,比如6个连续号码,这种概率是极低的。另外统计一下过往的连续号码最大位数和次数作为备选号码。还有一种就是重复开奖号码,如果重复开奖率极低,可以纳入排除列表。把范围缩小,概率自然就大一点。
问题1: bs4 只能安装 0.0.1版本
Could not fetch URL https://pypi.org/simple/bs4/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/bs4/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:841)'),)) - skipping
ERROR: Could not find a version that satisfies the requirement bs4==4.9.3
ERROR: No matching distribution found for bs4==4.9.3
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:841)'),)) - skipping
问题2: 执行 python get_train_data.py
Traceback (most recent call last):
File "get_train_data.py", line 64, in <module>
print("[INFO] 最新一期期号:{}".format(get_current_number()))
File "get_train_data.py", line 18, in get_current_number
soup = BeautifulSoup(r.text, "lxml")
File "E:\software\Python\lib\site-packages\bs4\__init__.py", line 246, in __init__
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
问题3: 执行python run_api.py
Traceback (most recent call last):
File "run_api.py", line 15, in <module>
model_red_1 = load_model('model/lstm_model_红球号码_1.h5')
File "E:\software\Python\lib\site-packages\tensorflow_core\python\keras\saving\save.py", line 149, in load_model
loader_impl.parse_saved_model(filepath)
File "E:\software\Python\lib\site-packages\tensorflow_core\python\saved_model\loader_impl.py", line 83, in parse_saved_model
constants.SAVED_MODEL_FILENAME_PB))
OSError: SavedModel file does not exist at: model/lstm_model_红球号码_1.h5/{saved_model.pbtxt|saved_model.pb}
你好 请问你这代码为什么不显示预测结果?还是你这代码只是显示往期已经开奖的号码?
如题,小菜对机器学习可以说是一无所知,能否对每个参数进行释义或者说明每个参数的用途
能否输出各个数字的概率数据,而不是单纯给一组号码。
比如红球 33 个,每个的概率在本期是多少,蓝球也是如此。
谢谢!
可以多出一些训练结果吗?还有config.py配置的规则是什么?
用这个版本tensorflow-cpu==2.2.0, 高版本的,tensorflow-addons不支持了
我使用的虚拟机,所有插件版本都是request.txt里的,除了numpy 是1.19.5以外(如果使用request里的1.17.2,在训练的时候会出现:Python Fatal Error: GC Object already Tracked 的报错。). Python 是3.6.13.
取数据和训练都顺利完成(会提示没有nvidia驱动,不过也能完成训练)。
运行了run_api.py后,打开 127.0.0.1:5000 是 “Welcome to use!”,如果打开127.0.0.1:5000/predict_api/ ,则报错:"GET /predict_api/ HTTP/1.1" 404 -; 如果打开127.0.0.1:5000/predict_api (没有"/"), 则报错:
ERROR in app: Exception on /predict_api [GET]
Traceback (most recent call last):
File "/home/xxxxxx/.local/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/xxxxxx/.local/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/xxxxxx/.local/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/xxxxxx/.local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/xxxxxx/.local/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/xxxxxx/.local/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "run_api.py", line 53, in get_predict_result
diff_number = windows_size - 1
SystemError: unknown opcode
"GET /predict_api HTTP/1.1" 500 -
是我哪里没配置对吗?请抽空解答下,谢谢。
你好 ,对这个很感兴趣,但是模型文件缺失,能否告知如何下载或生成
谢谢!@zepen
File "F:/predict_Lottery_ticket-master/predict_api.py", line 40, in get_predict_result
p_data = np.array(data_list).reshape([-1, 3, 1]).astype(np.float32)
ValueError: cannot reshape array of size 1 into shape (3,1)
这个要怎么运行
我train的时候总是报WARNING:tensorflow:Layer lstm_1 will not use cuDNN kernels since it doesn't meet the criteria. It will use a generic GPU kernel as fallback when running on GPU.结果就是,貌似大部分计算都去了cpu,gpu非常空闲。
我尝试按照stackoverflow的方法修改,但是没有成功,只能请教作者解决方法
同样的数据,反复训练是不是没有什么用?还是说每增加一期数据训练一次?另外,这个代码后续还有时间更新维护吗?
预测过拟合,随机性不够。
后续的预测数字,重复数字太高了
如题
predict_api.py
接口输出号码,和计算结果集里的不一样,被+1,这是个大坑,咳损失好几百万啊
return json.dumps({b_name: int(res) + 1
在安装完依赖后,运行train model 报错
windows_size = 3
batch_size = 1
sequence_len = 6
red_n_class = 33
red_epochs = 1
red_embedding_size = 32
red_hidden_size = 32
red_layer_size = 1
blue_n_class = 16
blue_epochs = 1
blue_embedding_size = 32
blue_hidden_size = 32
blue_layer_size = 1
red_learning_rate = 0.001
red_beta1 = 0.9
red_beta2 = 0.999
red_epsilon = 1e-08
blue_learning_rate = 0.001
blue_beta1 = 0.9
blue_beta2 = 0.999
blue_epsilon = 1e-08
能换网站吗
我尝试在train里面增加load model的代码,以期能中断后重新开始train。
代码类似run_api中的load model。
但是在sess.run()后会报错:
Fetch argument <tf.Operation 'Adam' type=NoOp> cannot be interpreted as a Tensor.
Tensorflow写的不多,求解惑
发生异常: TypeError
'NoneType' object is not subscriptable
File "D:\下载\predict_Lottery_ticket-master\get_train_data.py", line 19, in get_current_number
current_num = soup.find("div", class_="wrap_datachart").find("input", id="end")["value"]
File "D:\下载\predict_Lottery_ticket-master\get_train_data.py", line 64, in
print("[INFO] 最新一期期号:{}".format(get_current_number()))
我尝试了几次,都有奇怪的报错。。
手动创建了data文件夹拉取历史数据,运行train_model的时候报这个错:
ValueError: A target array with shape (2616, 24) was passed for an output of shape (None, 0) while using as loss categorical_crossentropy
. This loss expects targets to have the same shape as the output.
我运行成功 没有值 不知道怎么回事 谢谢!
[INFO] 模型加载成功!
Serving Flask app "predict_api" (lazy loading)
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
Debug mode: off
Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
运行完这结果 怎么办 呜呜
WARNING:tensorflow:Layer lstm_2 will not use cuDNN kernel since it doesn't meet the cuDNN kernel criteria. It will use generic GPU kernel as fallback when running on GPU
看loss的趋势感觉一直就是在波动,没有明显下降趋势,而且红球们很多次预测出的结果都一样,感觉最终结果可能不如概率?
中奖的 出来露个脸哟!
如题,大乐透的也可以搞一下
{"red_1": 1, "red_2": 3, "red_3": 7, "red_4": 10, "red_5": 32, "red_6": 33, "blue": 12}
经过测试,0.10.0版本的tensorflow-addons并不支持2.6.1版本的tensorflow-cpu,并且,2.5以上版本的tensorflow-cpu貌似不支持CRF,2.4版本的tensorflow-cpu不能很好的进行序列化,因此,个人推荐以下依赖版本:
tensorflow-cpu==2.3.*
tensorflow-addons==0.13.*
requests
keras
beautifulsoup4
pandas
numpy
lxml
loguru
grpcio
protobuf
但是,这样还是会有save时序列化warning的小问题,测试后发觉不影响使用
通过使用您的脚本进行预测发现不管是ssq还是dlt后区连续多期存在相同号码11
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.