[+] Add stddev to scientific utils
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Natual language processing utils
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def camel_split(camel: str) -> list[str]:
|
||||
|
||||
@@ -3,9 +3,7 @@ Importing this file requires numpy, matplotlib, and numba
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable
|
||||
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
@@ -23,13 +21,21 @@ class Statistics:
|
||||
maximum: float
|
||||
count: int
|
||||
total: float
|
||||
stddev: float
|
||||
|
||||
def get_metric_6(self) -> tuple[float, float, float, float, float, float]:
|
||||
return self.mean, self.median, self.minimum, self.maximum, self.lower_quartile, self.upper_quartile
|
||||
|
||||
def print(self, dec: int = 2):
|
||||
print(f'> Mean: {round(self.mean, dec)}, Median: {round(self.median, dec)}')
|
||||
print(f'> Min: {round(self.minimum, dec)}, Max: {round(self.maximum, dec)}')
|
||||
print(f'> Q1: {round(self.lower_quartile, dec)}, Q3: {round(self.upper_quartile, dec)}')
|
||||
print(f'> StdDev: {round(self.stddev, dec)}, IQR: {round(self.iqr, dec)}')
|
||||
print(f'> N: {self.count}')
|
||||
|
||||
|
||||
@njit(cache=True)
|
||||
def _calc_col_stats_helper(col: np.ndarray) -> tuple[float, float, float, float, float, float, float, int, float]:
|
||||
def _calc_col_stats_helper(col: np.ndarray) -> tuple[float, float, float, float, float, float, float, int, float, float]:
|
||||
q1 = np.quantile(col, 0.25)
|
||||
q3 = np.quantile(col, 0.75)
|
||||
return (
|
||||
@@ -41,7 +47,8 @@ def _calc_col_stats_helper(col: np.ndarray) -> tuple[float, float, float, float,
|
||||
float(np.min(col)),
|
||||
float(np.max(col)),
|
||||
len(col),
|
||||
float(np.sum(col))
|
||||
float(np.sum(col)),
|
||||
float(np.std(col))
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user