Skip to content

Commit 1845e73

Browse files
Merge pull request #313 from UBC-DSCI/whitespace-equal-sign-2
Remove argument whitespaces
2 parents 9d72fa8 + 8f0096b commit 1845e73

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

source/classification2.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ we call the `seed` function from the `numpy` package, and pass it any integer as
280280
Below we use the seed number `1`. At
281281
that point, Python will keep track of the randomness that occurs throughout the code.
282282
For example, we can call the `sample` method
283-
on the series of numbers, passing the argument `n = 10` to indicate that we want 10 samples.
283+
on the series of numbers, passing the argument `n=10` to indicate that we want 10 samples.
284284

285285
```{code-cell} ipython3
286286
import numpy as np
@@ -290,7 +290,7 @@ np.random.seed(1)
290290
291291
nums_0_to_9 = pd.Series([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
292292
293-
random_numbers1 = nums_0_to_9.sample(n = 10).to_numpy()
293+
random_numbers1 = nums_0_to_9.sample(n=10).to_numpy()
294294
random_numbers1
295295
```
296296
You can see that `random_numbers1` is a list of 10 numbers
@@ -299,7 +299,7 @@ we run the `sample` method again,
299299
we will get a fresh batch of 10 numbers that also look random.
300300

301301
```{code-cell} ipython3
302-
random_numbers2 = nums_0_to_9.sample(n = 10).to_numpy()
302+
random_numbers2 = nums_0_to_9.sample(n=10).to_numpy()
303303
random_numbers2
304304
```
305305

@@ -309,12 +309,12 @@ as before---and then call the `sample` method again.
309309

310310
```{code-cell} ipython3
311311
np.random.seed(1)
312-
random_numbers1_again = nums_0_to_9.sample(n = 10).to_numpy()
312+
random_numbers1_again = nums_0_to_9.sample(n=10).to_numpy()
313313
random_numbers1_again
314314
```
315315

316316
```{code-cell} ipython3
317-
random_numbers2_again = nums_0_to_9.sample(n = 10).to_numpy()
317+
random_numbers2_again = nums_0_to_9.sample(n=10).to_numpy()
318318
random_numbers2_again
319319
```
320320

@@ -326,12 +326,12 @@ obtain a different sequence of random numbers.
326326

327327
```{code-cell} ipython3
328328
np.random.seed(4235)
329-
random_numbers = nums_0_to_9.sample(n = 10).to_numpy()
329+
random_numbers = nums_0_to_9.sample(n=10).to_numpy()
330330
random_numbers
331331
```
332332

333333
```{code-cell} ipython3
334-
random_numbers = nums_0_to_9.sample(n = 10).to_numpy()
334+
random_numbers = nums_0_to_9.sample(n=10).to_numpy()
335335
random_numbers
336336
```
337337

@@ -378,15 +378,15 @@ functions. Those functions will then use your `RandomState` to generate random n
378378
`numpy`'s default generator. For example, we can reproduce our earlier example by using a `RandomState`
379379
object with the `seed` value set to 1; we get the same lists of numbers once again.
380380
```{code}
381-
rnd = np.random.RandomState(seed = 1)
382-
random_numbers1_third = nums_0_to_9.sample(n = 10, random_state = rnd).to_numpy()
381+
rnd = np.random.RandomState(seed=1)
382+
random_numbers1_third = nums_0_to_9.sample(n=10, random_state=rnd).to_numpy()
383383
random_numbers1_third
384384
```
385385
```{code}
386386
array([2, 9, 6, 4, 0, 3, 1, 7, 8, 5])
387387
```
388388
```{code}
389-
random_numbers2_third = nums_0_to_9.sample(n = 10, random_state = rnd).to_numpy()
389+
random_numbers2_third = nums_0_to_9.sample(n=10, random_state=rnd).to_numpy()
390390
random_numbers2_third
391391
```
392392
```{code}
@@ -540,8 +540,8 @@ cancer_train["Class"].value_counts(normalize=True)
540540
```{code-cell} ipython3
541541
:tags: [remove-cell]
542542
543-
glue("cancer_train_b_prop", "{:0.0f}".format(cancer_train["Class"].value_counts(normalize = True)["Benign"]*100))
544-
glue("cancer_train_m_prop", "{:0.0f}".format(cancer_train["Class"].value_counts(normalize = True)["Malignant"]*100))
543+
glue("cancer_train_b_prop", "{:0.0f}".format(cancer_train["Class"].value_counts(normalize=True)["Benign"]*100))
544+
glue("cancer_train_m_prop", "{:0.0f}".format(cancer_train["Class"].value_counts(normalize=True)["Malignant"]*100))
545545
```
546546

547547
### Preprocess the data
@@ -1620,7 +1620,7 @@ for i in range(len(ks)):
16201620
cancer_tune_pipe = make_pipeline(cancer_preprocessor, KNeighborsClassifier())
16211621
param_grid = {
16221622
"kneighborsclassifier__n_neighbors": range(1, 21),
1623-
} ## double check: in R textbook, it is tune_grid(..., grid = 20), so I guess it matches RandomizedSearchCV
1623+
} ## double check: in R textbook, it is tune_grid(..., grid=20), so I guess it matches RandomizedSearchCV
16241624
## instead of GridSeachCV?
16251625
# param_grid_rand = {
16261626
# "kneighborsclassifier__n_neighbors": range(1, 100),

source/clustering.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ in the clustering pipeline.
182182
```{code-cell} ipython3
183183
:tags: [remove-cell]
184184
penguins_standardized = penguins.assign(
185-
bill_length_standardized = (penguins["bill_length_mm"] - penguins["bill_length_mm"].mean())/penguins["bill_length_mm"].std(),
186-
flipper_length_standardized = (penguins["flipper_length_mm"] - penguins["flipper_length_mm"].mean())/penguins["flipper_length_mm"].std()
185+
bill_length_standardized=(penguins["bill_length_mm"] - penguins["bill_length_mm"].mean())/penguins["bill_length_mm"].std(),
186+
flipper_length_standardized=(penguins["flipper_length_mm"] - penguins["flipper_length_mm"].mean())/penguins["flipper_length_mm"].std()
187187
).drop(
188-
columns = ["bill_length_mm", "flipper_length_mm"]
188+
columns=["bill_length_mm", "flipper_length_mm"]
189189
)
190190
```
191191

@@ -261,7 +261,7 @@ kmeans = KMeans(n_clusters=3)
261261
262262
penguin_clust = kmeans.fit(penguins_standardized)
263263
264-
penguins_clustered = penguins_standardized.assign(cluster = penguin_clust.labels_)
264+
penguins_clustered = penguins_standardized.assign(cluster=penguin_clust.labels_)
265265
266266
colored_scatter_plot = alt.Chart(penguins_clustered).mark_circle().encode(
267267
x=alt.X("flipper_length_standardized", title="Flipper Length (standardized)"),

source/inference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,9 @@ glue(
716716
x="mean(price)"
717717
),
718718
base.mark_text(align="left", color="#f58518", size=12, fontWeight="bold", dx=10).transform_aggregate(
719-
mean_price = "mean(price)",
719+
mean_price="mean(price)",
720720
).transform_calculate(
721-
label = "'Mean = ' + round(datum.mean_price * 10) / 10"
721+
label="'Mean = ' + round(datum.mean_price * 10) / 10"
722722
).encode(
723723
x=alt.X("mean_price:Q", title="Sample mean price per night (dollars)"),
724724
y=alt.value(10),

source/reading.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ contain its own column names.
392392

393393
```{code-cell} ipython3
394394
:tags: ["output_scroll"]
395-
canlang_data = pd.read_csv(
395+
canlang_data = pd.read_csv(
396396
"data/can_lang_no_names.tsv",
397-
sep = "\t",
398-
header = None
397+
sep="\t",
398+
header=None
399399
)
400400
canlang_data
401401
```

source/regression1.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,8 @@ from sklearn.metrics import mean_squared_error
833833
834834
sacramento_test["predicted"] = sacr_gridsearch.predict(sacramento_test)
835835
RMSPE = mean_squared_error(
836-
y_true = sacramento_test["price"],
837-
y_pred = sacramento_test["predicted"]
836+
y_true=sacramento_test["price"],
837+
y_pred=sacramento_test["predicted"]
838838
)**(1/2)
839839
RMSPE
840840
```
@@ -1066,8 +1066,8 @@ to compute the RMSPE.
10661066
```{code-cell} ipython3
10671067
sacramento_test["predicted"] = sacr_gridsearch.predict(sacramento_test)
10681068
RMSPE_mult = mean_squared_error(
1069-
y_true = sacramento_test["price"],
1070-
y_pred = sacramento_test["predicted"]
1069+
y_true=sacramento_test["price"],
1070+
y_pred=sacramento_test["predicted"]
10711071
)**(1/2)
10721072
RMSPE_mult
10731073

source/regression2.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ sacramento_test["predicted"] = lm.predict(sacramento_test[["sqft"]])
440440
441441
# calculate RMSPE
442442
RMSPE = mean_squared_error(
443-
y_true = sacramento_test["price"],
444-
y_pred = sacramento_test["predicted"]
443+
y_true=sacramento_test["price"],
444+
y_pred=sacramento_test["predicted"]
445445
)**(1/2)
446446
447447
RMSPE
@@ -734,8 +734,8 @@ Finally, we make predictions on the test data set to assess the quality of our m
734734
sacramento_test["predicted"] = mlm.predict(sacramento_test[["sqft","beds"]])
735735
736736
lm_mult_test_RMSPE = mean_squared_error(
737-
y_true = sacramento_test["price"],
738-
y_pred = sacramento_test["predicted"]
737+
y_true=sacramento_test["price"],
738+
y_pred=sacramento_test["predicted"]
739739
)**(1/2)
740740
lm_mult_test_RMSPE
741741
```

0 commit comments

Comments
 (0)