ium_464937/script1.sh

23 lines
1.0 KiB
Bash
Raw Normal View History

2024-03-26 19:21:06 +01:00
#!/bin/bash
pip install kaggle
kaggle datasets download -d open-powerlifting/powerlifting-database
unzip -o powerlifting-database.zip
DATASET_FILE="openpowerlifting.csv"
2024-05-14 22:44:38 +02:00
column_names=$(head -n 1 $DATASET_FILE)
echo "Truncated rows: ${1}"
2024-03-26 19:21:06 +01:00
head -n $1 $DATASET_FILE > cutoff_$DATASET_FILE
2024-05-14 22:44:38 +02:00
echo "$column_names" > temp && cat cutoff_$DATASET_FILE >> temp && mv temp cutoff_$DATASET_FILE
2024-03-26 19:21:06 +01:00
total_lines=$(tail -n +2 cutoff_$DATASET_FILE | wc -l)
train_lines=$((total_lines * 90 / 100))
dev_lines=$((total_lines * 10 / 100))
test_lines=$((total_lines - train_lines - dev_lines))
shuf cutoff_$DATASET_FILE -o shuffled.csv
head -n $train_lines shuffled.csv > train.csv
tail -n $((dev_lines + test_lines)) shuffled.csv | head -n $dev_lines > dev.csv
tail -n $test_lines shuffled.csv > test.csv
mkdir -p data
2024-05-14 22:44:38 +02:00
echo "$column_names" | cat - train.csv > temp && mv temp train.csv
echo "$column_names" | cat - dev.csv > temp && mv temp dev.csv
echo "$column_names" | cat - test.csv > temp && mv temp test.csv
mv train.csv dev.csv test.csv data/