简体   繁体   中英

How do I predict data using a trained keras model

My independent variable is a datetime object and my dependent variable is an float. Currently, I have a keras model that predicts accurately, but I found out that model.predict() only returns predictions for the values that are already known. Is there a method I can call to tell the program to use the model to predict unknown values? If there isn't please give me instructions about how to predict these unknown values.

Currently, I have a Keras model that predicts accurately, but I found out that model.predict() only returns predictions for the values that are already known

That is incorrect. A predict statement doesn't just 'search and return' results from training data. That's not how machine learning works at all. The whole reason that you build models and have a train and test dataset is to ensure you have a model that is generalizable (ie can be used to make predictions on unseen data, assuming the observation is coming from the same underlying distribution that the model is trained on)

In your specific case, you are using a DateTime variable an independent, which means you should refrain from using variable such as year, which are non-recurring since you can use it to make predictions about the future (model learns patterns in 2019 but 2020 may be out of its vocabulary and thus years after that are not feasible to use for predictions.)

Instead, you should engineer some features from your DateTime variable and use recurring variables which may show reveal some patterns in the dependent variable. These variables are like days of the week, months, seasons, hours of the day. Depending on what your dependent variable is, you can surely find some patterns in these.

All of this totally depends on what you are trying to model and what is the goal of the model.predict() wrt your problem statement. Please elaborate if possible so that people can give you more specific answers.

Your assumption is incorrect. model.predict is specifically intended to use a trained model to make predictions on a data set typically not used previously for example a test set and not a training or validation set. To use it you need to create a data set to feed to model.predict. See answer here. on how to provide input to model.predict

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM