Documentation ¶
Overview ¶
Practical mathematical functions used to normalize and transform prediction results
Index ¶
- func Aroon(close []float64, window int) (aroon []float64)
- func ExtractTfArchive(f Namer, modelPath string) error
- func NormalizedSigmoid(x float32) float64
- func RemoveZeroValues(input []float64) ([]float64, []int)
- func SimpleMovingAverage(input []float64, n int) []float64
- func TrainModelLocally(ctx context.Context, shareId string) error
- type Namer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aroon ¶
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 ¶
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 ¶
Sigmoid function based this formula: https://de.wikipedia.org/wiki/Sigmoidfunktion
Transforming value range from [0,1] to [-1,1]
func RemoveZeroValues ¶
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 ¶
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]