-
Notifications
You must be signed in to change notification settings - Fork 627
/
NearestNeighbors.proto
132 lines (105 loc) · 2.98 KB
/
NearestNeighbors.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Copyright (c) 2017, Apple Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-3-clause license that can be
// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
package CoreML.Specification;
import public "DataStructures.proto";
import public "Parameters.proto";
/*
* A k-Nearest-Neighbor classifier
*/
message KNearestNeighborsClassifier {
/*
* The "core" nearest neighbor model attributes.
*/
NearestNeighborsIndex nearestNeighborsIndex = 1;
/*
* Number of neighbors to use for classification.
*/
Int64Parameter numberOfNeighbors = 3;
/*
* Type of labels supported by the model. Currently supports String or Int64
* labels.
*/
oneof ClassLabels {
StringVector stringClassLabels = 100;
Int64Vector int64ClassLabels = 101;
}
/*
* Default value of class label (useful when prediction is called on an empty kNN classifier)
*/
oneof DefaultClassLabel {
string defaultStringLabel = 110;
int64 defaultInt64Label = 111;
}
/*
* Weighting scheme to be used when computing the majority label of a
* new data point.
*/
oneof WeightingScheme {
UniformWeighting uniformWeighting = 200;
InverseDistanceWeighting inverseDistanceWeighting = 210;
}
}
/*
* The "core" attributes of a Nearest Neighbors model.
*/
message NearestNeighborsIndex {
/*
* Number of dimensions of the input data.
*/
int32 numberOfDimensions = 1;
/*
* Vector of floating point data that makes up the model. Each data point must have 'numberOfDimensions'
* dimensions.
*/
repeated FloatVector floatSamples = 2;
/*
* Backing data structure for the Nearest Neighbors Index. Currently supports
* a linear index or a kd-tree index.
*/
oneof IndexType {
LinearIndex linearIndex = 100;
SingleKdTreeIndex singleKdTreeIndex = 110;
}
/*
* Distance function to be used to find neighbors. Currently only Squared Euclidean
* Distance is supported.
*/
oneof DistanceFunction {
SquaredEuclideanDistance squaredEuclideanDistance = 200;
}
}
/*
* Specifies a uniform weighting scheme (i.e. each neighbor receives equal
* voting power).
*/
message UniformWeighting {
}
/*
* Specifies a inverse-distance weighting scheme (i.e. closest neighbors receives higher
* voting power). A nearest neighbor with highest sum of (1 / distance) is picked.
*/
message InverseDistanceWeighting {
}
/*
* Specifies a flat index of data points to be searched by brute force.
*/
message LinearIndex {
}
/*
* Specifies a kd-tree backend for the nearest neighbors model.
*/
message SingleKdTreeIndex {
/*
* Number of data points contained within a leaf node of the kd-tree.
*/
int32 leafSize = 1;
}
/*
* Specifies the Squared Euclidean Distance function.
*/
message SquaredEuclideanDistance {
}