[GH-ISSUE #258] Usage of double quotes inside an f-string, which causes a syntax error #1433

Open
opened 2026-04-18 01:15:57 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @zachpinto on GitHub (Jun 8, 2024).
Original GitHub issue: https://github.com/GokuMohandas/Made-With-ML/issues/258

In the section 'Machine Learning' in the 'Foundations' course, there is a code block in the 'Inference' sub-section:

# Unstandardize predictions pred_infer = model(X_infer).detach().numpy() * np.sqrt(y_scaler.var_) + y_scaler.mean_ for i, index in enumerate(sample_indices): print (f"{df.iloc[index]["y"]:.2f} (actual) → {pred_infer[i][0]:.2f} (predicted)")

However since there are also double-quotes around the y in the indexing (intended to display as "y"), the f-string ends early.

A fix would include simply changing the double quotes around the "y" to single quotes 'y':

# Unstandardize predictions pred_infer = model(X_infer).detach().numpy() * np.sqrt(y_scaler.var_) + y_scaler.mean_ for i, index in enumerate(sample_indices): print (f"{df.iloc[index]['y']:.2f} (actual) → {pred_infer[i][0]:.2f} (predicted)")

Originally created by @zachpinto on GitHub (Jun 8, 2024). Original GitHub issue: https://github.com/GokuMohandas/Made-With-ML/issues/258 In the section 'Machine Learning' in the 'Foundations' course, there is a code block in the 'Inference' sub-section: `# Unstandardize predictions pred_infer = model(X_infer).detach().numpy() * np.sqrt(y_scaler.var_) + y_scaler.mean_ for i, index in enumerate(sample_indices): print (f"{df.iloc[index]["y"]:.2f} (actual) → {pred_infer[i][0]:.2f} (predicted)")` However since there are also double-quotes around the y in the indexing (intended to display as "y"), the f-string ends early. A fix would include simply changing the double quotes around the "y" to single quotes 'y': `# Unstandardize predictions pred_infer = model(X_infer).detach().numpy() * np.sqrt(y_scaler.var_) + y_scaler.mean_ for i, index in enumerate(sample_indices): print (f"{df.iloc[index]['y']:.2f} (actual) → {pred_infer[i][0]:.2f} (predicted)")`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/Made-With-ML#1433