Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-096

Feature-Based Classification

Problem

Classify a series by nearest centroid in [mean, standard deviation, OLS slope] feature space. Compute the feature vector of value and of each training series, then return 0 if it is at least as close to train0 as to train1, otherwise 1.

Distances are squared Euclidean between the three-element feature vectors.

Hint

A tie in distance goes to class 0.

Test cases

case 1
in: [[1,1,1],[1,2,4],[1,1,1]]
expected: 0
case 2
in: [[1,1,1],[1,2,4],[1.1,2.1,4.1]]
expected: 1
case 3
in: [[0,0,0,0],[10,10,10,10],[3,3,3,3]]
expected: 0
case 4
in: [[0,0,0,0],[10,10,10,10],[6,6,6,6]]
expected: 1
Starter codePython
def classify_by_features(train0, train1, value):
    # Your code here
    pass

4 test cases · run your code against them in the editor