I am using XGBClassifier for my image classification. As i am new to machine learning and xgboost. But recently i got to know that the model i am saving by using pickle library after certain iteration is the last iteration not the best iteration. Can anyone tell me how can i save the model from best iteration? Obviously i am using early stop.
I kindly apologize if i make any mistake in asking questions. Please i need the solution as soon as possible because i need it for my thesis.
And those who are suggesting me older questions for best iteration please my question is different i want to save the best iteration in pickle format so that i can use it in future not just use it in predict later in the same code.
Thank you.
use joblib dump/load to save/load the model, and get the booster of the model, to get the best iteration
Related
I am developing an encoder-decoder model in order to predict titles for lecture transcripts. but the model is predicting the same title no matter what the input is. Any idea what may have caused such a problem?
If you would like to solve this, I will strongly recommend you to provide your code as an example, better including your loss, accuracy or something people will be more familiar about your problem. However, here are some conditions that will run into that problem: 1) your code was not doing the things you would like to do somehow. 2) LSTM sometimes experience gradient explode or gradient vanish problem, although it was said to fix those problem that a RNN structure will face, it still get into that problem form time to time anyway. 3) forget to shuffle your dataset before training, which makes your model learn the same pattern of one kind all the time. If all the things that mentioned above did not fit in your case, try to provide your code and dataset information to make it clear.
As asked in the title, i would like to know if it is possible to make a model early-stop the epochs during training when the error is reduced enough, so i can avoid overfitting and guessing the right number of epochs at each call.
This is the only thing i have found in the official documentation but it is tobe used in brainscript, and i don't know a single thing about it. I'm using Python 3.6 with CNTK 2.6.
Also, is there a way to perform cross validation in a CNTK CNN?? How could this be done?
Thanks in advance.
The CrossValidationConfig class tells CNTK to periodically evaluate the model on a validation data set, and then call a user-specified callback function, which then can be used to update the learning rate or to return False to indicate early stopping.
For examples on how to implement early stopping:
test_session_cv_callback_early_exit function here
Source code for cntk.train.training_session here.
There isn't any native implementation for early stopping in cntk. For cross validation you can look up CrossValidationConfig
I'm trying to implement 'multi-threading' to do both training and prediction(testing) at the same time. And I'm gonna use the python module 'threading' as shown in https://www.tensorflow.org/api_docs/python/tf/FIFOQueue
And the followings are questions.
If I use the python module 'threading', does tensorflow use more portion of gpu or more portion of cpu?
Do I have to make two graphs(neural nets which have the same topology) in tensorflow one for prediction and the other for training? Or is it okay to make just one graph?
I'll be very grateful to anyone who can answer these questions! thanks!
If you use python threading module, it will only make use of cpu; also python threading not for run time parallelism, you should use multiprocessing.
In your model if you are using dropout or batch_norm like ops which change based on training and validation, it's a good idea to create separate graphs, reusing (validation graph will reuse all training variables) the common variable for validation/testing.
Note: you can use one graph also, with additional operations which changes behaviors based on training/validation.
I have a task to compare two images and check whether they are of the same class (using Siamese CNN). Because I have a really small data set, I want to use keras imageDataGenerate.
I have read through the documentation and have understood the basic idea. However, I am not quite sure how to apply it to my use case, i.e. how to generate two images and a label that they are in the same class or not.
Any help would be greatly appreciated?
P.S. I can think of a much more convoluted process using sklearn's extract_patches_2d but I feel there is an elegant solution to this.
Edit: It looks like creating my own data generator may be the way to go. I will try this approach.
I have read the answer in another post https://stackoverflow.com/a/25794131/4566048
the classifier is pickled, how about the TfidfVectorizer? how can I use it from the pickled pipeline? since I need it to transform my feature vector, I still need to use it right?
After some digging around, I seem to have solved the problem. I will answer my own question here in case it can help anyone with same doubt in the future.
I found that only save the classifier is not enough, CountVectorizer and TfidfTransformer which are used to do the feature vector extraction need to be saved as well for it to work.
hope that helps!