Merge pull request #18 from nuluh/feature/15-normalize-dataset-by-preprocess-relatives-value-between-two-acceloremeter-sensors

Feature/15 normalize dataset by preprocess relatives value between two acceloremeter sensors
This commit was merged in pull request #18.
This commit is contained in:
Panuluh
2024-09-03 08:43:44 +07:00
committed by GitHub
3 changed files with 522 additions and 1065 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
# Ignore CSV files in the data directory and all its subdirectories # Ignore CSV files in the data directory and all its subdirectories
data/**/*.csv data/**/*.csv
.venv/
*.pyc *.pyc

File diff suppressed because one or more lines are too long

View File

@@ -16,8 +16,10 @@ os.makedirs(processed_path, exist_ok=True)
# Define the number of zeros to pad # Define the number of zeros to pad
num_damages = 5 num_damages = 5
num_tests = 10 num_tests = 10
num_sensors = 2
damage_pad = len(str(num_damages)) damage_pad = len(str(num_damages))
test_pad = len(str(num_tests)) test_pad = len(str(num_tests))
sensor_pad = len(str(num_sensors))
for damage in range(1, num_damages + 1): # 5 Damage levels starts from 1 for damage in range(1, num_damages + 1): # 5 Damage levels starts from 1
damage_folder = f"DAMAGE_{damage:0{damage_pad}}" damage_folder = f"DAMAGE_{damage:0{damage_pad}}"
@@ -25,23 +27,24 @@ for damage in range(1, num_damages + 1): # 5 Damage levels starts from 1
os.makedirs(damage_path, exist_ok=True) os.makedirs(damage_path, exist_ok=True)
for test in range(1, 11): # 10 Tests per damage level for test in range(1, 11): # 10 Tests per damage level
# Filename for the CSV for sensor in range(1, 3): # 2 Sensors per test
csv_filename = f"D{damage:0{damage_pad}}_TEST{test:0{test_pad}}.csv" # Filename for the CSV
csv_path = os.path.join(damage_path, csv_filename) csv_filename = f"D{damage:0{damage_pad}}_TEST{test:0{test_pad}}_{sensor:0{sensor_pad}}.csv"
csv_path = os.path.join(damage_path, csv_filename)
# Generate dummy data
num_rows = 10
start_time = datetime.now()
timestamps = [start_time + timedelta(seconds=i*0.0078125) for i in range(num_rows)]
values = np.random.randn(num_rows) # Random float values
# Generate dummy data # Create DataFrame
num_rows = 10 df = pd.DataFrame({
start_time = datetime.now() "Time": timestamps,
timestamps = [start_time + timedelta(seconds=i*0.0078125) for i in range(num_rows)] "Value": values
values = np.random.randn(num_rows) # Random float values })
# Create DataFrame # Save the CSV file with a custom header
df = pd.DataFrame({ with open(csv_path, 'w') as file:
"Time": timestamps, file.write('sep=,\n') # Writing the separator hint
"Value": values df.to_csv(file, index=False)
})
# Save the CSV file with a custom header
with open(csv_path, 'w') as file:
file.write('sep=,\n') # Writing the separator hint
df.to_csv(file, index=False)