{"id":17312955,"url":"https://github.com/vlomonaco/us-transportationmode","last_synced_at":"2025-04-14T14:15:12.351Z","repository":{"id":45754152,"uuid":"94562380","full_name":"vlomonaco/US-TransportationMode","owner":"vlomonaco","description":"Transportation Mode Detection with Unconstrained Smartphones Sensors","archived":false,"fork":false,"pushed_at":"2021-04-20T08:20:07.000Z","size":35032,"stargazers_count":42,"open_issues_count":1,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-14T14:15:02.663Z","etag":null,"topics":["context-awareness","internet-of-things","machine-learning","neural-networks","random-forest"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vlomonaco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-16T16:32:07.000Z","updated_at":"2025-03-24T04:12:51.000Z","dependencies_parsed_at":"2022-08-31T04:51:15.264Z","dependency_job_id":null,"html_url":"https://github.com/vlomonaco/US-TransportationMode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlomonaco%2FUS-TransportationMode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlomonaco%2FUS-TransportationMode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlomonaco%2FUS-TransportationMode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlomonaco%2FUS-TransportationMode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vlomonaco","download_url":"https://codeload.github.com/vlomonaco/US-TransportationMode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248894943,"owners_count":21179153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["context-awareness","internet-of-things","machine-learning","neural-networks","random-forest"],"created_at":"2024-10-15T12:45:11.460Z","updated_at":"2025-04-14T14:15:12.321Z","avatar_url":"https://github.com/vlomonaco.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# US-TransportationMode\n\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()\n[![built with Python2.7](https://camo.githubusercontent.com/65bf37ffbdcaef2a2cb000f66e2f395b32243357/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c64253230776974682d707974686f6e322e372d7265642e737667)](https://www.python.org/)\n\n**US-Transporation** is the name of our dataset that contains sensor data from over 13 users. In light of the lack in the literature of a common benchmark for TMD, we have collected a large set of measurements belonging to different subjects and through a simple Android Application. We openly release the dataset, so that other researchers can benefit from it for further improvements and research reproducibility.\u003cbr\u003e\nOur dataset is built from people of different gender, age and occupation. Moreover, we do not impose any restriction on the use of the application, hence every user records the data performing the action as she/he is used to, in order to assess real world conditions. \u003cbr\u003e\nIn this page in addition to downloadable datasets, you can find Python's code for extracting features,and building machine learning models to make predictions. \u003cbr\u003e\nYou can find more information about the dataset and our work at: http://cs.unibo.it/projects/us-tm2017/index.html.\n\nPlease cite the paper below in your publications if it helps your research:\n\n    @article{carpineti18,\n      Author = {Claudia Carpineti, Vincenzo Lomonaco, Luca Bedogni, Marco Di Felice, Luciano Bononi},\n      Journal = {Proc. of the 14th Workshop on Context and Activity Modeling and Recognition (IEEE COMOREA 2018)},\n      Title = {Custom Dual Transportation Mode Detection by Smartphone Devices Exploiting Sensor Diversity},\n      Year = {2018}\n      DOI = {https://doi.org/10.1109/PERCOMW.2018.8480119}\n    }\n\nOn-line version available here: https://ieeexplore.ieee.org/abstract/document/8480119\n\n# Menù\n\n* **[Dependecies](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#dependecies)**\n* **[Documentation](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#documentation)**\n  * **[Code](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#code)** \n  * **[Get started](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#get-started)**\n  * **[Project Structure](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#project-structure)**\n* **[License](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#license)**\n* **[Team of collaborators](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#team-of-collaborators)**\n* **[FAQ](https://github.com/vlomonaco/US-TransportationMode/blob/master/README.md#faq)**\n\n## Dependecies\nIn order to extecute the code in the repository you'll need to install the following dependencies:\n* [Python 2.7](https://www.python.org/)\n* [Scikit-learn](http://scikit-learn.org/stable/)\n* [Pandas](http://pandas.pydata.org/)\n\n## Documentation\n### Code\nIn this section we show the functionalities developed in our work and the relative parameters used.\n#### TMDataset.py\n\u003ctable\u003e\n\u003cthead\u003e\n\u003cth\u003eFunction name\u003c/th\u003e\n\u003cth\u003eParameter\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd\u003eclean_file()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003e\nFix original raw files problems: \n\u003cul\u003e\n\u003cli\u003edelete measure from  \u003cstrong\u003esensor_to_exclude\u003c/strong\u003e\u003c/li\u003e\n\u003cli\u003eif \u003cstrong\u003esound\u003c/strong\u003e or \u003cstrong\u003espeed\u003c/strong\u003e measure rows have negative time, use module\u003c/li\u003e\n\u003cli\u003eif **time** have incorrect values (\"/\", \"\u003e\", \"\u003c\", \"-\", \"_\"...), delete file\u003c/li\u003e\n\u003cli\u003eif file is empty, delete file\u003c/li\u003e \n\u003c/ul\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003etransform_raw_data()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eTransform sensor raw data in orientation independent data (with magnitude metric)\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e__fill_data_structure\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eFill tm, users, sensors data structures with the relative data from dataset\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e__range_position_in_header_with_features(sensor_name)\u003c/td\u003e\n\u003ctd\u003esensor_name: name of the sensor\u003c/td\u003e\n\u003ctd\u003eReturn position of input sensor in header with features\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003ecreate_header_files()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eFill directory with all file consistent with the header without features\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e__create_time_files()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eFill directory with all file consistent with the featured header divided in time window\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e__create_dataset()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eCreate dataset file\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003e__split_dataset()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eSplit passed dataframe into test and train\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003epreprocessing_files()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eClean files and transform in orientation independent\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eanalyze_sensors_support()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eFor each sensors analyze user support, put support result in sensor_support.csv [sensor,nr_user,list_users,list_classes]\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003ecreate_balanced_dataset(sintetic)\u003c/td\u003e\n\u003ctd\u003esintetic: set if data are sintentic or not. Default the value is \u003cstrong\u003eFalse\u003c/strong\u003e.\u003c/td\u003e\n\u003ctd\u003eAnalyze dataset composition in term of class and user contribution fill balance_time with minimum number of window for transportation mode\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eget_excluded_sensors(sensor_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data.\u003c/td\u003e\n\u003ctd\u003eReturn list of excluded sensor based on the correspondent classification level\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eget_remained_sensors(sensor_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data.\u003c/td\u003e\n\u003ctd\u003eReturn list of considered sensors based on the correspondent classification level\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eget_sensors_set_features()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eReturn list of the sensors set with their features\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eget_sensor_features(sensor)\u003c/td\u003e\n\u003ctd\u003esensor: data of a specific sensor\u003c/td\u003e\n\u003ctd\u003eReturn the features of a specific sensor\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n#### TMDetection.py\n\n\u003ctable\u003e\n\u003cthead\u003e\n\u003cth\u003eFunction name\u003c/th\u003e\n\u003cth\u003eParameter\u003c/th\u003e\n\u003cth\u003eDescription\u003c/th\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\n\u003ctr\u003e\n\u003ctd\u003edecision_tree(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003eDecision tree algorithm training on training al train set and test on all test set\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003erandom_forest(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003eRandom forest algorithm training on training al train set and test on all test set\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eneural_network(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003eNeural network algorithm training on training al train set and test on all test set\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003esupport_vector_machine(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003eSupport vector machine algorithm training on training al train set and test on all test set\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003eclasses_combination(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003eUse different algorithms changing target classes, try all combination of two target classes\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eleave_one_subject_out(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003esupport_vector_machine(sensors_set)\u003c/td\u003e\n\u003ctd\u003esensor_set: type of sensor dataset used with different sensor data\u003c/td\u003e\n\u003ctd\u003eUse different algorithms leaving one subject out from training and testing only on this subject considering all classes in dataset and only user classes\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003ctr\u003e\n\u003ctd\u003esingle_sensor_accuracy()\u003c/td\u003e\n\u003ctd\u003e\u003c/td\u003e\n\u003ctd\u003eUse feature relative to one sensor to build model and evaluate\u003c/td\u003e\n\u003c/tr\u003e\n\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n### Get started\nBefore starting, you must first download the data:\n```shell\npython download_dataset.py\n```\nThen you have to clean the raw data and extract the feature:\n\n```shell\npython TMDataset.py\n```\nFinally you can build models: \n```shell\npython TMDetection.py\n```\nFor further and detail information about our code, see our [tutorial section](http://cs.unibo.it/projects/us-tm2017/tutorial.html)\n\n### Project Structure\nUp to now the projects is structured as follows:\n```unicode\n.\n├── TransportationData\n|   ├── datasetBalanced\n|         └── ...\n|   └── _RawDataOriginal\n|         └── ...\n├── README.md\n├── LICENSE\n├── const.py\n├── function.py\n├── TMDataset.py\n├── TMDetection.py\n├── util.py\n├── sintetic_dataset_generator.py\n├── sintetic_dataset_config.json\n├── download_dataset.py\n└── cleanLog.log\n```\n## License\nThis work is licensed under a MIT License.\n\n## Team of collaborators\nThis project has been developed at the University of Bologna with the effort of different people:\n\n* \u003ca href=\"http://www.cs.unibo.it/~difelice/\"\u003eMarco Di Felice\u003c/a\u003e, Associate Professor - email: marco.difelice3@unibo.it\n* \u003ca href=\"http://www.cs.unibo.it/bononi/\" target=\"_blank\"\u003eLuciano Bononi\u003c/a\u003e, Associate Professor - email : luciano.bononi@unibo.it\n* \u003ca href=\"https://www.unibo.it/sitoweb/luca.bedogni4\"\u003eLuca Bedogni\u003c/a\u003e, Research Associate - email: luca.bedogni4@unibo.it\n* \u003ca href=\"http://vincenzolomonaco.com/\"\u003eVincenzo Lomonaco\u003c/a\u003e, PhD Student - email: vincenzo.lomonaco@unibo.it\n* \u003ca href=\"https://www.linkedin.com/in/matteo-cappella-30005b111/\" target=\"_blank\"\u003eMatteo Cappella\u003c/a\u003e • Master student - email: matteo.cappella@studio.unibo.it\n* \u003ca href=\"https://www.linkedin.com/in/simone-passaretti-397b23110/\" target=\"_blank\"\u003eSimone Passaretti\u003c/a\u003e • Master student - email: simone.passaretti@studio.unibo.it\n### Past collaborators\n* \u003ca href=\"https://www.linkedin.com/in/claudiacarpineti/\" target=\"_blank\"\u003eClaudia Carpineti\u003c/a\u003e • Master graduate student - email: claudia.carpineti@studio.unibo.it\n\n## FAQ\n\n\u003e I would need to know the units of the timestamps of each sensor measurements. In your article, you mention that the sampling frequency is approximately 20Hz. However, you do not specify the units of these time stamps. Are they given in seconds or milliseconds?\n\nThe timestamps are in milliseconds!\n\n\u003e Can I assume that the units of the sensor data (accelerometer, gyroscope and magnetometer) are the standard ones (m/s^2, rad/s and uT, respectively)?\n\nYes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlomonaco%2Fus-transportationmode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvlomonaco%2Fus-transportationmode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlomonaco%2Fus-transportationmode/lists"}