{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 24 buildings in the testing set.\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
filebuildingsite
0../input/indoor-location-navigation/test//00ff...5da1389e4db8ce0c98bd0547SiteName:和达城商场
1../input/indoor-location-navigation/test//01c4...5da138b74db8ce0c98bd4774SiteName:万象城
2../input/indoor-location-navigation/test//030b...5da138764db8ce0c98bcaa46SiteName:银泰百货
3../input/indoor-location-navigation/test//0389...5dbc1d84c1eb61796cf7c010SiteName:杭州大悦城
4../input/indoor-location-navigation/test//0402...5da1383b4db8ce0c98bc11abSiteName:永旺梦乐城
\n", "
" ], "text/plain": [ " file \\\n", "0 ../input/indoor-location-navigation/test//00ff... \n", "1 ../input/indoor-location-navigation/test//01c4... \n", "2 ../input/indoor-location-navigation/test//030b... \n", "3 ../input/indoor-location-navigation/test//0389... \n", "4 ../input/indoor-location-navigation/test//0402... \n", "\n", " building site \n", "0 5da1389e4db8ce0c98bd0547 SiteName:和达城商场 \n", "1 5da138b74db8ce0c98bd4774 SiteName:万象城 \n", "2 5da138764db8ce0c98bcaa46 SiteName:银泰百货 \n", "3 5dbc1d84c1eb61796cf7c010 SiteName:杭州大悦城 \n", "4 5da1383b4db8ce0c98bc11ab SiteName:永旺梦乐城 " ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np # linear algebra\n", "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", "\n", "# Input data files are available in the read-only \"../input/\" directory\n", "# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n", "\n", "import os\n", "# Prepare paths:\n", "import glob\n", "from pathlib import Path\n", "inpath = '../input/indoor-location-navigation/'\n", "metapath = inpath + 'metadata/'\n", "trainpath = inpath + 'train/'\n", "testpath = inpath + 'test/'\n", "\n", "# Extract testing files, buildings and sites:\n", "os.system(f'grep SiteID {testpath}/* > test_buildings.txt' )\n", "test_buildings = pd.read_csv('test_buildings.txt',sep='\\t',header=None,names=['file','building','site'])\n", "test_buildings['file'] = test_buildings['file'].apply(lambda x: x[:-2])\n", "test_buildings['building'] = test_buildings['building'].apply(lambda x: x[7:])\n", "\n", "# How many buildings in the testing set?\n", "buildings = np.unique(test_buildings['building'])\n", "print('There are',len(buildings),'buildings in the testing set.')\n", "\n", "test_buildings.head()\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Compile C++ pre-processing code:\n", "er=os.system(\"g++ ../input/indoor-cpp/1_preprocess.cpp -std=c++11 -o preprocess\")\n", "if(er): print(\"Error\")\n", "\n", "# Reformat the testing set:\n", "os.system('mkdir test')\n", "for i,(path_filename,building) in enumerate(zip(test_buildings['file'],test_buildings['building'])):\n", " er=os.system(f'./preprocess {path_filename} test {building} {0}') #since we do not know the floor, I put 0.\n", " if(er): print(\"Error:\",path_filename)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Acceleration, magnetic and orientation testing data:\n", "os.system('mkdir indoor_testing_accel')\n", "os.system(\"g++ ../input/indoor-cpp/2_preprocess_accel.cpp -std=c++11 -o preprocess_accel\")\n", "for building in buildings:\n", " os.system(f'./preprocess_accel {building}')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Wifi testing data:\n", "os.system('mkdir test_wifi')\n", "os.system(\"g++ /kaggle/input/indoor-cpp/2_preprocess_wifi.cpp -std=c++11 -o preprocess_wifi\")\n", "for building in buildings:\n", " os.system(f'./preprocess_wifi {building}')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }