-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.go
51 lines (47 loc) · 1.91 KB
/
example.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"golof/lof"
)
func main() {
points := [][]float64{
{-4.8447532242074978, -5.6869538132901658},
{1.7265577109364076, -2.5446963280374302},
{-1.9885982441038819, 1.705719643962865},
{-1.999050026772494, -4.0367551415711844},
{-2.0550860126898964, -3.6247409893236426},
{-1.4456945632547327, -3.7669258809535102},
{-4.6676062022635554, 1.4925324371089148},
{-3.6526420667796877, -3.5582661345085662},
{6.4551493172954029, -0.45434966683144573},
{-0.56730591589443669, -5.5859532963153349},
{-5.1400897823762239, -1.3359248994019064},
{5.2586932439960243, 0.032431285797532586},
{6.3610915734502838, -0.99059648246991894},
{-0.31086913190231447, -2.8352818694180644},
{1.2288582719783967, -1.1362795178325829},
{-0.17986204466346614, -0.32813130288006365},
{2.2532002509929216, -0.5142311840491649},
{-0.75397166138399296, 2.2465141276038754},
{1.9382517648161239, -1.7276112460593251},
{1.6809250808549676, -2.3433636210337503},
{0.68466572523884783, 1.4374914487477481},
{2.0032364431791514, -2.9191062023123635},
{-1.7565895138024741, 0.96995712544043267},
{3.3809644295064505, 6.7497121359292684},
{-4.2764152718650896, 5.6551328734397766},
{-3.6347215445083019, -0.85149861984875741},
{-5.6249411288060385, -3.9251965527768755},
{4.6033708001912093, 1.3375110154658127},
{-0.685421751407983, -0.73115552984211407},
{-2.3744241805625044, 1.3443896265777866},
}
samples := lof.GetSamplesFromFloat64s(points)
lofGetter := lof.NewLOF(5)
lofGetter.Train(samples)
mapping := lofGetter.GetLOFs(samples, "fast")
for sample, factor := range mapping {
fmt.Printf("Sample: %v, \tLOF: %f\n", sample.GetPoint(), factor)
}
lofGetter.Reset()
}