@distances = []

def classify_with_knn(data, k, unknown_data_point)
    data.each do |data|
        a = data
        b = unknown_data_point
        label2 = a[:label]
        value = distance(a, b)
        temp = {label: label2, distance: value}
        @distances.push(temp)
    end

    sorted = @distances.sort_by{ |x| x[:distance]}

    dog = 0
    cat = 0
    i = 0

    while i < k do
        temp2 = sorted[i]
        if temp2[:label] == 'cat'
            cat += 1
        else
            dog += 1
        end
        i += 1
    end

    result = []
    if cat > dog
        result.push('cat', cat)
        return result
    else
        result.push('dog', dog)
        return result
    end

end

def distance (a, b)
    temp = a[:features]
    temp2 = b[:features]
    output = 0
    i = 0

    temp.each do |v1|
        v2 = temp2[i]
        output += (v1 - v2)**2
        i += 1
    end

    return output
end