-
Notifications
You must be signed in to change notification settings - Fork 1
/
AI-Prediction.py
63 lines (50 loc) · 1.63 KB
/
AI-Prediction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
# start process
fr = open("number.txt", "r") # อ่านค่าประวัติ
v_lotto = list([]) # keep lotto
for i in fr.readlines():
v_lotto.append(int(i[:-1]) / 999999)
v_lotto.reverse()
print(v_lotto)
##@@ demo
# result = []
# for i in range(len(v_lotto)-1):
# single_value = v_lotto[i] - v_lotto[i+1]
# if single_value < 0:
# single_value *= (-1)
# result.append(single_value)
# v_lotto = result
# for i in v_lotto:
# print(i)
##@@ demo
lotto = np.array(v_lotto) # แปลงเป็นประเภท array
number = np.arange(len(lotto)) # แปลงเป็นประเภท array
lotto = lotto.reshape(-1, 1)
number = number.reshape(-1, 1)
# 476
# x_train, x_test = number[:390], number[390:] # แยกข้อมูลสำหรับ train & test
# y_train, y_test = lotto[:390], lotto[390:] # แยกข้อมูลสำหรับ train & test
# model train
model = LinearRegression()
model.fit(number, lotto)
# plt.scatter(number, lotto)
# plt.show()
##@@ demo
# predit demo
y_predit = model.predict([[len(lotto)+1]])
print(int(999999 * y_predit))
##@@ demo
# from sklearn.metrics import accuracy_score
# import math
# for i in range(len(y_predit)):
# y_predit[i][0] = math.ceil(y_predit[i][0])
# print("accuracy_score=",accuracy_score(y_test, y_predit)*100)
# print(len(v_lotto))
# predit
# point = len(lotto) + 1
# y_predit = model.predict([[point]])
# print("Number [", point, "] = ", y_predit)
# input("done")