public static int CastStructToInterfaceAndWriteInBoxed(Coord2 arg) { INormalize tmp = arg; var y = (int)tmp.Norm(); return(arg.X + y); // arg.X should not change }
public (double Probability, double Normalization, VectorData Vector) GetVector(TextVectorCell[] cells) { if (cells is null) { throw new ArgumentNullException(nameof(cells)); } log.LogDebug("GetVector"); var vectorCells = new List <VectorCell>(); var vector = new double[featureTable.Count]; for (var i = 0; i < featureTable.Count; i++) { vector[i] = 0; } var unknownIndexes = vector.Length; foreach (TextVectorCell textCell in cells) { VectorCell cell = GetCell(textCell); if (cell != null) { vector[cell.Index] = cell.X; vectorCells.Add(cell); } else { // if inverted exist in database, it is very likely that normal version has opposite meaning cell = GetCell(new TextVectorCell(textCell.Name.GetOpposite(), Math.Abs(textCell.Value))); if (cell != null) { var theata = textCell.Name.IsInverted() ? cell.Theta / 2 : cell.Theta / 4; cell = new VectorCell(unknownIndexes, textCell, -theata); vectorCells.Add(cell); unknownIndexes++; } } } INormalize normalized = vector.Normalize(NormalizationType.L2); vector = normalized.GetNormalized.ToArray(); var probability = Classifier.Probability(vector); // do not normalize data - SVM operates with normalized already. Second time normalization is not required. return(probability, normalized.Coeficient, new VectorData(vectorCells.ToArray(), unknownIndexes, Classifier.Model.Threshold, NormalizationType.None)); }
public static double CastStructToInterface(Coord arg) { INormalize tmp = arg; return(tmp.Norm()); }