def calculateMedianDifference(data): """ Trying to normalize the forces in input data. Calculating the difference to median Input should be data from one session from one person. Not an array with data from many persons Arguments: data {array} -- data dataframe """ cols = DataColumns.getAllForceCols() for col in cols: col_median = data.loc[:, col].median(axis=1, skipna=True) for row in range(0, len(data)): data.loc[row, col] = (data.loc[row, col] - col_median) return (data)
def minmaxStandardizeForces(data): """ Normalizing forces from data. Very sensitive to outliers though. Arguments: data {array} -- data dataframe """ fCols = DataColumns.getAllForceCols() force_data = data.loc[:, fCols] other_data = data.drop(fCols, axis=1) minmax = MinMaxScaler() minmax.fit(force_data) force_normalized = pd.DataFrame(minmax.transform(force_data), columns=fCols) other_data[fCols] = force_normalized.loc[:, fCols] print("result ", other_data) return (other_data)
def quantilesGaussianStandardizeForcesTest(data): """ Needs proper testing Arguments: data {array} -- data dataframe """ fCols = DataColumns.getAllForceCols() force_data = data.loc[:, fCols] other_data = data.drop(fCols, axis=1) quantile = QuantileTransformer(n_quantiles=10, random_state=0, output_distribution="normal") quantile.fit_transform(force_data) force_normalized = quantile.transform(force_data) result = pd.concat([other_data, force_normalized], axis=0, ignore_index=True) return (result)