{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport numpy as np","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import path\nimport glob,os","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neighbors import KNeighborsRegressor","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"base_path = '../input/indoor-navigation-and-location-wifi-features/wifi_features/'","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv('../input/simple-99-accurate-floor-model/submission.csv')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_files  = sorted(glob.glob('../input/indoor-navigation-and-location-wifi-features/wifi_features/train/*.csv'))\ntest_files = sorted(glob.glob('../input/indoor-navigation-and-location-wifi-features/wifi_features/test/*.csv'))","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = list()\nfor i in range(len(train_files)):\n    data = pd.read_csv(train_files[i])\n    fea,tar = data.iloc[:,1:-4],data.iloc[:,-4:-2]\n\n    predict = pd.read_csv(test_files[i]).iloc[:,1:-1]\n    regressor = KNeighborsRegressor(n_neighbors=1,weights=\"uniform\",algorithm=\"ball_tree\",leaf_size=17)\n    regressor.fit(fea,tar)\n    predictions.append(regressor.predict(predict))","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predictions = np.vstack(predictions)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['x'] = predictions[:,0]\nsubmission['y'] = predictions[:,1]","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv',index=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission","metadata":{},"execution_count":null,"outputs":[]}]}