Skip to content

Is it possible to write feature selection logs to file? #1048

Answered by arilwan
AlexGrunt asked this question in Q&A
Discussion options

You must be logged in to vote

HI @AlexGrunt,

Yes, I have done this and it works fine. Here's how:

  1. create a file handler object (e.g. f = open(...) just before the try...except block around here.
  2. Replace the sys.stderr.write (or add) with f.write(...) around line. Other option could be to redirect the stderr out in your terminal to a file.
    In the first case, do not forget to write to the file every time there update (don't wait until the is completed), e.g.
f.write(f'\n{k_idx} \t{cv_scores} \t{k_score}')
f.flush()
os.fsync(f.fileno()) # last 2 lines to ensure history is written to the file

Hope this helps.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AlexGrunt
Comment options

Answer selected by AlexGrunt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants