ak0da project
Go to file
2023-05-14 21:30:22 +02:00
.editorconfig initial commit 2023-05-14 16:47:01 +02:00
.envrc initial commit 2023-05-14 16:47:01 +02:00
.gitattributes initial commit 2023-05-14 16:47:01 +02:00
.gitignore go,nix: add Isolation Forest outlier detection 2023-05-14 19:55:21 +02:00
.golangci.yml initial commit 2023-05-14 16:47:01 +02:00
.pre-commit-config.yaml go: appease the linters 2023-05-14 21:03:45 +02:00
data.go go: break out data handling funcs to its own file 2023-05-14 21:30:22 +02:00
default.nix initial commit 2023-05-14 16:47:01 +02:00
flake.lock initial commit 2023-05-14 16:47:01 +02:00
flake.nix go,nix: add Isolation Forest outlier detection 2023-05-14 19:55:21 +02:00
go.mod go,nix: add Isolation Forest outlier detection 2023-05-14 19:55:21 +02:00
go.sum go,nix: add Isolation Forest outlier detection 2023-05-14 19:55:21 +02:00
main.go go: break out data handling funcs to its own file 2023-05-14 21:30:22 +02:00
README.md readme: add example output 2023-05-14 21:09:24 +02:00
shell.nix initial commit 2023-05-14 16:47:01 +02:00

ak0da

this repo contains code of the compulsory task for AK0DA course.

the topic is anomaly/outlier detection using golearn's Isolation Forest model implementation.

to test the functionality you'd need:

  • Go (v1.20.x+)
  • alternatively, you could use Nix

with Go ready, do:

go install -v git.dotya.ml/wanderer/ak0da@latest
$GOPATH/bin/ak0da

# or to run the code directly:
go run -v git.dotya.ml/wanderer/ak0da@latest

or with (flake-enabled) Nix, do:

nix run git+https://git.dotya.ml/wanderer/ak0da#proj

both of the above should put the ak0da binary in your $GOPATH, from where you can run it.
it then drops a data.csv file in $PWD which is overwritten everytime the program is run.

the last 15 (the amount is hardcoded) values are outliers, which should stand out to the model and be detected as such.

by default there are 10001 "normal" (standard normal distribution or uniform distribution < -1; 1 >) values generated, to array of which the outliers are appended.

example output:

$ go run -v .
git.dotya.ml/wanderer/ak0da
2023/05/14 20:58:19 generating data
2023/05/14 20:58:19 generating data - done
2023/05/14 20:58:19 saving data at 'data.csv'
2023/05/14 20:58:19 writing data
2023/05/14 20:58:19 writing data - done
2023/05/14 20:58:19 Train Isolation Forest model (nTrees: 1000, maxDepth: 1000, subSpace: 7500) on the data
2023/05/14 20:58:41 Calculate avg/min scores
	Average anomaly score for normal data: 0.410835
	Minimum anomaly score for normal data: 0.358608
	Anomaly scores for outliers are:
	0.8326351331269884
	0.8418463721853892
	0.8770692966745977
	0.8252221454618904
	0.8778969291657617
	0.8484648511184422
	0.8599306977267279
	0.8585139586360264
	0.8494674322646776
	0.8588444630459295
	0.8507734185366144
	0.8796766012823853
	0.868373052855811
	0.852372446867535
	0.8598396082607581
2023/05/14 20:58:41 we're done