public void GlobalSetup() { // setup input sets _inputSets = Enumerable.Range(0, 250).Select(_ => { var inp = Enumerable.Range(0, NumInputs).Select(_ => (float)_rng.NextDouble()).ToArray(); return(inp); }).ToArray(); // setup coefficients _coeff = new float[NumInputs, NumOutputs]; _intercepts = new float[NumOutputs]; for (var ip = 0; ip < NumInputs; ++ip) { for (var op = 0; op < NumOutputs; ++op) { var v = (float)_rng.NextDouble(); _coeff[ip, op] = v; // column-major (normal) } } for (var op = 0; op < NumOutputs; ++op) { _intercepts[op] = (float)_rng.NextDouble(); } _linearEstimator = new LinearEstimator(_coeff, _intercepts); }
public void BasicOperation() { var coefficients = new float[, ] { { 1, 2, 3 }, { 4, 5, 6 } }; var intercepts = new float[] { 100, 200, 300 }; using var est = new LinearEstimator(coefficients, intercepts); var features = new float[] { 1, 2 }; var results = new float[3]; est.EstimateLinear(features, results); Assert.Equal(new float[] { 109, 212, 315 }, results); }