Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 53 additions & 44 deletions notebooks/03 Neural Networks.ipynb

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions notebooks/05 Feature Engineering.ipynb

Large diffs are not rendered by default.

151 changes: 35 additions & 116 deletions notebooks/06 Feature Extraction and Selection.ipynb

Large diffs are not rendered by default.

196 changes: 103 additions & 93 deletions notebooks/07 Cross Validation.ipynb

Large diffs are not rendered by default.

563 changes: 286 additions & 277 deletions notebooks/10 Automated Machine Learning.ipynb

Large diffs are not rendered by default.

977 changes: 372 additions & 605 deletions notebooks/11 Clustering.ipynb

Large diffs are not rendered by default.

210 changes: 102 additions & 108 deletions notebooks/12 Time Series Forecasting.ipynb

Large diffs are not rendered by default.

66 changes: 65 additions & 1 deletion utils/graphics.q
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ plotprxpred:{
// @param label {string} plot label
// @return {<} embedpy plot
plotTimeSeries:{[dt;series;label]
plt[`:plot][dts:q2pydts dt;series];
plt[`:plot][q2pydts dt;series];
plt[`:xlabel]["Date"];
plt[`:ylabel][label];
plt[`:title][label," vs Date"];
Expand Down Expand Up @@ -180,3 +180,67 @@ plotResiduals:{
plt[`:show][];
}

// @kind function
// @category misc
// @fileoverview Plot results in scatter plot
// @param trn {float[][]} Data points in value flip format
// @param tst {float[][]} Data points in value flip format
// @param ttl {string} Plot title
// @param clt {long[]} List of cluster labels
// @param s {boolean} Indicates whether to show plot or not
// @return {null}
plotResults:{[trn;tst;ttl;clt;s]
$[clt~(::);
plt[`:scatter]. trn;
plt[`:scatter][;;`c pykw clt]. trn];
if[not tst~();
plt[`:scatter][;;`c pykw`r;`label pykw"Testing data"]. tst;
plt[`:legend][`bbox_to_anchor pykw 1.05 1;`loc pykw"upper left"]];
plt[`:title]ttl;
plt[`:xlabel]"X";
plt[`:ylabel]"Y";
if[s;plt[`:show][];];
}

// plot new dataset - inputs trn and ttl
plotDataset:plotResults[;();;::;1b]
// plot clusters from single dataset - inputs trn,ttl,clt
plotCluster:plotResults[;();;;1b]
// plot clusters for training and testing data - inputs trn,tst,ttl,clt
plotTrainTest:plotResults[;;;;1b]
// plot kmeans and add cluster centres - trn,ttl and results from kmeans algo r1 and updated results r2
plotKMeans:{[trn;r1;r2;ttl]
plotResults[trn;();ttl;;0b]$[(::)~r2;r1`clt;r2`clt];
plt[`:scatter][;;`c pykw"#ff028d";`marker pykw"*";`s pykw 500;`label pykw"Original centres"]. flip r1`reppts;
if[not(::)~r2;
plt[`:scatter][;;`c pykw"#21fc0d";`marker pykw"*";`s pykw 500;`label pykw"Updated centres"]. flip r2`reppts];
plt[`:legend][`bbox_to_anchor pykw 1.05 1;`loc pykw"upper left"];
plt[`:show][];
}

// Plot clusters and dendrogram
// @param d {float[][]} Data points
// @param lf {symbol} Linkage function
// @param dend {dict} Results of HC algo
// @param clust {long[]} Clusters - results of HC cut function
// @return {null}
plotHCResults:{[d;lf;dend;clust]
// initialize subplots
subplots:plt[`:subplots][1;2];
fig::subplots[@;0];axarr::subplots[@;1];
fig[`:set_size_inches;18.5;8.5];
// set plot title
ttl:@[string lf;0;upper];
// plot clusters
a0:axarr[@;0];
a0[`:scatter][;;`c pykw clust`clt]. d;
a0[`:set_title]ttl," Clustered Data";
a0[`:set_xlabel]"X";
a0[`:set_ylabel]"Y";
// plot dendrogram using scipy functionality
.p.import[`scipy.cluster;`:hierarchy;`:dendrogram]flip value flip dend`dgram;
plt[`:title]ttl," Dendrogram";
plt[`:xlabel]"Point Index";
plt[`:ylabel]"Distance";
plt[`:show][];
}
1 change: 0 additions & 1 deletion utils/util.q
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ ttsTimeSeries:{[tab;tar;sz]`xtrain`ytrain`xtest`ytest!raze(tab;tar)@\:/:(0,floor
rmsle:{
"The RMSLE is: ",string .ml.rmsle[x;y]
}