Datasets:
Formats:
csv
Size:
10M - 100M
Tags:
humanoid-robotics
fall-prediction
machine-learning
sensor-data
robotics
temporal-convolutional-networks
License:
Commit ·
bc5a291
1
Parent(s): 2f6a432
doc and eaxmple
Browse files- README.md +51 -0
- requirements.txt +3 -0
- usage_example.py +54 -0
README.md
CHANGED
|
@@ -38,6 +38,57 @@ This dataset is shared under the **apache-2.0** license, allowing use and modifi
|
|
| 38 |
## Citation
|
| 39 |
If you use this dataset in your research, please cite it as follows:
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
---
|
| 42 |
license: apache-2.0
|
| 43 |
---
|
|
|
|
| 38 |
## Citation
|
| 39 |
If you use this dataset in your research, please cite it as follows:
|
| 40 |
|
| 41 |
+
|
| 42 |
+
## How to Use the Dataset
|
| 43 |
+
|
| 44 |
+
To get started with the **Fall Prediction Dataset for Humanoid Robots**, follow the steps below:
|
| 45 |
+
|
| 46 |
+
### 1. Set Up a Virtual Environment
|
| 47 |
+
|
| 48 |
+
It's recommended to create a virtual environment to isolate dependencies. You can do this with the following command:
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
python -m venv .venv
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
+
After creating the virtual environment, activate it:
|
| 55 |
+
|
| 56 |
+
- On **Windows**:
|
| 57 |
+
```bash
|
| 58 |
+
.venv\Scripts\activate
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
- On **macOS/Linux**:
|
| 62 |
+
```bash
|
| 63 |
+
source .venv/bin/activate
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
### 2. Install Dependencies
|
| 67 |
+
|
| 68 |
+
Once the virtual environment is active, install the necessary packages by running:
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
pip install -r requirements.txt
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
### 3. Run the Example Script
|
| 75 |
+
|
| 76 |
+
To load and use the dataset for training a simple LSTM model, run the `usage_example.py` script:
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
python usage_example.py
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
This script demonstrates how to:
|
| 83 |
+
- Load the dataset
|
| 84 |
+
- Select the relevant sensor columns
|
| 85 |
+
- Split the data into training and test sets
|
| 86 |
+
- Train a basic LSTM model to predict falls
|
| 87 |
+
- Evaluate the model on the test set
|
| 88 |
+
|
| 89 |
+
Make sure to check the script and adjust the dataset paths if necessary. For further details, see the comments within the script.
|
| 90 |
+
|
| 91 |
+
|
| 92 |
---
|
| 93 |
license: apache-2.0
|
| 94 |
---
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
tensorflow
|
| 3 |
+
scikit-learn
|
usage_example.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Usage Example for the Fall Prediction Dataset
|
| 2 |
+
# Please install dependencies before:
|
| 3 |
+
# pip install -r requirements.txt
|
| 4 |
+
|
| 5 |
+
# Import necessary libraries
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import tensorflow as tf
|
| 8 |
+
from tensorflow.keras.models import Sequential
|
| 9 |
+
from tensorflow.keras.layers import Dense, LSTM, Dropout
|
| 10 |
+
from sklearn.model_selection import train_test_split
|
| 11 |
+
|
| 12 |
+
# Load the dataset from Huggingface or a local file path
|
| 13 |
+
# Example for local loading; replace with Huggingface dataset call if applicable
|
| 14 |
+
real_data = pd.read_csv('dataset.csv.bz2', compression='bz2')
|
| 15 |
+
|
| 16 |
+
# Preview the dataset
|
| 17 |
+
print(real_data.head())
|
| 18 |
+
|
| 19 |
+
# Select relevant columns (replace these with actual column names from your dataset)
|
| 20 |
+
# Here we assume that the dataset contains sensor readings like gyroscope and accelerometer data
|
| 21 |
+
relevant_columns = ['gyro_x', 'gyro_y', 'gyro_z', 'acc_x', 'acc_y', 'acc_z', 'upright']
|
| 22 |
+
sensordata = real_data[relevant_columns]
|
| 23 |
+
|
| 24 |
+
# Split the data into features (X) and labels (y)
|
| 25 |
+
# 'fall_label' is assumed to be the column indicating whether a fall occurred
|
| 26 |
+
X = sensordata.drop(columns=['upright']) # Replace 'fall_label' with the actual label column
|
| 27 |
+
y = sensordata['upright']
|
| 28 |
+
|
| 29 |
+
# Split data into training and test sets
|
| 30 |
+
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
|
| 31 |
+
|
| 32 |
+
# Reshape data for LSTM input (assuming time-series data)
|
| 33 |
+
# Adjust the reshaping based on your dataset structure
|
| 34 |
+
X_train = X_train.values.reshape(X_train.shape[0], X_train.shape[1], 1)
|
| 35 |
+
X_test = X_test.values.reshape(X_test.shape[0], X_test.shape[1], 1)
|
| 36 |
+
|
| 37 |
+
# Define a simple LSTM model
|
| 38 |
+
model = Sequential()
|
| 39 |
+
model.add(LSTM(64, input_shape=(X_train.shape[1], 1)))
|
| 40 |
+
model.add(Dropout(0.2))
|
| 41 |
+
model.add(Dense(1, activation='sigmoid'))
|
| 42 |
+
|
| 43 |
+
# Compile the model
|
| 44 |
+
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
|
| 45 |
+
|
| 46 |
+
# Train the model
|
| 47 |
+
history = model.fit(X_train, y_train, epochs=10, batch_size=64, validation_data=(X_test, y_test))
|
| 48 |
+
|
| 49 |
+
# Evaluate the model on the test set
|
| 50 |
+
loss, accuracy = model.evaluate(X_test, y_test)
|
| 51 |
+
print(f"Test Accuracy: {accuracy * 100:.2f}%")
|
| 52 |
+
|
| 53 |
+
# You can save the model if needed
|
| 54 |
+
# model.save('fall_prediction_model.h5')
|