Skip to content

Commit

Permalink
Better way to avoid flake8 undefined name error
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturoAmorQ committed Oct 27, 2023
1 parent f2e4f01 commit 28986c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
12 changes: 8 additions & 4 deletions python_scripts/linear_models_ex_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@
# Write your code here.

# %% [markdown]
# For the following questions, you can use the following snippet to get the
# feature names from the column transformer here named `preprocessor`.

# %%
# For the following questions, you can copy adn paste the following snippet to
# get the feature names from the column transformer here named `preprocessor`.
#
# ```python
# preprocessor.fit(data)
# feature_names = (
# preprocessor.named_transformers_["onehotencoder"].get_feature_names_out(
Expand All @@ -91,6 +91,10 @@
# ).tolist()
# feature_names += numerical_columns
# feature_names
# ```

# %%
# Write your code here.

# %% [markdown]
# Notice that there are as many feature names as coefficients in the last step
Expand Down
16 changes: 14 additions & 2 deletions python_scripts/linear_models_sol_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,22 @@
)

# %% [markdown]
# For the following questions, you can use the following snippet to get the
# feature names from the column transformer here named `preprocessor`.
# For the following questions, you can copy adn paste the following snippet to
# get the feature names from the column transformer here named `preprocessor`.
#
# ```python
# preprocessor.fit(data)
# feature_names = (
# preprocessor.named_transformers_["onehotencoder"].get_feature_names_out(
# categorical_columns
# )
# ).tolist()
# feature_names += numerical_columns
# feature_names
# ```

# %%
# solution
preprocessor.fit(data)
feature_names = (
preprocessor.named_transformers_["onehotencoder"].get_feature_names_out(
Expand Down

0 comments on commit 28986c2

Please sign in to comment.