diff --git a/tools/movement_treatment.py b/examples/movement_treatment.py similarity index 96% rename from tools/movement_treatment.py rename to examples/movement_treatment.py index aed748f1a05713f9ab8fbe4c492df1e2974be438..f80e18ee148fe2805a4fce4971d47acbe1b820db 100644 --- a/tools/movement_treatment.py +++ b/examples/movement_treatment.py @@ -45,6 +45,7 @@ def explained_variance_ratio(obj, p: int): plt.ylabel("Variance explained in ratio and cumulation") plt.xlabel("Number of factors") + plt.title('Explained variance ratio by the components and cumulation') plt.show() def corelations_circle(Xraw:pd.DataFrame, Xtransform:np.ndarray, p:int) -> pd.DataFrame: @@ -83,7 +84,7 @@ def corelations_circle(Xraw:pd.DataFrame, Xtransform:np.ndarray, p:int) -> pd.Da plt.xlabel('Component 1') plt.ylabel('Component 2') - + plt.title('Circle of the corelations between initial variables and components') plt.show() return pd.DataFrame({'id': Xraw.columns, 'COR_1': corvar[:, 0], 'COR_2': corvar[:, 1]}) @@ -106,11 +107,12 @@ def scatter_points(Xtransform:np.ndarray, Group_vect : pd.Series, Add_points : n plt.xlabel('Component 1') plt.ylabel('Component 2') + plt.title('Scatter plot of the transformed points') plt.show() return fig # %% LDA per motors____________________________________________ -for Motor in range(1,7,1): +for Motor in range(1,2,1): lda = LinearDiscriminantAnalysis() Movements_Data_Motor = Movements_Data_File.loc[Movements_Data_File['Motor'] == Motor].copy() @@ -128,7 +130,7 @@ for Motor in range(1,7,1): explained_variance_ratio(lda, p) coef = corelations_circle(Movements_Data_Motor, Xlda, Movements_Data_Motor.shape[1]) scatter_points(Xlda, Group_Data, New_points) - # print(coef) + print(coef) # %% ACP per motors (less revelating than LDA but still interesting) ____________________________________________ for Motor in range(1,7,1): diff --git a/examples/variable_by.py b/examples/variable_by.py index 28f06f31b7bb7f9d322424e20d93e734655aa7aa..34a9a7c6669be695cc8d73d47b502673e4289829 100644 --- a/examples/variable_by.py +++ b/examples/variable_by.py @@ -6,6 +6,9 @@ import seaborn as sns import scipy.signal as scs from pathlib import Path +import sys +sys.path.append("../") +# Must be ath te same level of main.py to work with regular execution from tools.database import Database from tools.utils import from_class_to_text from tools.plots import plot_all_axis, plot_grouped_load, plot_moving_axes diff --git a/tools/movement_extractor.py b/tools/movement_extractor.py index 8037edd07a14d87e131154e95914b399704c9dcb..c22f5ba08679a02b60a7a61372836c38e05beaed 100644 --- a/tools/movement_extractor.py +++ b/tools/movement_extractor.py @@ -8,9 +8,8 @@ import seaborn as sns import matplotlib.pyplot as plt import scipy.signal as scs -from tools.database import Database -from tools.plots import Spectrogram_plot -from tools.processing import RMS, FFT +from .database import Database +from .processing import RMS DB = Database(f"D:\VSB\Programs\DB\Robot2-LoadTest.sqlite") @@ -245,12 +244,10 @@ class Movement_Extractor: plt.show() return DataMovementFile - -# Example of uses : if __name__ == "__main__": # %% Extract movement from exel file and store it in Data_Movements.xlsx - Extractor = Movement_Extractor(fr"D:\VSB\Programs\data-collection\data\[2024-06-18] 10h53 data [30%-80%] [4ms] [class 4] [10 10 10 10 10 10] - Robot 2_TRACE.xlsx") + Extractor = Movement_Extractor(fr"D:\VSB\Programs\data-collection\data\[2024-06-18] 10h53 data [30%-80%] [4ms] [class 0] [10 10 10 10 10 10] - Robot 2_TRACE.xlsx") Total_Data = Extractor.movements_from_file(plot = 'current') # plots the extracted current Total_Data.to_excel("Data_Movements.xlsx")