util

package
v0.0.0-...-ec05587 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Practical mathematical functions used to normalize and transform prediction results

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aroon

func Aroon(close []float64, window int) (aroon []float64)

Calculates the Aroon index based on the closing prices and a given period to analyse. Normally the window is window=25, but it is customizable.

The output array has the same length as the closing price array. The missing len(close)-window elements will be inserted at the beginning of the result array and initialized with 0

func ExtractTfArchive

func ExtractTfArchive(f Namer, modelPath string) error

Extracts an archive downloaded from the gcp bucket.

Normally the archive should contain a trained model from Tensorflow; other archives are not verified

func NormalizedSigmoid

func NormalizedSigmoid(x float32) float64

Sigmoid function based this formula: https://de.wikipedia.org/wiki/Sigmoidfunktion

Transforming value range from [0,1] to [-1,1]

func RemoveZeroValues

func RemoveZeroValues(input []float64) ([]float64, []int)

Removes 0 Values of an Array and returnes the clean array as well as the index of the removed items

Example
package main

import (
	"fmt"

	"github.com/DHBWMannheim/ml-server/util"
)

func main() {
	clean, ri := util.RemoveZeroValues([]float64{1, 2, 5, 0, 4, 1, 5, 0, 3})

	fmt.Println(clean, ri)
}
Output:

[1 2 5 4 1 5 3] [3 7]

func SimpleMovingAverage

func SimpleMovingAverage(input []float64, n int) []float64

Calculates the SMA of the given input array with the given window size n.

It calculates the CumSum of the input array and afterwards slices it into the final result.

Example
package main

import (
	"fmt"

	"github.com/DHBWMannheim/ml-server/util"
)

func main() {
	res := util.SimpleMovingAverage([]float64{1, 2, 3, 4}, 2)

	fmt.Println(res)
}
Output:

[1 1.5 2.5 3.5]

func TrainModelLocally

func TrainModelLocally(ctx context.Context, shareId string) error

Types

type Namer

type Namer interface {
	Name() string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL