{"cells":[{"metadata":{},"cell_type":"markdown","source":"This predictor uses \"Indoor Navigation and Location Wifi Features\" data by [@hiro5299834](https://www.kaggle.com/hiro5299834), which is based on data by [@devinanzelmo](https://www.kaggle.com/devinanzelmo)."},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os, glob\nfrom catboost import CatBoostClassifier, CatBoostRegressor","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df = pd.read_csv('../input/indoor-location-navigation/sample_submission.csv')\ntest_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"feature_dir = \"../input/indoor-navigation-and-location-wifi-features\"\ntrain_files = sorted(glob.glob(os.path.join(feature_dir, '*_train.csv')))\ntest_files = sorted(glob.glob(os.path.join(feature_dir, '*_test.csv')))\ntest_df['site'] = test_df['site_path_timestamp'].apply(lambda x: x.split('_')[0])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"for i, site in enumerate(test_df['site'].unique()):\n    train_data = pd.read_csv(train_files[i], index_col=0)\n    test_data = pd.read_csv(test_files[i], index_col=0)\n    X_train = train_data.drop(['x', 'y', 'f', 'path'], axis=1)\n    X_test = test_data.drop(['site_path_timestamp'], axis=1)\n\n    f_model = CatBoostClassifier(verbose=False)\n    f_model.fit(X_train, train_data['f'])\n    test_df.loc[test_df['site']==site, 'floor'] = f_model.predict(X_test)\n\n    model = CatBoostRegressor(verbose=False, objective='RMSE', depth=10)\n\n    model.fit(X_train, train_data['x'])\n    test_df.loc[test_df['site']==site, 'x'] = model.predict(X_test)\n\n    model.fit(X_train, train_data['y'])\n    test_df.loc[test_df['site']==site, 'y'] = model.predict(X_test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.drop(['site'], axis=1).to_csv('submission.csv', index=None)\ntest_df.head()","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}