Skip to content

Commit 6e2fdd3

Browse files
authored
fix typos in comments (#7)
1 parent 08900d1 commit 6e2fdd3

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

em.q

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mf:.ml.wbinmle[n;0] / parameter maximization function
1515
phi:2#1f%2f / coins are picked with equal probability
1616
.ml.em[1b;lf;mf;x] . pT:(phi;flip enlist THETA)
1717
(.ml.em[1b;lf;mf;x]//) pT / call until convergence
18-
/ which flips came from which THETA? pick maximum log likelkhood
18+
/ which flips came from which THETA? pick maximum log likelihood
1919

2020
pT:(.ml.em[1b;lf;mf;x]//) pT
2121
.util.assert[1 0 0 1 0] .ml.imax .ml.likelihood[0b;lf;x] . pT
@@ -46,7 +46,7 @@ mu0:10 20 30 / distribution's mu
4646
s20:s0*s0:1 3 2 / distribution's variance
4747
m0:100 200 150 / number of points per distribution
4848
X:raze X0:mu0+s0*(.ml.bm ?[;1f]::) each m0 / build dataset
49-
show .util.plt raze each (X0;0f*X0),'(X0;.ml.gaussl'[mu0;s20;X0]) / plot 1d data and guassian curves
49+
show .util.plt raze each (X0;0f*X0),'(X0;.ml.gaussl'[mu0;s20;X0]) / plot 1d data and gaussian curves
5050
k:count mu0
5151
phi:k#1f%k; / guess that distributions occur with equal frequency
5252
mu:neg[k]?X; / pick k random points as centers

fmincg.q

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/ Minimize a continuous differentialble multivariate function. Starting point
1+
/ Minimize a continuous differentiable multivariate function. Starting point
22
/ is given by "X" (D by 1), and the function named in the string "f", must
33
/ return a function value and a vector of partial derivatives. The Polack-
44
/ Ribiere flavour of conjugate gradients is used to compute search
@@ -53,7 +53,7 @@
5353
/ f) introduced BREAK variable to overcome q's lack of break statement
5454
/ 2) max length "n" is now mandatory
5555

56-
\d .fmincg / function minimize nonlinear congjugate gradient
56+
\d .fmincg / function minimize nonlinear conjugate gradient
5757

