{"id":17157550,"url":"https://github.com/andi611/libsvm-classification","last_synced_at":"2025-08-30T17:12:22.214Z","repository":{"id":100457111,"uuid":"161452795","full_name":"andi611/LibSVM-Classification","owner":"andi611","description":"Performing classification tasks with the LibSVM toolkit on four different datasets: Iris, News, Abalone, and Income.","archived":false,"fork":false,"pushed_at":"2018-12-18T08:05:01.000Z","size":3789,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-04T10:01:55.844Z","etag":null,"topics":["abalone","abalone-dataset","classification","classification-algorithm","data-mining","income","income-dataset","iris","iris-dataset","libsvm","libsvm-ready","news-dataset","newsgroups-dataset","scikit-learn","svm","svm-classifier","svm-training"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/andi611.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-12T07:59:01.000Z","updated_at":"2019-01-19T16:42:55.000Z","dependencies_parsed_at":"2023-05-14T20:15:43.631Z","dependency_job_id":null,"html_url":"https://github.com/andi611/LibSVM-Classification","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andi611/LibSVM-Classification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andi611%2FLibSVM-Classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andi611%2FLibSVM-Classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andi611%2FLibSVM-Classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andi611%2FLibSVM-Classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andi611","download_url":"https://codeload.github.com/andi611/LibSVM-Classification/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andi611%2FLibSVM-Classification/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272878320,"owners_count":25008336,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["abalone","abalone-dataset","classification","classification-algorithm","data-mining","income","income-dataset","iris","iris-dataset","libsvm","libsvm-ready","news-dataset","newsgroups-dataset","scikit-learn","svm","svm-classifier","svm-training"],"created_at":"2024-10-14T22:09:15.057Z","updated_at":"2025-08-30T17:12:22.209Z","avatar_url":"https://github.com/andi611.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Mining: Classification with LIBSVM\n- Datasets:\n    - Iris\n    - News (subset of 20 Newsgroups dataset, with testing label)\n    - Abalone\n    - Income (UCI Adult Income dataset)\n\n\n## Environment\n* **\u003c [libsvm 3.23](https://github.com/cjlin1/libsvm) \u003e**\n* **\u003c scikit-learn 0.20.1 \u003e** (For date preprocessing)\n* **\u003c numpy 1.15.4 \u003e**\n* **\u003c pandas 0.23.4 \u003e**\n* **\u003c Python 3.7 \u003e**\n \n\n## File Description\n```\n.\n├── src/\n|   ├── 1_iris.sh\n|   ├── 2_news.sh\n|   ├── 3_abalone.sh\n|   ├── 4_income.sh\n|   └── data_loader.py\n├── data/\n|   ├── iris\n|   |   ├── iris.tr\n|   |   ├── iris.te\n|   |   └── iris.names\n|   ├── news\n|   |   ├── news.tr\n|   |   ├── news.te\n|   |   └── news.names\n|   ├── abalone\n|   |   ├── abalone_test.csv\n|   |   ├── abalone_train.csv\n|   |   └── abalone.names\n|   └── income\n|       ├── income_test.csv\n|       ├── income_train.csv\n|       └── income.names\n├── result/ ---------------------\u003e model prediction output\n├── problem_description.pdf -----\u003e Work spec\n└── Readme.md -------------------\u003e This file\n```\n\n\n## Usage\n### Compile LibSVM from binary:\n- Use the `libsvm-3.23/` provided in this repo, or compile by yourself: \n- Unzip `libsvm-3.23.zip` with: `$ libsvm-3.23.zip`\n- In `libsvm-3.23/` type: `$ make`\n\n### Run LibSVM on the Iris Dataset:\n- `$ ./1_iris.sh`\n- There are four modes that can be set manually in the script (Line 19-22):\n\t- `RUN_BEST`: Run training and testing using the best parameter.\n\t- `COMPARE_KERNAL`: Run training and testing with different kernal settings and compare performance.\n\t- `COMPARE_SCALE`: Run training and testing with different kernal settings in addition to data scaling and compare performance.\n\t- `RUN_ALL`: Run everything above.\n\n### Run LibSVM on the News Dataset:\n- `$ ./2_news.sh`\n- There are four modes that can be set manually in the script (Line 19-23):\n\t- `RUN_BEST`: Run training and testing using the best parameter.\n\t- `COMPARE_KERNAL`: Run training and testing with different kernal settings and compare performance.\n\t- `COMPARE_CSVM`: Run training and testing with C-SVM settings and compare performance.\n\t- `COMPARE_SCALE`: Run training and testing with different kernal settings in addition to data scaling and compare performance.\n\t- `RUN_ALL`: Run everything above.\n\n### Run LibSVM on the Abalone Dataset:\n- `$ ./3_abalone.sh`\n- There are four modes that can be set manually in the script (Line 21-25):\n\t- `RUN_BEST`: Run training and testing using the best parameter.\n\t- `COMPARE_KERNAL`: Run training and testing with different kernal settings and compare performance.\n\t- `COMPARE_CSVM`: Run training and testing with C-SVM settings and compare performance.\n\t- `COMPARE_SCALE`: Run training and testing with different kernal settings in addition to data scaling and compare performance.\n\t- `RUN_ALL`: Run everything above.\n\n### Run LibSVM on the Income Dataset:\n- `$ ./4_income.sh`\n- There are four modes that can be set manually in the script (Line 18-26):\n\t- `RUN_BEST`: Run training and testing using the best parameter.\n\t- `RUN_BEST_NFOLD`: Run training and testing using the best parameter with N-Fold cross validation.\n\t- `COMPARE_KERNAL`: Run training and testing with different kernal settings and compare performance.\n\t- `COMPARE_CSVM`: Run training and testing with C-SVM settings and compare performance.\n\t- `COMPARE_SCALE`: Run training and testing with different kernal settings in addition to data scaling and compare performance.\n\t- `RUN_ALL`: Run everything above.\n\n\n## Result - Naive Bayes Performance\n\n### Iris Dataset Results\n- Best model training accuracy: **98.66%**\n- Best model testing accuracy: **100%**\n- Parameter and setting for best model: `svm-train -s 0 -t 0`\n\n| Kernel Type  | Testing Accuracy | Testing Accuracy with Scaling |\n| ------------- | ------------- | ------------- |\n| Linear | **100.00%** | 97.33% |\n| Polynomial | 98.66% | 70.66% |\n| Radial Basis Function | 97.33% | 98.66% |\n| Sigmoid  | 33.33% | 96.00% |\n\n\n### News Dataset Results\n- Best model training accuracy: **97.63%**\n- Best model testing accuracy: **84.97%**\n- Parameter and setting for best model: `svm-train -s 0 -t 0 -e 0.01 -w3 2.5`\n\n| Kernel Type  | Testing Accuracy | Testing Accuracy with Scaling |\n| ------------- | ------------- | ------------- |\n| Linear | **83.36%** | 79.86% |\n| Polynomial | 49.51% | 35.59% |\n| Radial Basis Function | 70.91% | 69.02% |\n| Sigmoid  | 70.91% | 67.62% |\n\n### Abalone Dataset Results\n- Best model training accuracy: **65.16%**\n- Best model testing accuracy: **66.63%**\n- Parameter and setting for best model: `svm-train -s 0 -t 0 -e 0.01 -c 20`\n\n| Kernel Type  | Testing Accuracy | Testing Accuracy with Scaling |\n| ------------- | ------------- | ------------- |\n| Linear | **66.63%** | 57.81% |\n| Polynomial | 61.84% | 57.91% |\n| Radial Basis Function | 66.25% | 55.90% |\n| Sigmoid  | 56.28% | 54.94% |\n\n### Income Dataset Results\n- Best model training accuracy: **85.23%**\n- Best model 3-Fold cross validation accuracy: **85.10%**\n\n| Kernel Type  | Cross Validation Accuracy | Cross Validation Accuracy with Sklearn Scaling | Cross Validation Accuracy with LibSVM Scaling |\n| ------------- | ------------- | ------------- | ------------- |\n| Linear | 53.67% | **85.07%** | 84.99% |\n| Polynomial | 44.37% | 82.91% | 75.96% |\n| Radial Basis Function | 75.68% | 84.76% | 83.47% |\n| Sigmoid  | 75.96% | 83.11% | 83.41% |\n\n## Data Preprocessing\n\n### Iris Dataset Preprocessing\n- None, this dataset is LibSVM ready.\n\n### News Dataset Preprocessing\n- None, this dataset is LibSVM ready.\n\n### Abalone Dataset Preprocessing\n- Specify each entry to either one of the data type: (`int`, `str`)\n- Change the first column (the sex attribute which is categorical and in `str`) into one-hot encoding vectors.\n- Write the resulting feature into LibSVM format.\n\n### Income Dataset Preprocessing\n- Specify each entry to either one of the data type: (`int`, `str`)\n- Identify all missing entries `'?'` and replace them with `np.nan`\n- Impute and estimate all missing entries:\n    - If dtype is `int`: impute with mean value of the feature column\n    - If dtype is `str`: impute with most frequent item in the feature column\n- Split data into categorical and continuous and process them separately:\n    - categorical features index = [1, 3, 5, 6, 7, 8, 9, 13]\n    - continuous features index = [0, 2, 4, 10, 11, 12]\n- For categorical data:\n    - 8 categorical attributes are transformed into a 99 dimension one-hot feature vector.\n- Normalize each attribute to zero mean and unit variance.\n- Write the resulting feature into LibSVM format.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandi611%2Flibsvm-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandi611%2Flibsvm-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandi611%2Flibsvm-classification/lists"}