AccuracyTests

pull/1/head
unknown 3 years ago
parent 2ad948688c
commit e951c9c500

@ -95,9 +95,10 @@ namespace HNSWDemo
return vectors; return vectors;
} }
static void Main(string[] args) static void Main(string[] args)
{ {
FilterTest(); AccuracityTest();
Console.ReadKey(); Console.ReadKey();
} }
@ -390,7 +391,7 @@ namespace HNSWDemo
var miss = 0; var miss = 0;
foreach (var v in vectors) foreach (var v in vectors)
{ {
var numbers = map.ConvertIdsToFeatures( world.Search(v, K, context).Select(r=>r.Item1)); var numbers = map.ConvertIdsToFeatures(world.Search(v, K, context).Select(r => r.Item1));
foreach (var r in numbers) foreach (var r in numbers)
{ {
var record = testDict[r]; var record = testDict[r];
@ -422,7 +423,7 @@ namespace HNSWDemo
var sw = new Stopwatch(); var sw = new Stopwatch();
var test = new VectorsDirectCompare(samples, CosineDistance.ForUnits); var test = new VectorsDirectCompare(samples, CosineDistance.ForUnits);
var world = new SmallWorld<float[]>(NSWOptions<float[]>.Create(6, 15, 200, 200, CosineDistance.ForUnits, true, true, selectionHeuristic: NeighbourSelectionHeuristic.SelectSimple)); var world = new SmallWorld<float[]>(NSWOptions<float[]>.Create(32, 15, 200, 200, CosineDistance.ForUnits, true, true, selectionHeuristic: NeighbourSelectionHeuristic.SelectSimple));
sw.Start(); sw.Start();
var ids = world.AddItems(samples.ToArray()); var ids = world.AddItems(samples.ToArray());

@ -1,12 +1,16 @@
namespace ZeroLevel.HNSW.Services using System;
namespace ZeroLevel.HNSW.Services
{ {
internal sealed class ProbabilityLayerNumberGenerator internal sealed class ProbabilityLayerNumberGenerator
{ {
private const float DIVIDER = 3.361f; private const float DIVIDER = 3.361f;
private readonly float[] _probabilities; private readonly float[] _probabilities;
private float _mL;
internal ProbabilityLayerNumberGenerator(int maxLayers, int M) internal ProbabilityLayerNumberGenerator(int maxLayers, int M)
{ {
_mL = maxLayers;
_probabilities = new float[maxLayers]; _probabilities = new float[maxLayers];
var probability = 1.0f / DIVIDER; var probability = 1.0f / DIVIDER;
for (int i = 0; i < maxLayers; i++) for (int i = 0; i < maxLayers; i++)

Loading…
Cancel
Save

Powered by TurnKey Linux.