Fix polynomial regression plot rendering as zigzag line#971
Merged
Conversation
… curve Agent-Logs-Url: https://github.com/microsoft/ML-For-Beginners/sessions/ec6b5ce7-6500-4c18-8c79-bc21779ac649 Co-authored-by: leestott <2511341+leestott@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix polynomial regression plot rendering as zigzagged line
Fix polynomial regression plot rendering as zigzag line
Apr 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the polynomial regression visualization in the regression lesson by avoiding plotting predictions against an unordered X_test (which can render as a zigzag), and aligns the lesson materials to use a smooth, uniformly sampled X_range for plotting.
Changes:
- Update polynomial regression plotting to use
np.linspace+pipeline.predict(X_range)for a smooth curve. - Expand the polynomial regression README section with an explicit predict/metrics snippet and an explanation of why direct
X_testplotting can fail.
Show a summary per file
| File | Description |
|---|---|
| 2-Regression/3-Linear/README.md | Adds explicit prediction/metrics code and updates plotting guidance to use a uniform sorted range for smooth curves. |
| 2-Regression/3-Linear/solution/notebook.ipynb | Replaces the sorted(X_test) plotting workaround with an np.linspace-based range and plots predictions over that range. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
train_test_splitshuffles data, soX_testis unordered —plt.plot(X_test, pred)connects points in array order, producing a zigzag instead of a smooth curve. Fix: generate a sorted uniform range vianp.linspacefor plotting.2-Regression/3-Linear/README.mdnp.linspace-based plotting code with a brief explanation of why directX_testplotting fails2-Regression/3-Linear/solution/notebook.ipynbsorted(X_test)workaround with thenp.linspaceapproach consistent with the updated READMETrack translation progress by opening a draft PR using this template and checking off the translations completed
Each lesson includes a translation of the README.md and the Assignment.md file, if available. Only mark the lesson complete if both those files are translated per lesson, please.
1
1-1
1-2
1-3
2
2-1
2-2
2-3
2-4
3
3-1
3-2
3-3
4
4-1
5
5-1
5-2
5-3
6
6-1
6-2
6-3
6-4
6-5
6-6
7
7-1
7-2
7-3
7-4
Quiz (add a file in the quiz-app with all localizations)