File: NearestNeighbors.proto

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (120 lines) | stat: -rw-r--r-- 2,914 bytes parent folder | download | duplicates (9)
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
// 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 {}