fynance.features.metrics.accuracy¶
-
fynance.features.metrics.
accuracy
(y_true, y_pred, sign=True, axis=0)¶ Compute the accuracy of prediction.
Parameters: - y_true : np.ndarray[ndim=1 or 2, dtype]
Vector of true series.
- y_pred : np.ndarray[ndim=1 or 2, dtype]
Vector of predicted series.
- sign : bool, optional
- If True then check sign accuracy (default).
- Else check exact accuracy.
- axis : {0, 1}, optional
Axis along wich the computation is done. Default is 0.
Returns: - float or np.ndarray[ndim=1, float]
Accuracy of prediction as float between 0 and 1.
Notes
\[accuracy = \frac{right}{right + wrong}\]Examples
>>> y_true = np.array([1., .5, -.5, .8, -.2]) >>> y_pred = np.array([.5, .2, -.5, .1, .0]) >>> accuracy(y_true, y_pred) 0.8 >>> accuracy(y_true, y_pred, sign=False) 0.2