Skip to content

WIP Add module on dimensionality reduction#876

Open
ArturoAmorQ wants to merge 13 commits into
INRIA:mainfrom
ArturoAmorQ:dimred_module
Open

WIP Add module on dimensionality reduction#876
ArturoAmorQ wants to merge 13 commits into
INRIA:mainfrom
ArturoAmorQ:dimred_module

Conversation

@ArturoAmorQ

Copy link
Copy Markdown
Collaborator

Adds module on PCA. Adds the wiki_news dataset, notebooks and exercises.
Probably a good idea to merge this after the clustering module in #836.

Note: This is still WIP. We are missing at least one quiz and the wrap-up quiz.

Comment thread python_scripts/dimred_intuitions.py Outdated
Comment thread python_scripts/dimred_preprocessing.py Outdated
Comment thread python_scripts/dimred_ex_01.py Outdated
Comment thread python_scripts/dimred_text.py
Co-authored-by: Frits Hermans <post@fritshermans.nl>
# %% [markdown]
# ## Finding the principal component
#
# PCA is intended to find new features (called principal components, or "PC")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would help to clarify the vocabulary and describe each of the objects we are talking about, giving for each of them its shape and its different names (eg V^T is the components_ attribute, called principal axes, of shape n_components x n_input_features, the output of transform() is XV, ...) otherwise it can be easy to get confused about what is what. when talking about directions it can be helpful to say in which space.

I realize there is a tension between this and keeping the explanation short and at a high-level for now, but I think it would help to fix a bit ideas and would not hesitate to repeat the sizes of the things we are talking about

Comment thread python_scripts/dimred_intuitions.py Outdated
Comment thread python_scripts/dimred_intuitions.py Outdated
Comment thread python_scripts/dimred_preprocessing.py Outdated

@SebastienMelo SebastienMelo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the few comments we discussed, thank you @ArturoAmorQ !

Comment thread python_scripts/dimred_components.py Outdated

# %%
pca_std = np.sqrt(pca.explained_variance_)
print(f"Std along the first PC : {pca_std[0]:.3f} mm")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it weird to give the unit here since PCA can mix units. Maybe add a comment like "in the general case the std along a PC has no unit because they can mix several heterogeneous units".

Comment thread python_scripts/dimred_preprocessing.py Outdated
Comment thread python_scripts/dimred_ex_01.py Outdated
Comment on lines +133 to +158
labels = {
"mean_fit_time": "CV fit time (s)",
"mean_test_error": "CV score (MAE)",
}
grid_search_results["n_components"] = grid_search_results[
"n_components"
].fillna("None")
fig = px.scatter(
grid_search_results,
x="mean_fit_time",
y="mean_test_error",
error_x="std_fit_time",
error_y="std_test_score",
hover_data=grid_search_results.columns,
labels=labels,
)
fig.update_layout(
title={
"text": "Trade-off between fit time and mean test score",
"y": 0.95,
"x": 0.5,
"xanchor": "center",
"yanchor": "top",
}
)
fig.show(renderer="notebook")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define as a function that the student will copy paste to prevent the apparition of errors in the notbook

Comment thread python_scripts/dimred_components.py
Comment thread python_scripts/dimred_components.py
Comment thread python_scripts/dimred_components.py
Co-authored-by: Franck Charras <franck.charras@libertymail.net>
Co-authored-by: SebastienMelo <125986598+SebastienMelo@users.noreply.github.com>
Comment thread python_scripts/dimred_preprocessing.py Outdated

@SebastienMelo SebastienMelo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants