{"id":24847588,"url":"https://github.com/stefantaubert/quora-competition","last_synced_at":"2025-10-14T19:30:27.238Z","repository":{"id":77474372,"uuid":"115260627","full_name":"stefantaubert/quora-competition","owner":"stefantaubert","description":"Code for Quora Competition on Kaggle","archived":false,"fork":false,"pushed_at":"2018-01-17T08:24:37.000Z","size":468,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-07T11:24:27.668Z","etag":null,"topics":["data-science","dataset","evaluation","jaccard","kaggle","lemmatization","levenshtein","nlp","python","quora","quora-competition","quora-question-pairs","random-search","tfidf","tokenization","xgboost"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/stefantaubert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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-12-24T12:12:00.000Z","updated_at":"2019-08-29T19:51:19.000Z","dependencies_parsed_at":"2023-04-30T17:46:28.595Z","dependency_job_id":null,"html_url":"https://github.com/stefantaubert/quora-competition","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stefantaubert/quora-competition","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefantaubert%2Fquora-competition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefantaubert%2Fquora-competition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefantaubert%2Fquora-competition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefantaubert%2Fquora-competition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefantaubert","download_url":"https://codeload.github.com/stefantaubert/quora-competition/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefantaubert%2Fquora-competition/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020650,"owners_count":26086898,"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-10-14T02:00:06.444Z","response_time":60,"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":["data-science","dataset","evaluation","jaccard","kaggle","lemmatization","levenshtein","nlp","python","quora","quora-competition","quora-question-pairs","random-search","tfidf","tokenization","xgboost"],"created_at":"2025-01-31T11:30:05.168Z","updated_at":"2025-10-14T19:30:27.233Z","avatar_url":"https://github.com/stefantaubert.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quora Question Pairs\n\nOn Q\u0026A-Portals like Quora, Yahoo! Answers, Ask.fm, WikiAnswers or StackExchange were asked und answered tausands of questions every day. 6 Million of the over 13 million questions on Quora were asked only in the last year (march 2017). Thats are more than 16,000 new questions per day. For this amount of questions it is likely that someone want to ask an question which is alreecause the portal could list equal question to the user at the point he formulates his question. Maybe someone has already answered one of those questions and the questioner can get the answer to his question immediately. Also the seekers of answers find all answers central on one location and they don't have to look on ten versions of the question for an answer. The question responders profit likewise because they have to answer only one time per question. This could result in a better discussion for people with different opinions.\n\nHere you can find a [link](https://www.kaggle.com/c/quora-question-pairs) to the competition on Kaggle.\n\n## Approach\n\nTo solve this task data I do the following three steps:\n1. analyse the question-pairs from quora\n2. create an algorithm to idetify same question-meanings\n3. evaluate the algorithm\n\nThe last two steps I repeated as long as I get an satisfying result. For the evaluation I created a validationset because the evaluation on the testset had some restrictions:\n- only 5 submissions each day \n- evaluation only with log-loss\n- evaluation only for complete dataset\n\nFor those reasons I split up 10 percent of the trainingsset for the validationset. So I was able to:\n- create as many evaluations per day\n- evaluate with accuracy, precision, recall, f1 and log-loss\n- evaluate for the following **scopes**:\n\t- *all*: complete validationset\n\t- *0_30*: pairs where both questions have between 0 and 30 chars\n\t- *30_70*: pairs where both questions have between 30 and 70 chars\n\t- *70_150*: pairs where both questions have between 70 and 150 chars\n\n## Features\n\nI defined five feature groups:\n- **Word Count Features** e.g. length of q1, count of words of q1 without stopwords\n- **Levenshtein Feature** which calculates the levenshtein-distance for the pair\n- **Shared Words Features** e.g. count of common words or jaccard-distance\n- **Tf-Idf Features** which calculates the weights of common words\n- **Frequency Features** e.g. count of questionpairs which contains q1\n\nThose five feature groups resulted in 43 Features.\n\n## Parameter Optimization\n\nTo find the best combination of features I used random search as parameter optimization method. I've done 170 iterations on which I always used new combinations of these features. Then I calculated the scores of the evaluation metrics for the validationset for all scopes and saved the results in an CSV-file. The next iteration began. Here you can see how the CSV-file looked like:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"CSV-file example\" src=\"/screenshots/evaluation.png\"\u003e\n\u003c/p\u003e\n\nFor modell training I choosed XGBoost and the parameters of XGBoost I also varied, for example:\n- max_depth: 6 / 7 / 8\n- num_boosting_rounds: 2000 / 2500\n\nThe preprocessing of the questions I implemented with a Pipeline and FeatureUnion. I tryed the following:\n- convert all words to lower\n- use TokTokTokenizer\n- use WordNetLemmatizer\n\nAfter the training I rounded the resulting predictions to 0 or 1 to make the evaluation possible. Therefor I tryed rounding on 0.4, 0.5 and 0.6 to find the best rounding boundary for the highest f1.\n\n## Results\n\nI achieved an accuracy of over 87 percent for the validationset. The best feature was the Levenshtein-Feature followed from the Tf-Idf Features. I discovered that with only a low amount of features a good accuracy could be achieved.\nAlso the usage of a tokenizer and lemmatizer increased the accuracy and rounding at 0.4 resulted in the highest f1. Converting all questions to lowercase also add up to a better accuracy.\n\n## Code\n\nFor install instructions go [here](https://github.com/stefantaubert/quora-competition/tree/master/src).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefantaubert%2Fquora-competition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefantaubert%2Fquora-competition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefantaubert%2Fquora-competition/lists"}