{"id":17854821,"url":"https://github.com/yoyolicoris/iml_hw2","last_synced_at":"2025-04-02T17:25:55.528Z","repository":{"id":140051699,"uuid":"111557070","full_name":"yoyolicoris/IML_HW2","owner":"yoyolicoris","description":"My implementation of homework 2 for the Introduction to Machine Learning class in NCTU (course number 1181).","archived":false,"fork":false,"pushed_at":"2017-11-28T09:07:30.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T13:14:27.539Z","etag":null,"topics":["kd-tree","knn-classification","pca-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoyolicoris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-21T14:08:50.000Z","updated_at":"2023-07-17T06:40:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"8fcba81a-b606-491b-a5ec-fb612c7c25b7","html_url":"https://github.com/yoyolicoris/IML_HW2","commit_stats":null,"previous_names":["yoyolicoris/iml_hw2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyolicoris%2FIML_HW2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyolicoris%2FIML_HW2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyolicoris%2FIML_HW2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyolicoris%2FIML_HW2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoyolicoris","download_url":"https://codeload.github.com/yoyolicoris/IML_HW2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246858419,"owners_count":20845291,"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":["kd-tree","knn-classification","pca-analysis"],"created_at":"2024-10-28T01:40:56.712Z","updated_at":"2025-04-02T17:25:55.501Z","avatar_url":"https://github.com/yoyolicoris.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Environment\n\n* Ubuntu 16.04 LTS\n* python2.7.12(using Pycharm 2017.2.3)\n* extra module: numpy, sklearn, pandas, matplotlib\n\n## Usage\n\nRun the following command, this will display the accuracy of KNN and the k nearest neighbor's index of first three test data using different K (1, 5, 10, 100), along with PCA version of KNN.\n```\n./run.sh \u003ctrain file.csv\u003e \u003ctest file.csv\u003e\n```\n\nOutput format:\n\n```\nKNN accuracy:  1.0\n286\n151\n149\n\nKNN accuracy:  0.861111111111\n286 87 252 142 226\n151 282 276 71 221\n149 219 257 283 79\n\nKNN accuracy:  0.888888888889\n286 87 252 142 226 158 60 247 141 293\n151 282 276 71 221 84 81 289 49 10\n149 219 257 283 79 239 249 227 210 99\n\nKNN accuracy:  0.583333333333\n286 87 252 142 226 158 60 247 141 293 85 171 202 299 30 111 150 44 3 223 198 102 263 193 96 209 143 119 145 15 163 39 211 180 68 29 284 120 53 237 0 205 113 80 50 98 296 267 196 212 40 23 241 118 190 16 189 240 56 115 191 259 106 156 235 4 246 162 101 2 70 233 238 109 173 184 270 36 54 243 37 279 116 177 41 108 260 297 27 242 187 206 232 281 124 217 200 225 288 265\n151 282 276 71 221 84 81 289 49 10 195 92 117 174 91 9 199 274 79 253 82 227 292 34 249 69 140 250 181 191 201 53 271 260 72 210 239 216 288 265 219 284 48 76 184 215 175 121 161 232 143 194 208 104 133 62 243 182 285 12 183 228 146 149 19 261 267 254 125 266 189 236 124 14 220 205 89 272 57 65 100 108 235 264 294 96 162 46 127 196 230 296 238 45 80 200 283 66 139 99\n149 219 257 283 79 239 249 227 210 99 67 285 34 91 169 215 33 264 97 155 251 78 112 51 253 195 18 21 43 65 290 49 127 133 170 100 199 140 216 66 82 292 161 224 276 288 262 207 234 274 174 229 52 117 282 186 166 184 88 135 110 74 261 7 77 9 182 179 46 72 295 176 238 139 56 194 157 289 153 231 57 10 12 269 152 201 19 258 20 105 244 28 221 172 93 92 81 275 151 71\n\nK = 5, KNN_PCA accuracy: 0.861111\n```\n\nIf you want to see the whole result of the PCA version of KNN, run the following command:\n```\npython2 PCA.py \u003ctrain file.csv\u003e \u003ctest file.csv\u003e\n```\nIt's output format is the same as original KNN, but with M dimension of data (M=1~D, D=original dimension) after PCA transform the original training data.\nAnd when M=2, it will plot the data distribution of all class using the most contributive pair of eigenvalue.\n![](pca_2d.png)\n\nLast, it will show the best dimension to have the highest average accuracy above all K.\n\nFor detailed discussion in chinese, please refer to this [report](REPORT.md).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoyolicoris%2Fiml_hw2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoyolicoris%2Fiml_hw2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoyolicoris%2Fiml_hw2/lists"}