5858
RHO:.01 / a bunch of constants for line searches
5959
SIG:.5 / RHO and SIG are the constants in the Wolfe-Powell conditions
@@ -93,12 +93,12 @@ minimize:{[F;v]
9393
extrapolate:{[F;v]
9494
v[`z2]:cubicextrapolation . v`f2`f3`d2`d3`z3;
9595
v[`z2]:$[$[0>v`z2;1b;0w=v`z2];$[.5>=v`limit;v[`z1]*EXT-1;.5*v[`limit]-v`z1];
96-
/ extraplation beyond max? -> bisect
96+
/ extrapolation beyond max? -> bisect
9797
$[-.5<v`limit;v[`limit]<v[`z2]+v`z1;0b];.5*v[`limit]-v`z1;
98-
/ extraplation beyond limit? -> set to limit
98+
/ extrapolation beyond limit? -> set to limit
9999
$[-.5>v`limit;(EXT*v`z1)<v[`z2]+v`z1;0b];v[`z1]*EXT-1;
100100
v[`z2]<v[`z3]*neg INT;v[`z3]*neg INT;
101-
/ too clost to limit?
101+
/ too close to limit?
102102
$[-.5<v`limit;v[`z2]<(v[`limit]-v`z1)*1f-INT;0b];(v[`limit]-v`z1)*1f-INT;
103103
v[`z2]];
104104
v[`f3]:v`f2;v[`d3]:v`d2;v[`z3]:neg v`z2; / set pt 3 = pt 2

ml.q

+7-7
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ gaussl:{[mu;sigma;x]
400400
p:exp (x*x-:mu)%-2*sigma;
401401
p%:sqrt sigma*twopi;
402402
p}
403-
/ guassian log likelihood
403+
/ gaussian log likelihood
404404
gaussll:{[mu;sigma;X] -.5*sum (logtwopi;log sigma;(X*X-:mu)%sigma)}
405405
/ gaussian maximum likelihood estimator
406406
gaussmle:{[x](mu;avg x*x-:mu:avg x)}
@@ -433,7 +433,7 @@ likelihood:{[l;lf;X;phi;THETA]
433433
p:$[l;p+log phi;p*phi]; / apply prior probabilities
434434
p}
435435

436-
/ using (l)ikelhood (f)unction, (w)eighted (m)aximum likelihood estimator
436+
/ using (l)ikelihood (f)unction, (w)eighted (m)aximum likelihood estimator
437437
/ (f)unction with prior probabilities (p)hi and distribution parameters
438438
/ (THETA) (with optional (f)itting of (p)hi) perform expectation maximization
439439
em:{[fp;lf;wmf;X;phi;THETA]
@@ -448,7 +448,7 @@ em:{[fp;lf;wmf;X;phi;THETA]
448448
tdm:{[c;v](-1_@[(1+count v)#0;;+;1]::) each v?c}
449449

450450
lntf:{log 1f+x} / log normalized term frequency
451-
dntf:{[k;x]k+(1f-k)*x% max each x} / double normalized term frequenecy
451+
dntf:{[k;x]k+(1f-k)*x% max each x} / double normalized term frequency
452452

453453
idf: {log count[x]%sum 0<x} / inverse document frequency
454454
idfs:{log 1f+count[x]%sum 0<x} / inverse document frequency smooth
@@ -554,7 +554,7 @@ dt:{[cgf;ogf;ipf;opt;w;t]
554554
opt:(`maxd`minss`minsl`ming`maxff!(0N;2;1;0;::)),opt; / default options
555555
if[0=opt`maxd;:(w;first d)]; / check if we've reached max depth
556556
if[identical a:first d;:(w;a)]; / check if all values are equal
557-
if[opt[`minss]>count a;:(w;a)]; / check if insufficent samples
557+
if[opt[`minss]>count a;:(w;a)]; / check if insufficient samples
558558
d:((neg floor opt[`maxff] count d)?key d)#d:1 _d; / sub-select features
559559
d:{.[x isord z;y] z}[(cgf;ogf);(ipf;w;a)] peach d; / compute gains
560560
d:(where (any opt[`minsl]>count each last::) each d) _ d; / filter on minsl
@@ -575,7 +575,7 @@ dtcr:{[tr;d] / recursive component
575575
v:(,'/) tr[2] .z.s\: d; / dig deeper for null values
576576
v}
577577

578-
/ decistion tree pruning primitives
578+
/ decision tree pruning primitives
579579

580580
/ wilson score - binary confidence interval (Edwin Bidwell Wilson)
581581
wscore:{[z;f;n](f+(.5*z2n)+-1 1f*z*sqrt((.25*z2n)+f-f*f)%n)%1f+z2n:z*z%n}
@@ -637,7 +637,7 @@ dtkfxv:{[dtf;ef;a;ts]kfxvt[dtmincc[ef]\[;a]dtf::;dtc\:/:;ts]}
637637

638638
/ decision tree utilities
639639

640-
/ print leaf: prediction followd by classification error% or regresssion sse
640+
/ print leaf: prediction followed by classification error% or regression sse
641641
pleaf:{[w;x]
642642
v:waom[w;x]; / value
643643
e:$[isord x;string sum e*e:v-x;string[.1*"i"$1e3*1f-avg x = v],"%"];
@@ -693,7 +693,7 @@ rt:dt[oig;oig;wmse] / regression tree
693693
/ random forest
694694

695695
/ generate (n) decision trees by applying (f) to a resampled (with
696-
/ replacemnt) (t)able
696+
/ replacement) (t)able
697697
bag:{[n;f;t](f ?[;t]::) peach n#count t} / (b)ootstrap (ag)gregating
698698

699699
/ given an atom or list (k), and bootstrap aggregating (m)odel, make

porter.q

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ hasvowel:{any vowel x}
3838
/ returns true if x ends in a double consonant
3939
doublec:{$[2>count x;0b;(=) . -2#x;last cons x;0b]}
4040

41-
/ return true if last three letters are consontant - vowel -
42-
/ consontant and last letter is not in "wxy"
41+
/ return true if last three letters are consonant - vowel -
42+
/ consonant and last letter is not in "wxy"
4343
cvc:{$[3>count x;0b;101b~-3#cons x;not last[x] in "wxy";0b]}
4444

45-
/ if a<m replace n charaters with (r)eplacement suffix
45+
/ if a<m replace n characters with (r)eplacement suffix
4646
r:{[a;n;r;x]$[a<m n:n _ x;n,r;x]}
4747

4848
/ compute m where m in c?(vc){m}v? and c and v are consecutive lists
49-
/ of consontants and vowels
49+
/ of consonants and vowels
5050
m:{sum[x] - first x:x where differ x:cons x}
5151

5252
/ remove plurals and -ed or -ing

0 commit comments

Comments
 (0)