- Timestamp:
- 08/05/16 11:58:52 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/NearestNeighbour/NearestNeighbourModel.cs
r14235 r14236 200 200 x[column] = inputData[row, column]; 201 201 } 202 int actNeighbours = alglib.nearestneighbor.kdtreequeryknn(kdTree, x, k, false); 203 alglib.nearestneighbor.kdtreequeryresultsdistances(kdTree, ref dists); 204 alglib.nearestneighbor.kdtreequeryresultsxy(kdTree, ref neighbours); // gkronber: this call changes the kdTree data structure 202 int numNeighbours; 203 lock (kdTree) { // gkronber: the following calls change the kdTree data structure 204 numNeighbours = alglib.nearestneighbor.kdtreequeryknn(kdTree, x, k, false); 205 alglib.nearestneighbor.kdtreequeryresultsdistances(kdTree, ref dists); 206 alglib.nearestneighbor.kdtreequeryresultsxy(kdTree, ref neighbours); 207 } 205 208 206 209 double distanceWeightedValue = 0.0; 207 210 double distsSum = 0.0; 208 for (int i = 0; i < actNeighbours; i++) {211 for (int i = 0; i < numNeighbours; i++) { 209 212 distanceWeightedValue += neighbours[i, columns] / dists[i]; 210 213 distsSum += 1.0 / dists[i]; … … 233 236 x[column] = inputData[row, column]; 234 237 } 235 int actNeighbours = alglib.nearestneighbor.kdtreequeryknn(kdTree, x, k, false); 236 alglib.nearestneighbor.kdtreequeryresultsdistances(kdTree, ref dists); 237 alglib.nearestneighbor.kdtreequeryresultsxy(kdTree, ref neighbours); 238 238 int numNeighbours; 239 lock (kdTree) { 240 // gkronber: the following calls change the kdTree data structure 241 numNeighbours = alglib.nearestneighbor.kdtreequeryknn(kdTree, x, k, false); 242 alglib.nearestneighbor.kdtreequeryresultsdistances(kdTree, ref dists); 243 alglib.nearestneighbor.kdtreequeryresultsxy(kdTree, ref neighbours); 244 } 239 245 Array.Clear(y, 0, y.Length); 240 for (int i = 0; i < actNeighbours; i++) {246 for (int i = 0; i < numNeighbours; i++) { 241 247 int classValue = (int)Math.Round(neighbours[i, columns]); 242 248 y[classValue]++;
Note: See TracChangeset
for help on using the changeset viewer.