Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to predict a new sample (1 sample) on existing model? #316

Closed
TienNguyenKha opened this issue Sep 13, 2022 · 15 comments
Closed

How to predict a new sample (1 sample) on existing model? #316

TienNguyenKha opened this issue Sep 13, 2022 · 15 comments

Comments

@TienNguyenKha
Copy link

Hi, thank for your contribution you have made.
I wonder if i could use trained model to predict on a new sample ? Can you give me instructions or code demo?
( Now I'm using ACFM model for traffic flow prediction task. )

@aptx1231
Copy link
Member

Do you mean prediction with a trained model?
You need to specify two parameters, one is --train False, which controls the code to test directly without training.
The other is --exp_id ID. ID is an exp_id randomly generated when training the model. The trained model should be stored in the directory libcity/cache/ID/model_cache, so you need to specify the ID.

@aptx1231
Copy link
Member

What does "1 sample" mean?

@TienNguyenKha
Copy link
Author

TienNguyenKha commented Sep 13, 2022

What does "1 sample" mean?

I'm using ACFM model for traffic flow prediction task. And I trained it with "NYCTAXI201401-201403_GRID" dataset. I saw the length of 1 input sequence is 6 and the output is 1. How can I predict with another new sequence? I don't know how to preprocessing new raw data to model's input and which code to call and predict this new sequence.

@aptx1231
Copy link
Member

Modify the parameters input_window and output_window to change the length of input and output.

@aptx1231
Copy link
Member

Do you mean prediction with a trained model? You need to specify two parameters, one is --train False, which controls the code to test directly without training. The other is --exp_id ID. ID is an exp_id randomly generated when training the model. The trained model should be stored in the directory libcity/cache/ID/model_cache, so you need to specify the ID.

This is all that is needed to make predictions with the trained model, no data processing is required.

@TienNguyenKha
Copy link
Author

I keep the input_window and output_window like you.
I mean, If I have new sequence (,=not in train/val/test). Which code I need to use in this case to predict?

@aptx1231
Copy link
Member

This requires processing the data into atomic files before libcity can be used.

@TienNguyenKha
Copy link
Author

Assume I had atomic files, which code can I use ?

@aptx1231
Copy link
Member

You can run the model directly with run_model.py, --train false and --exp_id ID to specify the location of the pre-trained model to apply the pre-trained model to the new data.

@TienNguyenKha
Copy link
Author

Can I run "test_model.py" to test?
I trained AFCM model with id=28778. Have I configured it properly to load this model ?
git_libcity

@aptx1231
Copy link
Member

test_model.py only takes a batch data for testing, it can't achieve your requirement

@B046090010
Copy link

Hello, I have a similar problem.
If we only have the value of X, how do we make the inference of y using the existing model?
Thanks a lot.

@aptx1231
Copy link
Member

You can run the model directly with run_model.py, --train false and --exp_id ID to specify the location of the pre-trained model to apply the pre-trained model to the new data.

In this case, a pre-trained model is needed first. You can use other datasets to train the model in Libcity and generate a exp_id when training.
Then, you can run the model directly with run_model.py, --train false and --exp_id ID to specify the location of the pre-trained model to apply the pre-trained model to the new data X.

@B046090010
Copy link

You can run the model directly with run_model.py, --train false and --exp_id ID to specify the location of the pre-trained model to apply the pre-trained model to the new data.

Thank you for your response. Is the implementation steps as follows.

Suppose I have finished training DMVST with NYCTaxi20150103 dataset, then when I want to predict future data, e.g., taxi demand after 2015/3/1.

I need to modify NYCTaxi20150103.grid to add the data after 2015/03/01, and set departing_volume and arriving_volume to 0.

Finally, use run_model to adjust the test_rate to get the predicted value after multiple steps.

@aptx1231
Copy link
Member

You can run the model directly with run_model.py, --train false and --exp_id ID to specify the location of the pre-trained model to apply the pre-trained model to the new data.

Thank you for your response. Is the implementation steps as follows.

Suppose I have finished training DMVST with NYCTaxi20150103 dataset, then when I want to predict future data, e.g., taxi demand after 2015/3/1.

I need to modify NYCTaxi20150103.grid to add the data after 2015/03/01, and set departing_volume and arriving_volume to 0.

Finally, use run_model to adjust the test_rate to get the predicted value after multiple steps.

Yes, after you have trained DMVSTNET, just set --train false and the appropriate test_rate to make predictions only on this part of the test set. Thank you for the detailed steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants