Skip to content

Commit 98366dd

Browse files
committed
fd-update
1 parent 7931214 commit 98366dd

40 files changed

+242
-350
lines changed

__site/assets/end-to-end/wine/code/ex9.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
@load MultinomialClassifier pkg="MLJLinearModels";
44

55
@pipeline KnnPipe(std=Standardizer(), clf=KNNClassifier()) is_probabilistic=true
6-
@pipeline MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=true
6+
@pipeline MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=true;

__site/assets/end-to-end/wine/code/output/EX-wine-pca.svg

+167-167
Loading
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Machine{MnPipe} @ 143
1+
Machine{MnPipe} @ 422
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
MnPipe(
2-
std = Standardizer(
3-
features = Symbol[],
4-
ignore = false,
5-
ordered_factor = false,
6-
count = false),
7-
clf = MultinomialClassifier(
8-
lambda = 1.0,
9-
gamma = 0.0,
10-
penalty = :l2,
11-
fit_intercept = true,
12-
penalize_intercept = false,
13-
solver = nothing,
14-
nclasses = 2)) @ 8…98
1+
nothing

__site/assets/literate/EX-wine.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ We'll train two simple pipelines:
9090
@load MultinomialClassifier pkg="MLJLinearModels";
9191
9292
@pipeline KnnPipe(std=Standardizer(), clf=KNNClassifier()) is_probabilistic=true
93-
@pipeline MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=true
93+
@pipeline MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=true;
9494
```
9595

9696
We can now fit this on a train split of the data setting aside 20% of the data for eventual testing.

__site/assets/literate/EX-wine_script.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe(Xc, :mean, :std)
3535
@load MultinomialClassifier pkg="MLJLinearModels";
3636

3737
@pipeline KnnPipe(std=Standardizer(), clf=KNNClassifier()) is_probabilistic=true
38-
@pipeline MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=true
38+
@pipeline MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=true;
3939

4040
train, test = partition(eachindex(yc), 0.8, shuffle=true, rng=111)
4141
Xtrain = selectrows(Xc, train)

__site/deploy.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ preproc(s) = ACTIVATE * s
3838

3939
# Remove lines that end with `# hide`
4040
postproc(s) = replace(s, r"(^|\n).*?#(\s)*?(?i)hide(?:all)?"=>s"\1")
41+
postproc_nb(s) = replace(s, r",?\n.*?\".*?#\s*?(?i)hide(?:all)?.*?\""=>"")
4142

4243
# =============================================================================
4344

4445
get_fn(fp) = splitext(splitdir(fp)[2])[1]
4546

4647
for file in ifiles
4748
# Generate annotated notebooks
48-
Literate.notebook(file, nbpath,
49-
preprocess=preproc, postprocess=postproc,
50-
execute=false, documenter=false)
49+
Literate.notebook(file, nbpath, preprocess=preproc,
50+
execute=false, documenter=false)
51+
nbp = joinpath(nbpath, splitext(splitdir(file)[2])[1] * ".ipynb")
52+
write(nbp, postproc_nb(read(nbp, String)))
5153

5254
# Generate annotated scripts
5355
Literate.script(file, scpath,

__site/end-to-end/wine/index.html

+2-15
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,7 @@ <h2 id=getting_a_baseline ><a href="#getting_a_baseline">Getting a baseline</a><
7878
<span class=hljs-meta >@load</span> MultinomialClassifier pkg=<span class=hljs-string >"MLJLinearModels"</span>;
7979

8080
<span class=hljs-meta >@pipeline</span> KnnPipe(std=Standardizer(), clf=KNNClassifier()) is_probabilistic=<span class=hljs-literal >true</span>
81-
<span class=hljs-meta >@pipeline</span> MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=<span class=hljs-literal >true</span></code></pre><pre><code class="plaintext hljs">MnPipe(
82-
std = Standardizer(
83-
features = Symbol[],
84-
ignore = false,
85-
ordered_factor = false,
86-
count = false),
87-
clf = MultinomialClassifier(
88-
lambda = 1.0,
89-
gamma = 0.0,
90-
penalty = :l2,
91-
fit_intercept = true,
92-
penalize_intercept = false,
93-
solver = nothing,
94-
nclasses = 2)) @ 8…98</code></pre>
81+
<span class=hljs-meta >@pipeline</span> MnPipe(std=Standardizer(), clf=MultinomialClassifier()) is_probabilistic=<span class=hljs-literal >true</span>;</code></pre>
9582
<p>We can now fit this on a train split of the data setting aside 20&#37; of the data for eventual testing.</p>
9683
<pre><code class="julia hljs">train, test = partition(eachindex(yc), <span class=hljs-number >0.8</span>, shuffle=<span class=hljs-literal >true</span>, rng=<span class=hljs-number >111</span>)
9784
Xtrain = selectrows(Xc, train)
@@ -100,7 +87,7 @@ <h2 id=getting_a_baseline ><a href="#getting_a_baseline">Getting a baseline</a><
10087
ytest = selectrows(yc, test);</code></pre>
10188
<p>Let&#39;s now wrap an instance of these models with data &#40;all hyperparameters are set to default here&#41;:</p>
10289
<pre><code class="julia hljs">knn = machine(KnnPipe(), Xtrain, ytrain)
103-
multi = machine(MnPipe(), Xtrain, ytrain)</code></pre><pre><code class="plaintext hljs">Machine{MnPipe} @ 1…43
90+
multi = machine(MnPipe(), Xtrain, ytrain)</code></pre><pre><code class="plaintext hljs">Machine{MnPipe} @ 4…22
10491
</code></pre>
10592
<p>Let&#39;s train a KNNClassifier with default hyperparameters and get a baseline misclassification rate using 90&#37; of the training data to train the model and the remaining 10&#37; to evaluate it:</p>
10693
<pre><code class="julia hljs">opts = (resampling=Holdout(fraction_train=<span class=hljs-number >0.9</span>), measure=cross_entropy)

__site/generated/notebooks/A-composing-models.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"source": [
3030
"using MLJ\n",
3131
"using PrettyPrinting\n",
32-
"MLJ.color_off() # hide\n",
3332
"@load KNNRegressor\n",
3433
"# input\n",
3534
"X = (age = [23, 45, 34, 25, 67],\n",

__site/generated/notebooks/A-ensembles-2.ipynb

+3-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"using StableRNGs\n",
3434
"import DataFrames\n",
3535
"\n",
36-
"MLJ.color_off() # hide\n",
3736
"X, y = @load_boston\n",
3837
"sch = schema(X)\n",
3938
"p = length(sch.names)\n",
@@ -144,8 +143,7 @@
144143
"xlabel(\"Number of trees\", fontsize=16)\n",
145144
"xticks([10, 250, 500, 750, 1000], fontsize=14)\n",
146145
"yticks(fontsize=14)\n",
147-
"\n",
148-
"savefig(joinpath(@OUTPUT, \"A-ensembles-2-curves.svg\")) # hide"
146+
"\n"
149147
],
150148
"metadata": {},
151149
"execution_count": null
@@ -254,8 +252,7 @@
254252
"xlabel(\"Number of sub-features\", fontsize=14)\n",
255253
"yticks(0.4:0.2:1, fontsize=12)\n",
256254
"ylabel(\"Bagging fraction\", fontsize=14)\n",
257-
"\n",
258-
"savefig(joinpath(@OUTPUT, \"A-ensembles-2-heatmap.svg\")) # hide"
255+
"\n"
259256
],
260257
"metadata": {},
261258
"execution_count": null
@@ -278,8 +275,7 @@
278275
"source": [
279276
"ŷ = predict(m, X)\n",
280277
"rms(ŷ, y)\n",
281-
"\n",
282-
"PyPlot.close_figs() # hide"
278+
"\n"
283279
],
284280
"metadata": {},
285281
"execution_count": null

__site/generated/notebooks/A-ensembles-3.ipynb

+2-5
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@
156156
"\n",
157157
"plot(curve.parameter_values, curve.measurements)\n",
158158
"xlabel(curve.parameter_name)\n",
159-
"\n",
160-
"savefig(joinpath(@OUTPUT, \"e1.svg\")) # hide"
159+
"\n"
161160
],
162161
"metadata": {},
163162
"execution_count": null
@@ -195,8 +194,7 @@
195194
"\n",
196195
"plot(curve.parameter_values, curve.measurements)\n",
197196
"xlabel(curve.parameter_name)\n",
198-
"\n",
199-
"savefig(joinpath(@OUTPUT, \"e2.svg\")) # hide"
197+
"\n"
200198
],
201199
"metadata": {},
202200
"execution_count": null
@@ -212,7 +210,6 @@
212210
"outputs": [],
213211
"cell_type": "code",
214212
"source": [
215-
"PyPlot.close_figs() # hide"
216213
],
217214
"metadata": {},
218215
"execution_count": null

__site/generated/notebooks/A-ensembles.ipynb

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"using PrettyPrinting\n",
3434
"using StableRNGs\n",
3535
"\n",
36-
"MLJ.color_off() # hide\n",
3736
"\n",
3837
"rng = StableRNG(512)\n",
3938
"Xraw = rand(rng, 300, 3)\n",
@@ -295,8 +294,7 @@
295294
"xlabel(\"Bagging fraction\", fontsize=14)\n",
296295
"yticks([1, 5, 10, 15, 20], fontsize=12)\n",
297296
"ylabel(\"Number of neighbors - K\", fontsize=14)\n",
298-
"\n",
299-
"savefig(joinpath(@OUTPUT, \"A-ensembles-heatmap.svg\")) # hide"
297+
"\n"
300298
],
301299
"metadata": {},
302300
"execution_count": null
@@ -316,8 +314,7 @@
316314
"source": [
317315
"ŷ = predict(tuned_ensemble, rows=test)\n",
318316
"rms(ŷ, y[test])\n",
319-
"\n",
320-
"PyPlot.close_figs() # hide"
317+
"\n"
321318
],
322319
"metadata": {},
323320
"execution_count": null

__site/generated/notebooks/A-fit-predict.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"using PrettyPrinting\n",
3939
"using StableRNGs\n",
4040
"\n",
41-
"MLJ.color_off() # hide\n",
4241
"X, y = @load_iris;"
4342
],
4443
"metadata": {},

__site/generated/notebooks/A-learning-networks-2.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"using MLJ\n",
3131
"using StableRNGs\n",
3232
"import DataFrames\n",
33-
"MLJ.color_off() # hide\n",
3433
"@load RidgeRegressor pkg=MultivariateStats\n",
3534
"\n",
3635
"rng = StableRNG(6616) # for reproducibility\n",

__site/generated/notebooks/A-learning-networks.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"source": [
3030
"using MLJ, StableRNGs\n",
3131
"import DataFrames\n",
32-
"MLJ.color_off() # hide\n",
3332
"@load RidgeRegressor pkg=MultivariateStats\n",
3433
"\n",
3534
"rng = StableRNG(551234) # for reproducibility\n",

__site/generated/notebooks/A-model-choice.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"source": [
3737
"using RDatasets\n",
3838
"using MLJ\n",
39-
"MLJ.color_off() # hide\n",
4039
"iris = dataset(\"datasets\", \"iris\")\n",
4140
"\n",
4241
"first(iris, 3) |> pretty"

__site/generated/notebooks/A-model-tuning.ipynb

+2-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
"source": [
3838
"using MLJ\n",
3939
"using PrettyPrinting\n",
40-
"MLJ.color_off() # hide\n",
4140
"X, y = @load_iris\n",
4241
"@load DecisionTreeClassifier"
4342
],
@@ -177,8 +176,7 @@
177176
"xlabel(\"Maximum depth\", fontsize=14)\n",
178177
"ylabel(\"Misclassification rate\", fontsize=14)\n",
179178
"ylim([0, 1])\n",
180-
"\n",
181-
"savefig(joinpath(@OUTPUT, \"A-model-tuning-hpt.svg\")) # hide"
179+
"\n"
182180
],
183181
"metadata": {},
184182
"execution_count": null
@@ -310,8 +308,7 @@
310308
"ylabel(\"Bagging fraction\", fontsize=14)\n",
311309
"xticks([1, 2, 3], fontsize=12)\n",
312310
"yticks(fontsize=12)\n",
313-
"\n",
314-
"savefig(joinpath(@OUTPUT, \"A-model-tuning-hm.svg\")) # hide"
311+
"\n"
315312
],
316313
"metadata": {},
317314
"execution_count": null
@@ -327,7 +324,6 @@
327324
"outputs": [],
328325
"cell_type": "code",
329326
"source": [
330-
"PyPlot.close_figs() # hide"
331327
],
332328
"metadata": {},
333329
"execution_count": null

__site/generated/notebooks/A-stacking.ipynb

+5-11
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
"source": [
134134
"using MLJ\n",
135135
"using PyPlot\n",
136-
"MLJ.color_off() # hide\n",
137136
"using StableRNGs"
138137
],
139138
"metadata": {},
@@ -380,8 +379,7 @@
380379
"plot(x, yraw, ls=\"none\", marker=\"o\", label=\"data\")\n",
381380
"xlim(-4.5, 4.5)\n",
382381
"legend()\n",
383-
"\n",
384-
"savefig(joinpath(@OUTPUT, \"s1.svg\")) # hide"
382+
"\n"
385383
],
386384
"metadata": {},
387385
"execution_count": null
@@ -546,8 +544,7 @@
546544
"step(xsort, ysort, label=\"truth\", where=\"mid\")\n",
547545
"plot(x, y1_oos(), ls=\"none\", marker=\"o\", label=\"linear oos\")\n",
548546
"legend()\n",
549-
"\n",
550-
"savefig(joinpath(@OUTPUT, \"s2.svg\")) # hide"
547+
"\n"
551548
],
552549
"metadata": {},
553550
"execution_count": null
@@ -598,8 +595,7 @@
598595
"step(xsort, ysort, label=\"truth\", where=\"mid\")\n",
599596
"plot(x, y2_oos(), ls=\"none\", marker=\"o\", label=\"knn oos\")\n",
600597
"legend()\n",
601-
"\n",
602-
"savefig(joinpath(@OUTPUT, \"s3.svg\")) # hide"
598+
"\n"
603599
],
604600
"metadata": {},
605601
"execution_count": null
@@ -697,8 +693,7 @@
697693
"step(xsort, ysort, label=\"truth\", where=\"mid\")\n",
698694
"plot(x, yhat(), ls=\"none\", marker=\"o\", label=\"yhat\")\n",
699695
"legend()\n",
700-
"\n",
701-
"savefig(joinpath(@OUTPUT, \"s4.svg\")) # hide"
696+
"\n"
702697
],
703698
"metadata": {},
704699
"execution_count": null
@@ -985,8 +980,7 @@
985980
"cell_type": "code",
986981
"source": [
987982
"print_performance(best_stack, X, y)\n",
988-
"\n",
989-
"PyPlot.close_figs() # hide"
983+
"\n"
990984
],
991985
"metadata": {},
992986
"execution_count": null

__site/generated/notebooks/D0-loading.ipynb

+3-6
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@
9292
{
9393
"outputs": [],
9494
"cell_type": "code",
95-
"source": [
96-
"# hideall\n",
95+
"source": [,
9796
"c = \"\"\"\n",
9897
"col1,col2,col3,col4,col5,col6,col7,col8\n",
9998
",1,1.0,1,one,2019-01-01,2019-01-01T00:00:00,true\n",
@@ -162,8 +161,7 @@
162161
{
163162
"outputs": [],
164163
"cell_type": "code",
165-
"source": [
166-
"# hideall\n",
164+
"source": [,
167165
"c = \"\"\"\n",
168166
"3.26;0.829;1.676;0;1;1.453;3.770\n",
169167
"2.189;0.58;0.863;0;0;1.348;3.115\n",
@@ -226,8 +224,7 @@
226224
{
227225
"outputs": [],
228226
"cell_type": "code",
229-
"source": [
230-
"# hideall\n",
227+
"source": [,
231228
"c = \"\"\"\n",
232229
"1,0,1,0,0,0,0,1,0,1,1,?,1,0,0,0,0,1,0,0,0,0,1,67,137,15,0,1,1,1.53,95,13.7,106.6,4.9,99,3.4,2.1,34,41,183,150,7.1,0.7,1,3.5,0.5,?,?,?,1\n",
233230
"0,?,0,0,0,0,1,1,?,?,1,0,0,1,0,0,0,1,0,0,0,0,1,62,0,?,0,1,1,?,?,?,?,?,?,?,?,?,?,?,?,?,?,1,1.8,?,?,?,?,1\n",

__site/generated/notebooks/EX-AMES.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"using PrettyPrinting\n",
3333
"import DataFrames\n",
3434
"import Statistics\n",
35-
"MLJ.color_off() # hide\n",
3635
"\n",
3736
"X, y = @load_reduced_ames\n",
3837
"X = DataFrames.DataFrame(X)\n",

__site/generated/notebooks/EX-airfoil.ipynb

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"using HTTP\n",
3939
"using StableRNGs\n",
4040
"\n",
41-
"MLJ.color_off() # hide\n",
4241
"\n",
4342
"req = HTTP.get(\"https://raw.githubusercontent.com/rupakc/UCI-Data-Analysis/master/Airfoil%20Dataset/airfoil_self_noise.dat\");\n",
4443
"\n",
@@ -369,8 +368,7 @@
369368
"xlabel(\"Number of trees\", fontsize=14)\n",
370369
"ylabel(\"Sampling fraction\", fontsize=14)\n",
371370
"xticks(9:1:15, fontsize=12)\n",
372-
"yticks(fontsize=12)\n",
373-
"plt.savefig(joinpath(@OUTPUT, \"airfoil_heatmap.svg\")) # hide"
371+
"yticks(fontsize=12)\n"
374372
],
375373
"metadata": {},
376374
"execution_count": null
@@ -386,7 +384,6 @@
386384
"outputs": [],
387385
"cell_type": "code",
388386
"source": [
389-
"PyPlot.close_figs() # hide"
390387
],
391388
"metadata": {},
392389
"execution_count": null

0 commit comments

Comments
 (0)