6 instantiations of Single
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
PresentationCore (4)
PresentationFramework (1)
2707 references to Single
Aspire.Dashboard (3)
dotnet-svcutil-lib (37)
Microsoft.AspNetCore.Components (4)
Microsoft.AspNetCore.Components.Server (2)
Microsoft.AspNetCore.Components.Tests (2)
Microsoft.AspNetCore.Mvc.TagHelpers (1)
Microsoft.AspNetCore.OpenApi (1)
Microsoft.AspNetCore.SignalR.Tests (1)
Microsoft.Build (1)
Microsoft.CodeAnalysis.CSharp (1)
Microsoft.CodeAnalysis.CSharp.Features (1)
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (4)
Microsoft.CodeAnalysis.UnitTests (1)
Microsoft.CodeAnalysis.Workspaces.UnitTests (6)
Microsoft.Data.Analysis (95)
Microsoft.DotNet.XUnitAssert.Tests (1)
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (8)
Microsoft.Extensions.Diagnostics.Testing.Tests (1)
Microsoft.Maui (13)
Microsoft.Maui.Controls (23)
Brush\BrushTypeConverter.cs (8)
267 foreach (var offset in offsets)
302 if (TryParseNumber(part, "deg", out var degrees))
308 if (TryParseNumber(part, "turn", out var turn))
337 var hasPositionX = TryParseOffset(directionX, out var positionX);
338 var hasPositionY = TryParseOffset(directionY, out var positionY);
380 if (float.TryParse(number, NumberStyles.Any, CultureInfo.InvariantCulture, out var value))
396 if (TryParseNumber(part, "%", out var value))
419 if (TryParseOffset(part, out var offset))
Microsoft.Maui.Controls.Build.Tasks (1)
Microsoft.Maui.Controls.Xaml (2)
Microsoft.Maui.Essentials (1)
Microsoft.Maui.Graphics (155)
Color.cs (26)
204 var l = (m + v) / 2.0f;
212 ToHsl(out var h, out var s, out var l);
220 ToHsl(out var h, out var s, out var l);
226 ToHsl(out var h, out var s, out var l);
232 ToHsl(out var h, out var s, out var l);
238 ToHsl(out var h, out var s, out var l);
244 ToHsl(out var h, out var s, out var l);
250 ToHsl(out var h, out var s, out var l);
268 var p = v * (1 - s);
522 var r = Red;
523 var g = Green;
524 var b = Blue;
GradientPaint.cs (10)
187 var before = float.MaxValue;
189 var after = float.MaxValue;
194 var currentOffset = stops[i].Offset;
203 var dx = offset - currentOffset;
212 var dx = currentOffset - offset;
231 var f = GeometryUtil.GetFactor(before, after, offset);
250 var r = GeometryUtil.GetLinearValue(startColor.Red, endColor.Red, factor);
251 var g = GeometryUtil.GetLinearValue(startColor.Green, endColor.Green, factor);
252 var b = GeometryUtil.GetLinearValue(startColor.Blue, endColor.Blue, factor);
253 var a = GeometryUtil.GetLinearValue(startColor.Alpha, endColor.Alpha, factor);
Microsoft.Maui.Graphics.Skia (67)
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (20)
Microsoft.Maui.Resizetizer (12)
Microsoft.ML.AutoML (30)
Sweepers\SmacSweeper.cs (16)
11using Float = System.Single;
46public Float SplitRatio;
49public Float Epsilon;
109Single[] targets = new Single[previousRuns.Count()];
110Single[][] features = new Single[previousRuns.Count()][];
116targets[i] = (Float)r.MetricValue;
278Float[] neighbor = SweeperProbabilityUtils.ParameterSetAsFloatArray(_sweepParameters, parent, false);
306Float[] neigh = SweeperProbabilityUtils.ParameterSetAsFloatArray(_sweepParameters, parent, false);
310neigh[i] = (Float)newVal;
333Float[] transformedParams = SweeperProbabilityUtils.ParameterSetAsFloatArray(_sweepParameters, config, true);
334VBuffer<Float> features = new VBuffer<Float>(transformedParams.Length, transformedParams);
336var leafValue = GetLeafValue(forest, treeId, leafId);
350private static int GetLeaf(TreeEnsembleModelParameters model, int treeId, VBuffer<Float> features)
Microsoft.ML.CodeGenerator (3)
Microsoft.ML.Core (76)
Microsoft.ML.Core.Tests (104)
UnitTests\TestEntryPoints.cs (92)
428L1Regularization = (Single)0.1 * i,
429L2Regularization = (Single)0.01 * (1 + i),
474var avgScoreGetter = curs1.GetGetter<Single>(scoreColumn.Value);
478var medScoreGetter = curs2.GetGetter<Single>(scoreColumn.Value);
482var regScoreGetter = curs3.GetGetter<Single>(scoreColumn.Value);
484var individualScoreGetters = new ValueGetter<Single>[nModels];
488individualScoreGetters[i] = curs4.GetGetter<Single>(scoreColumn.Value);
491var scoreBuffer = new Single[nModels];
501Single score = 0;
505Single avgScore = 0;
510Single medScore = 0;
1562L1Regularization = (Single)0.1 * i,
1563L2Regularization = (Single)0.01 * (1 + i),
1686var getter0 = curs0.GetGetter<Single>(scoreColumn.Value);
1689var getter1 = curs1.GetGetter<Single>(scoreColumn.Value);
1692var getter2 = curs2.GetGetter<Single>(scoreColumn.Value);
1695var getter3 = curs3.GetGetter<Single>(scoreColumn.Value);
1698var getter4 = curs4.GetGetter<Single>(scoreColumn.Value);
1701var getterReg = cursReg.GetGetter<Single>(scoreColumn.Value);
1704var getterBin = cursBin.GetGetter<Single>(scoreColumn.Value);
1707var getterBinCali = cursBinCali.GetGetter<Single>(scoreColumn.Value);
1710var getterSaved = cursSaved.GetGetter<Single>(scoreColumn.Value);
1713var getterAnom = cursAnom.GetGetter<Single>(scoreColumn.Value);
1718Single score = 0;
1729Single[] score0 = new Single[5];
1735Single scoreBin = 0;
1736Single scoreBinCali = 0;
1737Single scoreSaved = 0;
1738Single scoreAnom = 0;
1743Assert.True(Single.IsNaN(scoreBin) && Single.IsNaN(score) || scoreBin == score);
1744Assert.True(Single.IsNaN(scoreBinCali) && Single.IsNaN(score) || scoreBinCali == score);
1745Assert.True(Single.IsNaN(scoreSaved) && Single.IsNaN(score) || CompareNumbersWithTolerance(scoreSaved, score, null, 5));
1746Assert.True(Single.IsNaN(scoreAnom) && Single.IsNaN(score) || scoreAnom == score);
1748Single avg = 0;
1750Assert.True(Single.IsNaN(avg) && Single.IsNaN(score) || avg == score);
1828L1Regularization = (Single)0.1 * i,
1829L2Regularization = (Single)0.01 * (1 + i),
1912var getter0 = curs0.GetGetter<Single>(scoreColumn.Value);
1915var getter1 = curs1.GetGetter<Single>(scoreColumn.Value);
1918var getter2 = curs2.GetGetter<Single>(scoreColumn.Value);
1921var getter3 = curs3.GetGetter<Single>(scoreColumn.Value);
1924var getter4 = curs4.GetGetter<Single>(scoreColumn.Value);
1927var getterReg = cursReg.GetGetter<Single>(scoreColumn.Value);
1930var getterBin = cursBin.GetGetter<Single>(scoreColumn.Value);
1933var getterBinCali = cursBinCali.GetGetter<Single>(scoreColumn.Value);
1936var getterSaved = cursSaved.GetGetter<Single>(scoreColumn.Value);
1941Single score = 0;
1951Single[] score0 = new Single[5];
1957Single scoreBin = 0;
1958Single scoreBinCali = 0;
1959Single scoreSaved = 0;
1963Assert.True(Single.IsNaN(scoreBin) && Single.IsNaN(score) || scoreBin == score);
1964Assert.True(Single.IsNaN(scoreBinCali) && Single.IsNaN(score) || scoreBinCali == score);
1965Assert.True(Single.IsNaN(scoreSaved) && Single.IsNaN(score) || scoreSaved == score);
1967Single avg = 0;
1969Assert.True(Single.IsNaN(avg) && Single.IsNaN(score) || avg == score);
2070var getter0 = curs0.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2073var getter1 = curs1.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2076var getter2 = curs2.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2079var getter3 = curs3.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2082var getter4 = curs4.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2085var getter = curs.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2088var getterSaved = cursSaved.GetGetter<VBuffer<Single>>(scoreColumn.Value);
2091VBuffer<Single> score = default(VBuffer<Single>);
2092VBuffer<Single>[] score0 = new VBuffer<Single>[5];
2093VBuffer<Single> scoreSaved = default(VBuffer<Single>);
2094VBuffer<Single> avg = default(VBuffer<Single>);
2095VBuffer<Single> dense1 = default(VBuffer<Single>);
2096VBuffer<Single> dense2 = default(VBuffer<Single>);
2264private static bool CompareVBuffers(in VBuffer<Single> v1, in VBuffer<Single> v2, ref VBuffer<Single> dense1, ref VBuffer<Single> dense2)
2274if (!Single.IsNaN(dense1Values[i]) && !Single.IsNaN(dense2Values[i]) && dense1Values[i] != dense2Values[i])
Microsoft.ML.CpuMath (1)
Microsoft.ML.CpuMath.UnitTests (10)
UnitTests.cs (10)
643var actual = CpuMathUtils.Sum(src);
666var actual = CpuMathUtils.SumSq(src);
684var actual = CpuMathUtils.SumSq(defaultScale, src);
714var actual = CpuMathUtils.SumAbs(src);
732var actual = CpuMathUtils.SumAbs(defaultScale, src);
756var actual = CpuMathUtils.MaxAbs(src);
785var actual = CpuMathUtils.MaxAbsDiff(defaultScale, src);
825var actual = CpuMathUtils.DotProductDense(src, dst, dst.Length);
859var actual = CpuMathUtils.DotProductSparse(src, dst, idx, limit);
891var actual = CpuMathUtils.L2DistSquared(src, dst, dst.Length);
Microsoft.ML.Data (654)
Data\Conversion.cs (65)
24using R4 = Single;
122AddStd<I1, R4>(Convert);
132AddStd<I2, R4>(Convert);
142AddStd<I4, R4>(Convert);
152AddStd<I8, R4>(Convert);
163AddStd<U1, R4>(Convert);
174AddStd<U2, R4>(Convert);
185AddStd<U4, R4>(Convert);
196AddStd<U8, R4>(Convert);
210AddStd<R4, R4>(Convert);
211AddStd<R4, BL>(Convert);
212AddStd<R4, R8>(Convert);
213AddAux<R4, SB>(Convert);
214AddStd<R4, TX>(Convert);
216AddStd<R8, R4>(Convert);
231AddStd<TX, R4>(Convert);
244AddStd<BL, R4>(Convert);
251AddStd<TS, R4>(Convert);
257AddStd<DT, R4>(Convert);
264AddStd<DZ, R4>(Convert);
269AddIsNA<R4>(IsNA);
272AddGetNA<R4>(GetNA);
275AddHasNA<R4>(HasNA);
282AddIsDef<R4>(IsDefault);
309AddTryParse<R4>(TryParse);
766private bool IsNA(in R4 src) => R4.IsNaN(src);
771private bool HasNA(in VBuffer<R4> src) { var srcValues = src.GetValues(); for (int i = 0; i < srcValues.Length; i++) { if (R4.IsNaN(srcValues[i])) return true; } return false; }
780private bool IsDefault(in R4 src) => src == 0;
802private void GetNA(ref R4 value) => value = R4.NaN;
879public void Convert(in I1 src, ref R4 dst) => dst = (R4)src;
880public void Convert(in I2 src, ref R4 dst) => dst = (R4)src;
881public void Convert(in I4 src, ref R4 dst) => dst = (R4)src;
882public void Convert(in I8 src, ref R4 dst) => dst = (R4)src;
883public void Convert(in U1 src, ref R4 dst) => dst = src;
884public void Convert(in U2 src, ref R4 dst) => dst = src;
885public void Convert(in U4 src, ref R4 dst) => dst = src;
889public void Convert(in U8 src, ref R4 dst) => dst = src;
891public void Convert(in TS src, ref R4 dst) => dst = (R4)src.Ticks;
892public void Convert(in DT src, ref R4 dst) => dst = (R4)src.Ticks;
893public void Convert(in DZ src, ref R4 dst) => dst = (R4)src.UtcDateTime.Ticks;
924public void Convert(in R4 src, ref SB dst) { ClearDst(ref dst); if (R4.IsNaN(src)) dst.AppendFormat(CultureInfo.InvariantCulture, "{0}", "?"); else dst.AppendFormat(CultureInfo.InvariantCulture, "{0:R}", src); }
949public void Convert(in R4 src, ref TX dst) => dst = src.ToString("G7", CultureInfo.InvariantCulture).AsMemory();
959public void Convert(in R4 src, ref BL dst) => dst = System.Convert.ToBoolean(src);
971public void Convert(in R4 src, ref R4 dst) => dst = src;
972public void Convert(in R4 src, ref R8 dst) => dst = src;
976public void Convert(in R8 src, ref R4 dst) => dst = (R4)src;
1375public bool TryParse(in TX src, out R4 dst)
1380dst = R4.NaN;
1682public void Convert(in TX src, ref R4 value)
1688value = R4.NaN;
1726public void Convert(in BL src, ref R4 dst) => dst = System.Convert.ToSingle(src);
Evaluators\BinaryClassifierEvaluator.cs (54)
36public Single Threshold;
104private readonly Single _threshold;
240var scores = new List<Single>();
402private readonly Single _threshold;
494public Counters(bool useRaw, Single threshold)
500public void Update(Single score, Single prob, Single label, Double logloss, Single weight)
519if (!Single.IsNaN(prob))
533public Single Score;
534public Single Label;
535public Single Weight;
539public readonly List<Single> Scores;
560private ValueGetter<Single> _labelGetter;
561private ValueGetter<Single> _scoreGetter;
562private ValueGetter<Single> _weightGetter;
563private ValueGetter<Single> _probGetter;
564private Single _score;
565private Single _label;
566private Single _weight;
571int auPrcReservoirSize, Single threshold, bool useRaw, int prCount, string stratName)
610Scores = new List<Single>();
628_scoreGetter = row.GetGetter<Single>(score);
636_probGetter = row.GetGetter<Single>(prob[0]);
638_probGetter = (ref Single value) => value = Single.NaN;
642_weightGetter = row.GetGetter<Single>(schema.Weight.Value);
654if (Single.IsNaN(_label))
660Single prob = 0;
664if (!Single.IsNaN(prob))
746Single scoreCur = Single.PositiveInfinity;
748.Concat(new[] { new RocInfo() { Score = Single.NegativeInfinity } }))
768if (Single.IsNegativeInfinity(point.Score))
1056private readonly Single _threshold;
1060public BinaryPerInstanceEvaluator(IHostEnvironment env, DataViewSchema schema, string scoreCol, string probCol, string labelCol, Single threshold, bool useRaw)
1157Single label = 0;
1158Single prob = 0;
1159Single score = 0;
1161ValueGetter<Single> nanGetter = (ref Single value) => value = Single.NaN;
1164ValueGetter<Single> probGetter;
1166probGetter = input.GetGetter<Single>(input.Schema[_probIndex]);
1169ValueGetter<Single> scoreGetter;
1171scoreGetter = input.GetGetter<Single>(input.Schema[ScoreIndex]);
1231private Double GetLogLoss(Single prob, Single label)
1233if (Single.IsNaN(prob) || Single.IsNaN(label))
1240private bool GetPredictedLabel(Single val)
1243return Single.IsNaN(val) ? false : val > _threshold;
1293public Single Threshold;
Evaluators\RankingEvaluator.cs (27)
296private readonly List<Single> _queryOutputs;
375_queryOutputs = new List<Single>();
379public void Update(short label, Single output)
385public void UpdateGroup(Single weight)
421private Single _currentQueryWeight;
423private ValueGetter<Single> _labelGetter;
424private ValueGetter<Single> _scoreGetter;
425private ValueGetter<Single> _weightGetter;
446_currentQueryWeight = Single.NaN;
461_scoreGetter = row.GetGetter<Single>(score);
464_weightGetter = row.GetGetter<Single>(schema.Weight.Value);
487Single label = 0;
488Single score = 0;
492if (Single.IsNaN(score))
502Single weight = 1;
506if (Single.IsNaN(_currentQueryWeight))
520_currentQueryWeight = Single.NaN;
628private sealed class Transform : PerGroupTransformBase<short, Single, Transform.RowCursorState>
791Single label = 0;
797protected override ValueGetter<Single> GetScoreGetter(DataViewRow row)
799return row.GetGetter<Single>(row.Schema[_bindings.ScoreIndex]);
807protected override void ProcessExample(RowCursorState state, short label, Single score)
831public readonly List<Single> QueryOutputs;
842QueryOutputs = new List<Single>();
997List<short> queryLabels, List<Single> queryOutputs, Double[] groupMaxDcgCur)
1036List<short> queryLabels, List<Single> queryOutputs, Double[] groupDcgCur)
1056private static Comparison<int> GetCompareItems(List<short> queryLabels, List<Single> queryOutputs)
Transforms\NormalizeColumn.cs (9)
986return Sng.MinMaxOneColumnFunctionBuilder.Create(column, host, srcType, cursor.GetGetter<Single>(srcColumn));
993return Sng.MinMaxVecColumnFunctionBuilder.Create(column, host, vectorType, cursor.GetGetter<VBuffer<Single>>(srcColumn));
1025return Sng.MeanVarOneColumnFunctionBuilder.Create(column, host, srcType, cursor.GetGetter<Single>(srcColumn));
1032return Sng.MeanVarVecColumnFunctionBuilder.Create(column, host, vectorType, cursor.GetGetter<VBuffer<Single>>(srcColumn));
1066return Sng.MeanVarOneColumnFunctionBuilder.Create(column, host, srcType, cursor.GetGetter<Single>(srcColumn));
1073return Sng.MeanVarVecColumnFunctionBuilder.Create(column, host, vectorType, cursor.GetGetter<VBuffer<Single>>(srcColumn));
1106return Sng.BinOneColumnFunctionBuilder.Create(column, host, srcType, cursor.GetGetter<Single>(srcColumn));
1113return Sng.BinVecColumnFunctionBuilder.Create(column, host, vectorType, cursor.GetGetter<VBuffer<Single>>(srcColumn));
1217return Sng.RobustScalerOneColumnFunctionBuilder.Create(column, host, srcType, column.CenterData, column.QuantileMin, column.QuantileMax, cursor.GetGetter<Single>(srcColumn));
Transforms\NormalizeColumnSng.cs (314)
23using TFloat = Single;
28int numFeatures, int[] indices, TFloat[] scales, TFloat[] offsets, bool saveText = false)
48ctx.Writer.Write(sizeof(TFloat));
89out int numFeatures, out TFloat[] scales, out TFloat[] offsets,
90out int[] indicesMorph, out TFloat[] scalesSparse, out TFloat[] offsetsSparse)
106Contracts.CheckDecode(cbFloat == sizeof(TFloat));
133TFloat scale = scales[iv];
134Contracts.CheckDecode(!TFloat.IsNaN(scale));
142TFloat offset = offsets[iv];
143Contracts.CheckDecode(!TFloat.IsNaN(offset));
155scalesSparse = ctx.Reader.ReadSingleArray(scaleCount) ?? new TFloat[0];
161scales = Utils.CreateArray<TFloat>(numFeatures, 1);
162offsets = offsetsSparse != null ? new TFloat[numFeatures] : null;
169TFloat scale = scales[iv] = scalesSparse[iiv];
170Contracts.CheckDecode(!TFloat.IsNaN(scale));
178TFloat offset = offsets[iv] = offsetsSparse[iiv];
179Contracts.CheckDecode(!TFloat.IsNaN(offset));
195public static void SaveModel(ModelSaveContext ctx, TFloat[][] binUpperBounds, bool saveText = false)
207ctx.Writer.Write(sizeof(TFloat));
234public static void LoadModel(ModelLoadContext ctx, out TFloat[][] binUpperBounds)
246Contracts.CheckDecode(cbFloat == sizeof(TFloat));
251binUpperBounds = new TFloat[numFeatures][];
254TFloat[] curUpperBounds = ctx.Reader.ReadSingleArray();
259Contracts.CheckDecode(curUpperBounds[curUpperBounds.Length - 1] == TFloat.PositiveInfinity);
266public static void SaveModel(ModelSaveContext ctx, bool useLog, TFloat[] mean, TFloat[] stddev)
274ctx.Writer.Write(sizeof(TFloat));
290public static void LoadModel(ModelLoadContext ctx, int cv, out bool useLog, out TFloat[] mean, out TFloat[] stddev)
300Contracts.CheckDecode(cbFloat == sizeof(TFloat));
318internal sealed class MinMaxSngAggregator : IColumnAggregator<VBuffer<TFloat>>
320private readonly TFloat[] _min;
321private readonly TFloat[] _max;
328_min = new TFloat[size];
329_max = new TFloat[size];
333_min[i] = TFloat.PositiveInfinity;
334_max[i] = TFloat.NegativeInfinity;
338public TFloat[] Min
343public TFloat[] Max
353public void ProcessValue(in VBuffer<TFloat> value)
368var val = values[j];
378var val = values[k];
397private void Update(int j, TFloat val)
466public void ProcessValue(in VBuffer<TFloat> value)
480var origVal = values[j];
489var origVal = values[k];
509private void Update(int j, TFloat origVal)
513var val = _useLog ? (TFloat)Math.Log(origVal) : origVal;
769internal sealed class MedianSngAggregator : IColumnAggregator<TFloat>
778_belowMedianHeap = new MedianAggregatorUtils.MaxHeap<TFloat>(contatinerStartingSize);
779_aboveMedianHeap = new MedianAggregatorUtils.MinHeap<TFloat>(contatinerStartingSize);
783public TFloat Median
788public void ProcessValue(in TFloat value)
803public static IColumnFunction Create(IHost host, TFloat scale, TFloat offset)
808public static IColumnFunction Create(IHost host, TFloat[] scale, TFloat[] offset, int[] indicesNonZeroOffset)
816public sealed class ImplOne : ImplOne<TFloat>
818public ImplOne(IHost host, TFloat scale, TFloat offset)
825host.Check(typeSrc.RawType == typeof(TFloat), "The column type must be Single.");
828TFloat[] scales;
829TFloat[] offsets;
831TFloat[] scalesSparse;
832TFloat[] offsetsSparse;
845private void GetResult(ref TFloat input, ref TFloat value)
867var getSrc = input.GetGetter<TFloat>(input.Schema[icol]);
868ValueGetter<TFloat> del =
869(ref TFloat dst) =>
879public sealed class ImplVec : ImplVec<TFloat>
881public ImplVec(IHost host, TFloat[] scale, TFloat[] offset, int[] indicesNonZeroOffset)
888host.Check(typeSrc.ItemType.RawType == typeof(TFloat), "The column type must be vector of Single.");
892TFloat[] scales;
893TFloat[] offsets;
895TFloat[] scalesSparse;
896TFloat[] offsetsSparse;
934node.AddAttribute("offset", Enumerable.Repeat<TFloat>(0, featureCount));
942var getSrc = input.GetGetter<VBuffer<TFloat>>(input.Schema[icol]);
943var bldr = new BufferBuilder<TFloat>(R4Adder.Instance);
944ValueGetter<VBuffer<TFloat>> del;
947del = (ref VBuffer<TFloat> dst) =>
957del = (ref VBuffer<TFloat> dst) =>
967del = (ref VBuffer<TFloat> dst) =>
980private static void FillValues(in VBuffer<TFloat> input, BufferBuilder<TFloat> bldr, TFloat[] scale)
1010private static void FillValues(in VBuffer<TFloat> input, BufferBuilder<TFloat> bldr, TFloat[] scale,
1011TFloat[] offset)
1055private static void FillValues(in VBuffer<TFloat> input, BufferBuilder<TFloat> bldr, TFloat[] scale,
1056TFloat[] offset, int[] nz)
1131public static IColumnFunction Create(IHost host, TFloat mean, TFloat stddev, bool useLog)
1136public static IColumnFunction Create(IHost host, TFloat[] mean, TFloat[] stddev, bool useLog)
1143public sealed class ImplOne : ImplOne<TFloat>
1145public ImplOne(IHost host, TFloat mean, TFloat stddev, bool useLog)
1152host.Check(typeSrc.RawType == typeof(TFloat), "The column type must be Single.");
1157TFloat[] mean;
1158TFloat[] stddev;
1164private void GetResult(ref TFloat input, ref TFloat value)
1166var val = UseLog ? (TFloat)Math.Log(input) : input;
1187if (Stddev <= TFloat.Epsilon)
1189ValueGetter<TFloat> trivial =
1190(ref TFloat dst) =>
1197var getSrc = input.GetGetter<TFloat>(input.Schema[icol]);
1198ValueGetter<TFloat> del =
1199(ref TFloat dst) =>
1208public sealed class ImplVec : ImplVec<TFloat>
1210public ImplVec(IHost host, TFloat[] mean, TFloat[] stddev, bool useLog)
1217host.Check(typeSrc.ItemType.RawType == typeof(TFloat), "The column type must be vector of Single.");
1224TFloat[] mean;
1225TFloat[] stddev;
1242var getSrc = input.GetGetter<VBuffer<TFloat>>(input.Schema[icol]);
1243var bldr = new BufferBuilder<TFloat>(R4Adder.Instance);
1244ValueGetter<VBuffer<TFloat>> del;
1245del = (ref VBuffer<TFloat> dst) =>
1256private static void FillValues(in VBuffer<TFloat> input, BufferBuilder<TFloat> bldr, TFloat[] mean,
1257TFloat[] stddev, bool useLog)
1275var sigma = stddev[i];
1276if (sigma > TFloat.Epsilon)
1278var val = useLog ? (TFloat)Math.Log(values[i]) : values[i];
1291var sigma = stddev[ivDst];
1292if (sigma > TFloat.Epsilon)
1294var val = useLog ? (TFloat)Math.Log(values[ii]) : values[ii];
1306public static IColumnFunction Create(IHost host, TFloat[] binUpperBounds, bool fixZero)
1311public static IColumnFunction Create(IHost host, TFloat[][] binUpperBounds, bool fixZero)
1320private readonly TFloat[] _binUpperBounds;
1321private readonly TFloat _den;
1322private readonly TFloat _offset;
1324public ImplOne(IHost host, TFloat[] binUpperBounds, bool fixZero)
1336host.Check(typeSrc.RawType == typeof(TFloat), "The column type must be Single.");
1344TFloat[][] binUpperBounds = null;
1372var getSrc = input.GetGetter<TFloat>(input.Schema[icol]);
1373ValueGetter<TFloat> del =
1374(ref TFloat dst) =>
1382private void GetResult(TFloat input, ref TFloat value)
1388=> new NormalizingTransformer.BinNormalizerModelParameters<TFloat>(ImmutableArray.Create(_binUpperBounds), _den, _offset);
1393private readonly TFloat[][] _binUpperBounds;
1394private readonly TFloat[] _den;
1395private readonly TFloat[] _offset;
1397public ImplVec(IHost host, TFloat[][] binUpperBounds, bool fixZero)
1401_den = new TFloat[_binUpperBounds.Length];
1406_offset = new TFloat[_binUpperBounds.Length];
1421host.Check(typeSrc.ItemType.RawType == typeof(TFloat), "The column type must be vector of Single.");
1430TFloat[][] binUpperBounds = null;
1457var getSrc = input.GetGetter<VBuffer<TFloat>>(input.Schema[icol]);
1458var bldr = new BufferBuilder<TFloat>(R4Adder.Instance);
1459ValueGetter<VBuffer<TFloat>> del =
1460(ref VBuffer<TFloat> dst) =>
1469private void GetResult(in VBuffer<TFloat> input, ref VBuffer<TFloat> value, BufferBuilder<TFloat> bldr)
1508TFloat zero = 0;
1539=> new NormalizingTransformer.BinNormalizerModelParameters<ImmutableArray<TFloat>>(
1549public static void ComputeScaleAndOffset(bool fixZero, TFloat max, TFloat min, out TFloat scale, out TFloat offset)
1557private static void ComputeScaleAndOffset(TFloat max, TFloat min, out TFloat scale, out TFloat offset)
1559Contracts.Assert(!TFloat.IsNaN(min));
1560Contracts.Assert(!TFloat.IsNaN(max));
1564Contracts.Assert(min <= max || (TFloat.IsPositiveInfinity(min) && TFloat.IsNegativeInfinity(max)));
1579Contracts.Assert(0 <= scale && scale < TFloat.PositiveInfinity);
1582private static void ComputeScaleAndOffsetFixZero(TFloat max, TFloat min, out TFloat scale, out TFloat offset)
1584Contracts.Assert(!TFloat.IsNaN(min));
1585Contracts.Assert(!TFloat.IsNaN(max));
1589Contracts.Assert(min <= max || (TFloat.IsPositiveInfinity(min) && TFloat.IsNegativeInfinity(max)));
1600Contracts.Assert(0 <= scale && scale < TFloat.PositiveInfinity);
1606public static void ComputeScaleAndOffset(Double mean, Double stddev, out TFloat scale, out TFloat offset)
1616else if ((scale = 1 / (TFloat)stddev) == 0)
1619offset = (TFloat)mean;
1620Contracts.Assert(0 <= scale && scale < TFloat.PositiveInfinity);
1623public static void ComputeScaleAndOffsetFixZero(Double mean, Double meanSquaredError, out TFloat scale, out TFloat offset)
1635scale = 1 / (TFloat)Math.Sqrt(meanSquaredError + mean * mean);
1636Contracts.Assert(0 <= scale && scale < TFloat.PositiveInfinity);
1642public static TFloat Cdf(TFloat input, TFloat mean, TFloat stddev)
1648var x = (input - mean) / stddev;
1649var x2 = x * x / 2;
1650const TFloat a = (TFloat)0.147;
1651var ax2 = a * x2;
1652return (TFloat)(0.5 + 0.5 * Math.Sign(x) * Math.Sqrt(1 - Math.Exp(-x2 * (4 / Math.PI + ax2) / (1 + ax2))));
1658public static TFloat GetValue(TFloat input, TFloat[] binUpperBounds, TFloat den, TFloat offset)
1660if (TFloat.IsNaN(input))
1664var value = binIdx / den - offset;
1669public static TFloat GetValue(TFloat input, TFloat[] binUpperBounds, TFloat den)
1671if (TFloat.IsNaN(input))
1675var value = binIdx / den;
1683public abstract class MinMaxOneColumnFunctionBuilderBase : OneColumnFunctionBuilderBase<TFloat>
1687private VBuffer<TFloat> _buffer;
1689protected MinMaxOneColumnFunctionBuilderBase(IHost host, long lim, bool fix, ValueGetter<TFloat> getSrc)
1694_buffer = new VBuffer<TFloat>(1, new TFloat[1]);
1697protected override bool ProcessValue(in TFloat val)
1709private MinMaxOneColumnFunctionBuilder(IHost host, long lim, bool fix, ValueGetter<TFloat> getSrc)
1715ValueGetter<TFloat> getter)
1724TFloat scale;
1725TFloat offset;
1732public abstract class MinMaxVecColumnFunctionBuilderBase : VecColumnFunctionBuilderBase<TFloat>
1737protected MinMaxVecColumnFunctionBuilderBase(IHost host, int cv, long lim, bool fix, ValueGetter<VBuffer<TFloat>> getSrc)
1744protected override bool ProcessValue(in VBuffer<TFloat> buffer)
1759ValueGetter<VBuffer<TFloat>> getSrc)
1765ValueGetter<VBuffer<TFloat>> getter)
1808public sealed class MeanVarOneColumnFunctionBuilder : OneColumnFunctionBuilderBase<TFloat>
1815private VBuffer<TFloat> _buffer;
1817private MeanVarOneColumnFunctionBuilder(IHost host, long lim, bool fix, ValueGetter<TFloat> getSrc, bool useLog, bool useCdf, bool useSampleVariance)
1825_buffer = new VBuffer<TFloat>(1, new TFloat[1]);
1829ValueGetter<TFloat> getter)
1836ValueGetter<TFloat> getter)
1843protected override bool ProcessValue(in TFloat origVal)
1864return AffineColumnFunction.Create(Host, (TFloat)0, (TFloat)0);
1865TFloat scale;
1866TFloat offset;
1882return CdfColumnFunction.Create(Host, (TFloat)0, (TFloat)0, _useLog);
1886return CdfColumnFunction.Create(Host, (TFloat)_aggregator.Mean[0], (TFloat)stdDev, _useLog);
1890public sealed class MeanVarVecColumnFunctionBuilder : VecColumnFunctionBuilderBase<TFloat>
1899ValueGetter<VBuffer<TFloat>> getSrc, bool useLog, bool useCdf, bool useSampleVariance)
1910ValueGetter<VBuffer<TFloat>> getter)
1918ValueGetter<VBuffer<TFloat>> getter)
1926protected override bool ProcessValue(in VBuffer<TFloat> buffer)
1950var scale = new TFloat[cv];
1951var offset = new TFloat[cv];
1996var mean = new TFloat[cv];
1997var stddev = new TFloat[cv];
2007mean[i] = (TFloat)_aggregator.Mean[i];
2008stddev[i] = (TFloat)(_useSampleVariance ? _aggregator.StdDevSample[i] : _aggregator.StdDevPopulation[i]);
2016public sealed class BinOneColumnFunctionBuilder : OneColumnFunctionBuilderBase<TFloat>
2020private readonly List<TFloat> _values;
2022private BinOneColumnFunctionBuilder(IHost host, long lim, bool fix, int numBins, ValueGetter<TFloat> getSrc)
2027_values = new List<TFloat>();
2031ValueGetter<TFloat> getter)
2041protected override bool ProcessValue(in TFloat val)
2054_values.RemoveAll(TFloat.IsNaN);
2060public sealed class BinVecColumnFunctionBuilder : VecColumnFunctionBuilderBase<TFloat>
2064private readonly List<TFloat>[] _values;
2067ValueGetter<VBuffer<TFloat>> getSrc)
2072_values = new List<TFloat>[cv];
2075_values[i] = new List<TFloat>();
2080ValueGetter<VBuffer<TFloat>> getter)
2091protected override bool ProcessValue(in VBuffer<TFloat> buffer)
2115var val = values[k];
2127var binUpperBounds = new TFloat[count][];
2131_values[i].RemoveAll(TFloat.IsNaN);
2138public sealed class SupervisedBinOneColumnFunctionBuilder : OneColumnSupervisedBinFunctionBuilderBase<TFloat>
2152protected override bool AcceptColumnValue(in TFloat colValue)
2154return !TFloat.IsNaN(colValue);
2176public sealed class SupervisedBinVecColumnFunctionBuilder : VecColumnSupervisedBinFunctionBuilderBase<TFloat>
2190protected override bool AcceptColumnValue(in VBuffer<TFloat> colValuesBuffer)
2198TFloat[][] binUpperBounds = new TFloat[ColumnSlotCount][];
2216public sealed class RobustScalerOneColumnFunctionBuilder : OneColumnFunctionBuilderBase<TFloat>
2223private VBuffer<TFloat> _buffer;
2225private RobustScalerOneColumnFunctionBuilder(IHost host, long lim, bool centerData, uint quantileMin, uint quantileMax, ValueGetter<TFloat> getSrc)
2232_buffer = new VBuffer<TFloat>(1, new TFloat[1]);
2238protected override bool ProcessValue(in TFloat val)
2249bool centerData, uint quantileMin, uint quantileMax, ValueGetter<TFloat> getter)
2260TFloat median = _medianAggregator.Median;
2261TFloat range = _minMaxAggregator.Max[0] - _minMaxAggregator.Min[0];
2263TFloat quantileRange = (_quantileMax - _quantileMin) / 100f;
2264TFloat scale = 1 / (range * quantileRange);
2273public sealed class RobustScalerVecFunctionBuilder : OneColumnFunctionBuilderBase<VBuffer<TFloat>>
2281private RobustScalerVecFunctionBuilder(IHost host, long lim, int vectorSize, bool centerData, uint quantileMin, uint quantileMax, ValueGetter<VBuffer<TFloat>> getSrc)
2299protected override bool ProcessValue(in VBuffer<TFloat> val)
2316bool centerData, uint quantileMin, uint quantileMax, ValueGetter<VBuffer<TFloat>> getter)
2327TFloat[] scale = new TFloat[_medianAggregators.Length];
2328TFloat[] median = new TFloat[_medianAggregators.Length];
2336TFloat range = _minMaxAggregator.Max[i] - _minMaxAggregator.Min[i];
2339TFloat quantileRange = (_quantileMax - _quantileMin) / 100f;
Microsoft.ML.Ensemble (223)
OutputCombiners\BaseStacking.cs (14)
23public Single ValidationDatasetProportion = 0.3f;
32public Single ValidationDatasetProportion { get; }
60env.CheckDecode(cbFloat == sizeof(Single));
83ctx.Writer.Write(sizeof(Single));
97var map = mapper.GetMapper<VBuffer<Single>, TOutput>();
99var feat = default(VBuffer<Single>);
101(ref TOutput dst, TOutput[] src, Single[] weights) =>
109protected abstract void FillFeatureBuffer(TOutput[] src, ref VBuffer<Single> dst);
135var maps = new ValueMapper<VBuffer<Single>, TOutput>[models.Count];
140maps[i] = m.GetMapper<VBuffer<Single>, TOutput>();
152private IDataView CreateDataView(IHostEnvironment env, IChannel ch, RoleMappedData data, ValueMapper<VBuffer<Single>,
169private IDataView CreateDataView<T>(IHostEnvironment env, IChannel ch, RoleMappedData data, ValueMapper<VBuffer<Single>, TOutput>[] maps,
174var features = new VBuffer<Single>[100];
180var vBuffers = new VBuffer<Single>[maps.Length];
Trainer\EnsembleDistributionModelParameters.cs (38)
21using TDistPredictor = IDistPredictorProducing<Single, Single>;
23internal sealed class EnsembleDistributionModelParameters : EnsembleModelParametersBase<Single>,
43private readonly Single[] _averagedWeights;
64FeatureSubsetModel<float>[] models, IOutputCombiner<Single> combiner, Single[] weights = null)
142Host.Check(typeof(TIn) == typeof(VBuffer<Single>));
143Host.Check(typeof(TOut) == typeof(Single));
147var predictions = new Single[_mappers.Length];
148var probabilities = new Single[_mappers.Length];
149var vBuffers = new VBuffer<Single>[_mappers.Length];
150ValueMapper<VBuffer<Single>, Single> del =
151(in VBuffer<Single> src, ref Single dst) =>
178Host.Check(typeof(TIn) == typeof(VBuffer<Single>));
179Host.Check(typeof(TOut) == typeof(Single));
180Host.Check(typeof(TDist) == typeof(Single));
185var predictions = new Single[_mappers.Length];
186var probabilities = new Single[_mappers.Length];
187var vBuffers = new VBuffer<Single>[_mappers.Length];
188ValueMapper<VBuffer<Single>, Single, Single> del =
189(in VBuffer<Single> src, ref Single score, ref Single prob) =>
214private ValueMapper<VBuffer<Single>, Single, Single>[] GetMaps()
218var maps = new ValueMapper<VBuffer<Single>, Single, Single>[_mappers.Length];
220maps[i] = _mappers[i].GetMapper<VBuffer<Single>, Single, Single>();
224private void ComputeAveragedWeights(out Single[] averagedWeights)
241averagedWeights = Models.SelectMany(model => model.Metrics).Where(m => m.Key == metric.Key).Select(m => (Single)m.Value).ToArray();
Microsoft.ML.Fairlearn (10)
Microsoft.ML.FastTree (35)
Microsoft.ML.GenAI.LLaMA (6)
Microsoft.ML.GenAI.Mistral (2)
Microsoft.ML.GenAI.Phi (6)
Microsoft.ML.GenAI.Samples (1)
Microsoft.ML.ImageAnalytics (11)
Microsoft.ML.IntegrationTests (5)
Microsoft.ML.LightGbm (11)
Microsoft.ML.Mkl.Components (15)
Microsoft.ML.OnnxTransformer (5)
Microsoft.ML.OnnxTransformerTest (3)
Microsoft.ML.Parquet (3)
Microsoft.ML.PCA (4)
Microsoft.ML.Recommender (2)
Microsoft.ML.Samples (28)
Dynamic\Trainers\MulticlassClassification\PermutationFeatureImportanceLoadFromDisk.cs (1)
124var value = (float)
Microsoft.ML.Samples.GPU (1)
Microsoft.ML.SamplesUtils (2)
Microsoft.ML.SearchSpace (4)
Microsoft.ML.StandardTrainers (79)
Standard\SdcaBinary.cs (20)
465var l1Threshold = SdcaTrainerOptions.L1Regularization.Value;
495var l2Const = SdcaTrainerOptions.L2Regularization.Value;
583var normSquared = VectorUtils.NormSquared(features);
800var l1Threshold = SdcaTrainerOptions.L1Regularization.Value;
802var lr = SdcaTrainerOptions.BiasLearningRate * SdcaTrainerOptions.L2Regularization.Value;
824var featuresNormSquared = VectorUtils.NormSquared(features);
838var dual = duals[idx];
839var output = WDot(in features, in weights[0], biasReg[0] + biasUnreg[0]);
840var dualUpdate = Loss.DualUpdate(output, label, dual, invariant, numThreads);
844var adjustment = l1ThresholdZero ? lr * biasReg[0] : lr * l1IntermediateBias[0];
855var instanceWeight = GetInstanceWeight(cursor);
856var primalUpdate = dualUpdate * lambdaNInv * instanceWeight;
968var biasTotal = biasReg[0] + biasUnreg[0];
979var instanceWeight = GetInstanceWeight(cursor);
981var output = WDot(in features, in weights[0], biasTotal);
1674/// <seealso cref="Microsoft.ML.StandardTrainersCatalog.SdcaNonCalibrated(Microsoft.ML.BinaryClassificationCatalog.BinaryClassificationTrainers,System.String,System.String,System.String,Microsoft.ML.Trainers.ISupportSdcaClassificationLoss,System.Nullable{System.Single},System.Nullable{System.Single},System.Nullable{System.Int32})"/>
2047var l2Weight = _options.L2Regularization;
2050var positiveInstanceWeight = _options.PositiveInstanceWeight;
2083var instanceWeight = cursor.Weight;
Standard\SdcaMulticlass.cs (13)
188var l1Threshold = SdcaTrainerOptions.L1Regularization.Value;
190var lr = SdcaTrainerOptions.BiasLearningRate * SdcaTrainerOptions.L2Regularization.Value;
226var labelOutput = WDot(in features, in weights[label], biasReg[label] + biasUnreg[label]);
227var instanceWeight = GetInstanceWeight(cursor);
256var dual = duals[dualIndex];
258var dualUpdate = _loss.DualUpdate(output, 1, dual, invariant, numThreads);
262var adjustment = l1ThresholdZero ? lr * biasReg[iClass] : lr * l1IntermediateBias[iClass];
271var primalUpdate = dualUpdate * lambdaNInv * instanceWeight;
320var intermediateBias = l1IntermediateBias[label];
380var instanceWeight = GetInstanceWeight(cursor);
383var labelOutput = WDot(in features, in weights[label], biasReg[label] + biasUnreg[label]);
396var currentClassOutput = WDot(in features, in weights[iClass], biasReg[iClass] + biasUnreg[iClass]);
399var dual = duals[dualIndex++];
Microsoft.ML.Sweeper (7)
Microsoft.ML.Sweeper.Tests (6)
Microsoft.ML.TensorFlow (2)
Microsoft.ML.TestFramework (8)
DataPipe\TestDataPipe.cs (8)
23private static float[] _dataFloat = new float[] { -0.0f, 0, 1, -1, 2, -2, Single.NaN, Single.MinValue,
24Single.MaxValue, Single.Epsilon, Single.NegativeInfinity, Single.PositiveInfinity };
27private static VBuffer<Single> _dataFloatSparse = new VBuffer<Single>(5, 3, new float[] { -0.0f, 0, 1 }, new[] { 0, 3, 4 });
Microsoft.ML.Tests (76)
ExpressionLanguageTests\ExpressionLanguageTests.cs (25)
38using R4 = Single;
376var v = (Single)src;
453FunctionProviderUtils.Fn<R4, R4>(A));
466FunctionProviderUtils.Fn<I4, BL, R4[], R4>(Var));
480FunctionProviderUtils.Fn<R4, R4>(X));
490FunctionProviderUtils.Fn<R4, R4>(Dump),
496FunctionProviderUtils.Fn<TX, R4, R4>(Dump),
526public static R4 A(R4 a)
535public static R4 Var(I4 a, BL b, R4[] c)
538return R4.NaN;
539R4 res = c[a];
580internal static R4 X(R4 a)
651FunctionProviderUtils.Fn<R4, R4>(A));
678public static R4 A(R4 a)
Microsoft.ML.TimeSeries (315)
AdaptiveSingularSpectrumSequenceModeler.cs (110)
51internal sealed class AdaptiveSingularSpectrumSequenceModelerInternal : SequenceModelerBase<Single, Single>
55internal sealed class SsaForecastResult : ForecastResultBase<Single>
57public VBuffer<Single> ForecastStandardDeviation;
58public VBuffer<Single> UpperBound;
59public VBuffer<Single> LowerBound;
60public Single ConfidenceLevel;
63internal Single BoundOffset;
73public Single[] Spectrum;
98public Single[] AutoRegressiveCoefficients;
147private Single[] _alpha;
148private Single[] _state;
149private readonly FixedSizeQueue<Single> _buffer;
155private readonly Single _discountFactor;
165private Single _observationNoiseVariance;
166private Single _observationNoiseMean;
167private Single _autoregressionNoiseVariance;
168private Single _autoregressionNoiseMean;
172private Single _nextPrediction;
187public Single LastSmoothedValue { get { return _state[_windowSize - 2]; } }
192public Single LastValue { get { return _buffer.Count > 0 ? _buffer[_buffer.Count - 1] : Single.NaN; } }
228public AdaptiveSingularSpectrumSequenceModelerInternal(IHostEnvironment env, int trainSize, int seriesLength, int windowSize, Single discountFactor = 1,
268_buffer = new FixedSizeQueue<Single>(seriesLength);
270_alpha = new Single[windowSize - 1];
271_state = new Single[windowSize - 1];
322_alpha = new Single[_windowSize - 1];
324_state = new Single[_windowSize - 1];
396_state = new Single[_windowSize - 1];
419_info.AutoRegressiveCoefficients = new Single[_windowSize - 1];
510var tempArray = new Single[_rank * _windowSize];
523private static void ReconstructSignal(TrajectoryMatrix tMat, Single[] singularVectors, int rank, Single[] output)
533var v = new Single[k];
547private static void ReconstructSignalTailFast(Single[] series, TrajectoryMatrix tMat, Single[] singularVectors, int rank, Single[] output)
556Single v;
561Single temp;
594private static void ComputeNoiseMoments(Single[] series, Single[] signal, Single[] alpha, out Single observationNoiseVariance, out Single autoregressionNoiseVariance,
595out Single observationNoiseMean, out Single autoregressionNoiseMean, int startIndex = 0)
606var y = new Single[k];
642private static int DetermineSignalRank(Single[] series, TrajectoryMatrix tMat, Single[] singularVectors, Single[] singularValues,
643Single[] outputSignal, int maxRank)
656var x = new Single[inputSeriesLength];
657var y = new Single[k];
658var alpha = new Single[tMat.WindowSize - 1];
659var v = new Single[k];
661Single nu = 0;
671Single temp;
674Single lambda;
675Single observationNoiseMean;
677FixedSizeQueue<Single> window = new FixedSizeQueue<float>(tMat.WindowSize - 1);
738private static int DetermineSignalRankFast(Single[] series, TrajectoryMatrix tMat, Single[] singularVectors, Single[] singularValues, int maxRank)
750var x = new Single[tMat.WindowSize - 1];
751var alpha = new Single[tMat.WindowSize - 1];
752Single v;
754Single nu = 0;
763Single temp;
765Single lambda;
766Single observationNoiseMean;
768FixedSizeQueue<Single> window = new FixedSizeQueue<float>(tMat.WindowSize - 1);
1084_alpha[i] = (Single)(-coeff[i]);
1103internal override void Consume(ref Single input, bool updateModel = false)
1105if (Single.IsNaN(input))
1114Single[] vecs = new Single[_rank * _windowSize];
1166internal override void Train(FixedSizeQueue<Single> data)
1171Single[] dataArray = new Single[_trainSize];
1176if (!Single.IsNaN(data[i]))
1215Single[] dataArray = new Single[_trainSize];
1220var getVal = cursor.GetGetter<Single>(featureCol);
1221Single val = default;
1225if (!Single.IsNaN(val))
1251private void TrainCore(Single[] dataArray, int originalSeriesLength)
1254Single[] singularVals;
1255Single[] leftSingularVecs;
1259var signal = new Single[signalLength];
1272if (Single.IsNaN(leftSingularVecs[i]))
1285var v = leftSingularVecs[(i + 1) * _windowSize - 1];
1292_alpha = new Single[_windowSize - 1];
1293_state = new Single[_windowSize - 1];
1318var temp = (Single)(1f / Math.Sqrt(_windowSize));
1340Single nu = 0;
1405_info.AutoRegressiveCoefficients = new Single[_windowSize - 1];
1418internal override void Forecast(ref ForecastResultBase<Single> result, int horizon = 1)
1452var lastCol = new FixedSizeQueue<Single>(_windowSize - 1);
1462Single temp = 0;
1485internal override void PredictNext(ref Single output)
1490internal override SequenceModelerBase<Single, Single> Clone()
1500internal static void ComputeForecastIntervals(ref SsaForecastResult forecast, Single confidenceLevel = 0.95f)
1524upper.Values[i] = (Single)(meanForecast[i] + forecast.BoundOffset + temp);
1525lower.Values[i] = (Single)(meanForecast[i] + forecast.BoundOffset - temp);
1564var getVal = cursor.GetGetter<Single>(col);
1565Single val = default(Single);
1569if (!Single.IsNaN(val))
MovingAverageTransform.cs (45)
25internal sealed class MovingAverageTransform : SequentialTransformBase<Single, Single, MovingAverageTransform.State>
66private readonly Single[] _weights;
115private static Single ComputeMovingAverageUniformInitialisation(FixedSizeQueue<Single> others, Single input, int lag,
116Single lastDropped, ref Single currentSum,
119Single sumValues = 0;
124if (Single.IsNaN(input))
135if (Single.IsNaN(others[i]))
142return nb == 0 ? Single.NaN : sumValues / nb;
145internal static Single ComputeMovingAverageNonUniform(FixedSizeQueue<Single> others, Single input, Single[] weights, int lag)
147Single sumWeights = 0;
148Single sumValues = 0;
152if (!Single.IsNaN(input))
164if (!Single.IsNaN(others[i]))
170return sumWeights != 0 ? sumValues / sumWeights : Single.NaN;
180internal static Single ComputeMovingAverageUniform(FixedSizeQueue<Single> others, Single input, int lag,
181Single lastDropped, ref Single currentSum,
193if (Single.IsNaN(lastDropped))
204Contracts.Assert(FloatUtils.IsFinite(lastDropped) || Single.IsNaN(lastDropped));
207if (!Single.IsNaN(newValue) && !FloatUtils.IsFinite(newValue))
214Contracts.Assert(FloatUtils.IsFinite(newValue) || Single.IsNaN(newValue));
216if (!Single.IsNaN(currentSum) && !FloatUtils.IsFinite(currentSum))
218if (Single.IsNaN(newValue))
228Contracts.Assert(FloatUtils.IsFinite(currentSum) || Single.IsNaN(currentSum));
230if (Single.IsNaN(newValue))
234return nb == 0 ? Single.NaN : currentSum / nb;
240return nb == 0 ? Single.NaN : currentSum / nb;
247private Single[] _weights;
253private Single _lastDroppedValue;
254private Single _currentSum;
264private protected override void SetNaOutput(ref Single output)
266output = Single.NaN;
276private protected override void TransformCore(ref Single input, FixedSizeQueue<Single> windowedBuffer, long iteration, ref Single output)
292private protected override void LearnStateFromDataCore(FixedSizeQueue<Single> data)
SSaForecasting.cs (2)
231/// <seealso cref="Microsoft.ML.TimeSeriesCatalog.ForecastBySsa(Microsoft.ML.ForecastingCatalog,System.String,System.String,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean,System.Single,Microsoft.ML.Transforms.TimeSeries.RankSelectionMethod,System.Int32?,System.Int32?,System.Boolean,System.Boolean,Microsoft.ML.Transforms.TimeSeries.GrowthRatio?,System.String,System.String,System.Single,System.Boolean)" />
TrajectoryMatrix.cs (44)
36private Single[] _data;
113public TrajectoryMatrix(IExceptionContext ectx, Single[] data, int windowSize, int seriesLength)
135public void SetSeries(Single[] data)
154private static Single RoundUpToReal(Double re, Double im, Double coeff = 1)
156return (Single)(coeff * Math.Sign(re) * Math.Sqrt(re * re + im * im));
190public void ComputeUnnormalizedTrajectoryCovarianceMat(Single[] cov)
198var temp = new Single[_k];
223public bool ComputeSvd(out Single[] singularValues, out Single[] leftSingularvectors)
225Single[] covariance = new Single[_windowSize * _windowSize];
226Single[] sVal;
227Single[] sVec;
228singularValues = new Single[_windowSize];
229leftSingularvectors = new Single[_windowSize * _windowSize];
262private void NaiveMultiply(Single[] vector, Single[] result, bool add = false, int srcIndex = 0, int dstIndex = 0)
292private void FftMultiply(Single[] vector, Single[] result, bool add = false, int srcIndex = 0, int dstIndex = 0)
350public void Multiply(Single[] vector, Single[] result, bool add = false, int srcIndex = 0, int dstIndex = 0)
366private void NaiveMultiplyTranspose(Single[] vector, Single[] result, bool add = false, int srcIndex = 0, int dstIndex = 0)
396private void FftMultiplyTranspose(Single[] vector, Single[] result, bool add = false, int srcIndex = 0, int dstIndex = 0)
454public void MultiplyTranspose(Single[] vector, Single[] result, bool add = false, int srcIndex = 0, int dstIndex = 0)
475private void NaiveRankOneHankelization(Single[] u, Single[] v, Single sigma, Single[] result, bool add = false,
504_ectx.Assert(!Single.IsNaN(sigma));
505_ectx.Assert(!Single.IsInfinity(sigma));
512Single temp;
547private void FftRankOneHankelization(Single[] u, Single[] v, Single sigma, Single[] result, bool add = false,
575_ectx.Assert(!Single.IsNaN(sigma));
576_ectx.Assert(!Single.IsInfinity(sigma));
658public void RankOneHankelization(Single[] u, Single[] v, Single sigma, Single[] result, bool add = false,
Microsoft.ML.TorchSharp (8)
Microsoft.ML.Transforms (356)
Microsoft.ML.Vision (1)
mscorlib (1)
netstandard (1)
PresentationBuildTasks (2)
PresentationCore (111)
System\Windows\Media\Animation\Generated\SingleAnimation.cs (32)
32private Single[] _keyValues;
47Type typeofProp = typeof(Single?);
56new PropertyMetadata((Single?)null, propCallback),
63new PropertyMetadata((Single?)null, propCallback),
70new PropertyMetadata((Single?)null, propCallback),
94public SingleAnimation(Single toValue, Duration duration)
106public SingleAnimation(Single toValue, Duration duration, FillBehavior fillBehavior)
119public SingleAnimation(Single fromValue, Single toValue, Duration duration)
132public SingleAnimation(Single fromValue, Single toValue, Duration duration, FillBehavior fillBehavior)
205protected override Single GetCurrentValueCore(Single defaultOriginValue, Single defaultDestinationValue, AnimationClock animationClock)
222Single from = new Single();
223Single to = new Single();
224Single accumulated = new Single();
225Single foundation = new Single();
339Single accumulator = AnimatedTypeHelpers.SubtractSingle(to, from);
364_keyValues = new Single[2];
371_keyValues = new Single[2];
378_keyValues = new Single[1];
385_keyValues = new Single[1];
391_keyValues = new Single[1];
412Single? typedValue = (Single?)value;
432public Single? From
436return (Single?)GetValue(FromProperty);
452public Single? To
456return (Single?)GetValue(ToProperty);
472public Single? By
476return (Single?)GetValue(ByProperty);
PresentationFramework (5)
System.Linq.Expressions (3)
System.Private.CoreLib (3)
System.Private.DataContractSerialization (3)
System.Runtime (1)