Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 预测游戏结果的下一个价值_Python_Machine Learning_Keras_Deep Learning_Lstm - Fatal编程技术网

Python 预测游戏结果的下一个价值

Python 预测游戏结果的下一个价值,python,machine-learning,keras,deep-learning,lstm,Python,Machine Learning,Keras,Deep Learning,Lstm,我正在努力预测游戏输出。这场比赛有三个座位座椅A、座椅B和座椅C。每次只有一个席位将随机获胜 我已经编写了LSTM代码来预测下一个值。我制作了大约8000场比赛的数据集,并记录了结果。但LSTM并没有预测下一个值。它要么预测所有“0”要么预测所有“1”。我很好奇为什么它不是学习 在这里你可以找到 这是我的谷歌colab附件 请告诉我为什么预测不正确。如果你声称“每次只有一个席位会随机获胜”,那么这里真的没有什么可预测的。就像@desernaut提到的,你试图预测没有意义的随机性。但我对同一个

我正在努力预测游戏输出。这场比赛有三个座位座椅A座椅B座椅C。每次只有一个席位将随机获胜

我已经编写了LSTM代码来预测下一个值。我制作了大约8000场比赛的数据集,并记录了结果。但LSTM并没有预测下一个值。它要么预测所有“0”要么预测所有“1”。我很好奇为什么它不是学习

  • 在这里你可以找到
  • 这是我的谷歌colab附件

请告诉我为什么预测不正确。

如果你声称“每次只有一个席位会随机获胜”,那么这里真的没有什么可预测的。就像@desernaut提到的,你试图预测没有意义的随机性。但我对同一个问题使用了朴素贝叶斯,它的预测准确率为38%到42%。我关心的是,为什么LSTM在训练后甚至没有预测一个值。如果“每次只有一个席位会随机获胜”,正如你所说,那么这里真的没有什么可预测的。就像@desernaut提到的,你试图预测随机性,这是没有意义的。但我用朴素贝叶斯来解决同样的问题,它的预测准确率为38%至42%。我关心的是为什么LSTM在训练后甚至不能预测一个值
# univariate data preparation
from sklearn.preprocessing import OneHotEncoder
from numpy import array
import pandas as pd
# split a univariate sequence into samples
df = pd.read_csv('DatasetLarge.csv') # here you can find dataset https://drive.google.com/open?id=1WZBMYO-Oi3uErPlBXphXFAACmn9VK_yZ
def split_sequence(sequence, n_steps):
    X, y = list(), list()
    for i in range(len(sequence)):
        # find the end of this pattern
        end_ix = i + n_steps
        # check if we are beyond the sequence
        if end_ix > len(sequence)-1:
            break
        # gather input and output parts of the pattern
        seq_x, seq_y = sequence[i:end_ix], sequence[end_ix]
        X.append(seq_x)
        y.append(seq_y)
    return array(X), array(y)
# Removing some errors of dataset
df=df.replace(to_replace ="q", 
                 value ="a")
df=df.replace(to_replace ="aa", 
                 value ="a")
df=df.replace(to_replace ="cc", 
                 value ="c")
#label encoding
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
le.fit(df.values)
df=le.transform(df)
# define input sequence
raw_seq=df
# choose a number of time steps
n_steps = 5
# split into samples
X, y = split_sequence(raw_seq, n_steps)
# summarize the data
for i in range(len(X)):
    print(X[i], y[i])

#Spliting dataset for train and test
X_train=X[0:7500]
y_train=y[0:7500]
X_test=X[7500:]
y_test=y[7500:]

import tensorflow.keras
from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import Dense, Dropout, Flatten,Input,LSTM
n_features = 1
X_train = X_train.reshape((X_train.shape[0], X_train.shape[1], n_features))
# define model
model = Sequential()
model.add(LSTM(200, activation='softmax', input_shape=(n_steps, n_features)))
model.add(Dense(1))
model.compile(optimizer='adam', loss='binary_crossentropy')
# # fit model
model.fit(X_train, y_train, epochs=100, verbose=0)
# # demonstrate prediction
X_test=X_test.reshape((X_test.shape[0], X_test.shape[1], n_features))
yhat_classes =(model.predict(X_test) > 0.5).astype("int32")

print(yhat_classes)