Skip to content

Commit e60b9bd

Browse files
committed
[ci skip] MAINT Remove head method (#766)
Co-authored-by: ArturoAmorQ <[email protected]> 09ad771
1 parent 65a0c69 commit e60b9bd

28 files changed

+1869
-228
lines changed

_sources/python_scripts/01_tabular_data_exploration.py

+9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@
7070
# %%
7171
adult_census.head()
7272

73+
# %% [markdown]
74+
# An alternative is to omit the `head` method. This would output the intial and
75+
# final rows and columns, but everything in between is not shown by default. It
76+
# also provides the dataframe's dimensions at the bottom in the format `n_rows`
77+
# x `n_columns`.
78+
79+
# %%
80+
adult_census
81+
7382
# %% [markdown]
7483
# The column named **class** is our target variable (i.e., the variable which we
7584
# want to predict). The two possible classes are `<=50K` (low-revenue) and

_sources/python_scripts/02_numerical_pipeline_hands_on.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
adult_census = pd.read_csv("../datasets/adult-census.csv")
3535
# drop the duplicated column `"education-num"` as stated in the first notebook
3636
adult_census = adult_census.drop(columns="education-num")
37-
adult_census.head()
37+
adult_census
3838

3939
# %% [markdown]
4040
# The next step separates the target from the data. We performed the same
@@ -44,7 +44,7 @@
4444
data, target = adult_census.drop(columns="class"), adult_census["class"]
4545

4646
# %%
47-
data.head()
47+
data
4848

4949
# %%
5050
target
@@ -95,7 +95,7 @@
9595
# the `object` data type.
9696

9797
# %%
98-
data.head()
98+
data
9999

100100
# %% [markdown]
101101
# We see that the `object` data type corresponds to columns containing strings.
@@ -105,7 +105,7 @@
105105

106106
# %%
107107
numerical_columns = ["age", "capital-gain", "capital-loss", "hours-per-week"]
108-
data[numerical_columns].head()
108+
data[numerical_columns]
109109

110110
# %% [markdown]
111111
# Now that we limited the dataset to numerical columns only, we can analyse

_sources/python_scripts/02_numerical_pipeline_introduction.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# Let's have a look at the first records of this dataframe:
4040

4141
# %%
42-
adult_census.head()
42+
adult_census
4343

4444
# %% [markdown]
4545
# We see that this CSV file contains all information: the target that we would
@@ -56,7 +56,7 @@
5656

5757
# %%
5858
data = adult_census.drop(columns=[target_name])
59-
data.head()
59+
data
6060

6161
# %% [markdown]
6262
# We can now linger on the variables, also denominated features, that we later

_sources/python_scripts/03_categorical_pipeline.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
# %%
8383
data_categorical = data[categorical_columns]
84-
data_categorical.head()
84+
data_categorical
8585

8686
# %%
8787
print(f"The dataset is composed of {data_categorical.shape[1]} features")
@@ -194,7 +194,7 @@
194194

195195
# %%
196196
print(f"The dataset is composed of {data_categorical.shape[1]} features")
197-
data_categorical.head()
197+
data_categorical
198198

199199
# %%
200200
data_encoded = encoder.fit_transform(data_categorical)

_sources/python_scripts/03_categorical_pipeline_column_transformer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
# method. As an example, we predict on the five first samples from the test set.
166166

167167
# %%
168-
data_test.head()
168+
data_test
169169

170170
# %%
171171
model.predict(data_test)[:5]

_sources/python_scripts/cross_validation_train_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
print(housing.DESCR)
4242

4343
# %%
44-
data.head()
44+
data
4545

4646
# %% [markdown]
4747
# To simplify future visualization, let's transform the prices from the 100
4848
# (k\$) range to the thousand dollars (k\$) range.
4949

5050
# %%
5151
target *= 100
52-
target.head()
52+
target
5353

5454
# %% [markdown]
5555
# ```{note}
@@ -218,7 +218,7 @@
218218
import pandas as pd
219219

220220
cv_results = pd.DataFrame(cv_results)
221-
cv_results.head()
221+
cv_results
222222

223223
# %% [markdown]
224224
# ```{tip}

_sources/python_scripts/linear_models_ex_02.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
data = penguins_non_missing[columns]
5454
target = penguins_non_missing[target_name]
55-
data.head()
55+
data
5656

5757
# %% [markdown]
5858
# Now it is your turn to train a linear regression model on this dataset. First,

_sources/python_scripts/linear_models_sol_02.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
data = penguins_non_missing[columns]
4848
target = penguins_non_missing[target_name]
49-
data.head()
49+
data
5050

5151
# %% [markdown]
5252
# Now it is your turn to train a linear regression model on this dataset. First,

_sources/python_scripts/linear_regression_without_sklearn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pandas as pd
2323

2424
penguins = pd.read_csv("../datasets/penguins_regression.csv")
25-
penguins.head()
25+
penguins
2626

2727
# %% [markdown]
2828
# We aim to solve the following problem: using the flipper length of a penguin,

_sources/python_scripts/parameter_tuning_grid_search.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# %%
3838
data = adult_census.drop(columns=[target_name, "education-num"])
39-
data.head()
39+
data
4040

4141
# %% [markdown]
4242
# Once the dataset is loaded, we split it into a training and testing sets.
@@ -193,7 +193,7 @@
193193
cv_results = pd.DataFrame(model_grid_search.cv_results_).sort_values(
194194
"mean_test_score", ascending=False
195195
)
196-
cv_results.head()
196+
cv_results
197197

198198
# %% [markdown]
199199
# Let us focus on the most interesting columns and shorten the parameter names

_sources/python_scripts/parameter_tuning_manual.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# Our data is only numerical.
3939

4040
# %%
41-
data.head()
41+
data
4242

4343
# %% [markdown]
4444
# Let's create a simple predictive model made of a scaler followed by a logistic

_sources/python_scripts/parameter_tuning_randomized_search.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
# %%
4646
data = adult_census.drop(columns=[target_name, "education-num"])
47-
data.head()
47+
data
4848

4949
# %% [markdown]
5050
# Once the dataset is loaded, we split it into a training and testing sets.

_sources/python_scripts/trees_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# Let's check the dataset more into details.
4949

5050
# %%
51-
penguins.head()
51+
penguins
5252

5353
# %% [markdown]
5454
# Since that we have few samples, we can check a scatter plot to observe the

appendix/notebook_timings.html

+26-26
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
668668
</thead>
669669
<tbody>
670670
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/01_tabular_data_exploration.html"><span class="doc">python_scripts/01_tabular_data_exploration</span></a></p></td>
671-
<td><p>2024-04-26 13:19</p></td>
671+
<td><p>2024-04-26 13:50</p></td>
672672
<td><p>cache</p></td>
673-
<td><p>7.52</p></td>
673+
<td><p>8.22</p></td>
674674
<td><p></p></td>
675675
</tr>
676676
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/01_tabular_data_exploration_ex_01.html"><span class="doc">python_scripts/01_tabular_data_exploration_ex_01</span></a></p></td>
@@ -704,15 +704,15 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
704704
<td><p></p></td>
705705
</tr>
706706
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/02_numerical_pipeline_hands_on.html"><span class="doc">python_scripts/02_numerical_pipeline_hands_on</span></a></p></td>
707-
<td><p>2024-04-26 13:20</p></td>
707+
<td><p>2024-04-26 13:50</p></td>
708708
<td><p>cache</p></td>
709-
<td><p>1.92</p></td>
709+
<td><p>2.01</p></td>
710710
<td><p></p></td>
711711
</tr>
712712
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/02_numerical_pipeline_introduction.html"><span class="doc">python_scripts/02_numerical_pipeline_introduction</span></a></p></td>
713-
<td><p>2024-04-26 13:20</p></td>
713+
<td><p>2024-04-26 13:50</p></td>
714714
<td><p>cache</p></td>
715-
<td><p>4.77</p></td>
715+
<td><p>4.8</p></td>
716716
<td><p></p></td>
717717
</tr>
718718
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/02_numerical_pipeline_scaling.html"><span class="doc">python_scripts/02_numerical_pipeline_scaling</span></a></p></td>
@@ -734,15 +734,15 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
734734
<td><p></p></td>
735735
</tr>
736736
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/03_categorical_pipeline.html"><span class="doc">python_scripts/03_categorical_pipeline</span></a></p></td>
737-
<td><p>2024-04-26 13:20</p></td>
737+
<td><p>2024-04-26 13:50</p></td>
738738
<td><p>cache</p></td>
739-
<td><p>2.95</p></td>
739+
<td><p>2.8</p></td>
740740
<td><p></p></td>
741741
</tr>
742742
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/03_categorical_pipeline_column_transformer.html"><span class="doc">python_scripts/03_categorical_pipeline_column_transformer</span></a></p></td>
743-
<td><p>2024-04-26 13:20</p></td>
743+
<td><p>2024-04-26 13:50</p></td>
744744
<td><p>cache</p></td>
745-
<td><p>4.55</p></td>
745+
<td><p>4.23</p></td>
746746
<td><p></p></td>
747747
</tr>
748748
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/03_categorical_pipeline_ex_01.html"><span class="doc">python_scripts/03_categorical_pipeline_ex_01</span></a></p></td>
@@ -836,9 +836,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
836836
<td><p></p></td>
837837
</tr>
838838
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/cross_validation_train_test.html"><span class="doc">python_scripts/cross_validation_train_test</span></a></p></td>
839-
<td><p>2024-04-26 13:22</p></td>
839+
<td><p>2024-04-26 13:51</p></td>
840840
<td><p>cache</p></td>
841-
<td><p>10.15</p></td>
841+
<td><p>10.87</p></td>
842842
<td><p></p></td>
843843
</tr>
844844
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/cross_validation_validation_curve.html"><span class="doc">python_scripts/cross_validation_validation_curve</span></a></p></td>
@@ -1004,9 +1004,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
10041004
<td><p></p></td>
10051005
</tr>
10061006
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/linear_models_ex_02.html"><span class="doc">python_scripts/linear_models_ex_02</span></a></p></td>
1007-
<td><p>2024-04-26 13:31</p></td>
1007+
<td><p>2024-04-26 13:51</p></td>
10081008
<td><p>cache</p></td>
1009-
<td><p>1.1</p></td>
1009+
<td><p>1.09</p></td>
10101010
<td><p></p></td>
10111011
</tr>
10121012
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/linear_models_ex_03.html"><span class="doc">python_scripts/linear_models_ex_03</span></a></p></td>
@@ -1040,9 +1040,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
10401040
<td><p></p></td>
10411041
</tr>
10421042
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/linear_models_sol_02.html"><span class="doc">python_scripts/linear_models_sol_02</span></a></p></td>
1043-
<td><p>2024-04-26 13:32</p></td>
1043+
<td><p>2024-04-26 13:51</p></td>
10441044
<td><p>cache</p></td>
1045-
<td><p>6.06</p></td>
1045+
<td><p>6.1</p></td>
10461046
<td><p></p></td>
10471047
</tr>
10481048
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/linear_models_sol_03.html"><span class="doc">python_scripts/linear_models_sol_03</span></a></p></td>
@@ -1070,9 +1070,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
10701070
<td><p></p></td>
10711071
</tr>
10721072
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/linear_regression_without_sklearn.html"><span class="doc">python_scripts/linear_regression_without_sklearn</span></a></p></td>
1073-
<td><p>2024-04-26 13:32</p></td>
1073+
<td><p>2024-04-26 13:51</p></td>
10741074
<td><p>cache</p></td>
1075-
<td><p>2.71</p></td>
1075+
<td><p>2.65</p></td>
10761076
<td><p></p></td>
10771077
</tr>
10781078
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/logistic_regression.html"><span class="doc">python_scripts/logistic_regression</span></a></p></td>
@@ -1130,15 +1130,15 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
11301130
<td><p></p></td>
11311131
</tr>
11321132
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/parameter_tuning_grid_search.html"><span class="doc">python_scripts/parameter_tuning_grid_search</span></a></p></td>
1133-
<td><p>2024-04-26 13:33</p></td>
1133+
<td><p>2024-04-26 13:51</p></td>
11341134
<td><p>cache</p></td>
1135-
<td><p>10.35</p></td>
1135+
<td><p>10.21</p></td>
11361136
<td><p></p></td>
11371137
</tr>
11381138
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/parameter_tuning_manual.html"><span class="doc">python_scripts/parameter_tuning_manual</span></a></p></td>
1139-
<td><p>2024-04-26 13:33</p></td>
1139+
<td><p>2024-04-26 13:51</p></td>
11401140
<td><p>cache</p></td>
1141-
<td><p>4.46</p></td>
1141+
<td><p>4.17</p></td>
11421142
<td><p></p></td>
11431143
</tr>
11441144
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/parameter_tuning_nested.html"><span class="doc">python_scripts/parameter_tuning_nested</span></a></p></td>
@@ -1154,9 +1154,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
11541154
<td><p></p></td>
11551155
</tr>
11561156
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/parameter_tuning_randomized_search.html"><span class="doc">python_scripts/parameter_tuning_randomized_search</span></a></p></td>
1157-
<td><p>2024-04-26 13:34</p></td>
1157+
<td><p>2024-04-26 13:51</p></td>
11581158
<td><p>cache</p></td>
1159-
<td><p>41.68</p></td>
1159+
<td><p>24.21</p></td>
11601160
<td><p></p></td>
11611161
</tr>
11621162
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/parameter_tuning_sol_02.html"><span class="doc">python_scripts/parameter_tuning_sol_02</span></a></p></td>
@@ -1178,9 +1178,9 @@ <h1>Notebook timings<a class="headerlink" href="#notebook-timings" title="Permal
11781178
<td><p></p></td>
11791179
</tr>
11801180
<tr class="row-odd"><td><p><a class="xref doc reference internal" href="../python_scripts/trees_dataset.html"><span class="doc">python_scripts/trees_dataset</span></a></p></td>
1181-
<td><p>2024-04-26 13:34</p></td>
1181+
<td><p>2024-04-26 13:51</p></td>
11821182
<td><p>cache</p></td>
1183-
<td><p>2.95</p></td>
1183+
<td><p>2.75</p></td>
11841184
<td><p></p></td>
11851185
</tr>
11861186
<tr class="row-even"><td><p><a class="xref doc reference internal" href="../python_scripts/trees_ex_01.html"><span class="doc">python_scripts/trees_ex_01</span></a></p></td>

0 commit comments

Comments
 (0)