Scalars not getting saved

I’m new to guild.ai and trying to use the guild.yml files to save all relevant information including scalars. The scalars are however not being saved.

This is my code:

boston = load_boston()
X = pd.DataFrame(boston.data, columns=boston.feature_names)
y = boston.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

namedf = ['X_train', 'X_test']
namenp = ['y_train', 'y_test']

reg = Ridge(alpha=0.9)
fitted = reg.fit(X, y)

print("score: %f" % fitted.score(X, y))

and this is my guild.yml file:

ridge-regression:
  description: fit ridge regression using boston data.
  notebook: Checklist.ipynb
  flags:
    alpha:
      description: alpha value in ridge regression
      nb-replace: 'alpha=(\d+)'
  output-scalers:
    score: 'score: (\value)'

When I print out all information on the command line there are no scalars to be seen. Does anyone know why?

The problem is the spelling of output-scalars attribute - you have a typo there.

It would be nice if Guild told you that but sadly you can mistype attribute names and Guild just ignores them, in many cases.

You may run into other problems, related to the patterns. For those you can use the --test-output-scalars option to see how Guild applies the patterns for an operation. That would look like this:

guild cat --output <run ID to test> | guild run <op> --test-output-scalars -

Note the use of - (dash) as the argument to --test-output-scalars. That tells Guild to read from stdin. Otherwise you can use a filename containing output to test.

1 Like

Thank you for your reply! The misspelling was a one-off :smiley: The problem was that I was printing to the Jupyter notebook and not to the console…

The code that you have in the original post looks okay to me. This print("score: ...") line will print to the output for the cell but Guild will see this.

How did you change your code to get this working?

I added the line:

sys.stdout = open('/dev/stdout', 'w') 

before printing the score. Guild didn’t seem to be finding the output from the cell before.

I’m glad you have this working! This sounds like it may be a Guild bug. If it’s convenient to reproduce this problem, could you paste the cell contents of the broken version here—or share a simplified ipynb (e.g. via attachment, gist, etc.)?