1. A nearest-neighbor-based distance metric learning process implemented by a computer, comprising: applying an exponential-based loss function to provide a smooth objective; and determining an objective and a gradient of both hinge-based and exponential-based loss function in a quadratic time of the number of instances using a computer; wherein the loss function and its gradient comprises: l = E x , y ∼ x ⁢ 1 N x - [ ( 1 + d 2 ⁡ ( y , x ) ) ⁢  Z x , y  - ∑ z ∈ Z x , y ⁢ ⁢ d 2 ⁡ ( z , x ) ] l. = E x , y ∼ x ⁢ 1 N x - ⁢ ∑ z ∈ Z x , y ⁢ { ( y - x ) ⁢ ( y - x ) - ( z - x ) ⁢ ( z - x ) } = ∑ x , v ⁢ ⁢ w x , v ⁡ ( v - x ) ⁢ ( v - x ) = X ⁡ ( S - W - W ) ⁢ X where d is distance, x and y are data points, z is sampled from a class which x does not belong to, Z x,y is the set of data not belonging to the class of x and satifying 1+d 2 (y,x)≧d 2 (z,x), w x,v is  Z x , v  NN x + ⁢ N x - if v in the same class of x, w x,v is -  Y x , v  NN x + ⁢ N x - if v is not in the same class as x, X is an p×N matrix whose j-th column is the feature vector of x j , W is an N×N matrix whose i,j-th element is w x i ,x j , S is an N×N diagonal matrix whose i-th diagonal element is Σ j (w ij +w ji ), NN x+ is the size of class of x, N x− is the size of data not in the class of x, and E is the expection over values x,y ˜x .