{"id":20937555,"url":"https://github.com/jmcheon/dslr","last_synced_at":"2026-05-20T01:02:40.863Z","repository":{"id":181703195,"uuid":"649420786","full_name":"jmcheon/dslr","owner":"jmcheon","description":"Subject created by the 42AI association. Discover Data Science in the projects where you re-constitute Poudlard’s Sorting Hat. Warning: this is not a subject on cameras.","archived":false,"fork":false,"pushed_at":"2024-04-05T11:59:44.000Z","size":186386,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T20:22:20.279Z","etag":null,"topics":["data-science","logistic-regression","python3"],"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/jmcheon.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":"2023-06-04T19:34:34.000Z","updated_at":"2024-02-02T20:13:41.000Z","dependencies_parsed_at":"2024-04-05T12:50:23.201Z","dependency_job_id":null,"html_url":"https://github.com/jmcheon/dslr","commit_stats":null,"previous_names":["jmcheon/dslr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcheon%2Fdslr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcheon%2Fdslr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcheon%2Fdslr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmcheon%2Fdslr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmcheon","download_url":"https://codeload.github.com/jmcheon/dslr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330323,"owners_count":20274039,"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":["data-science","logistic-regression","python3"],"created_at":"2024-11-18T22:37:37.268Z","updated_at":"2025-12-30T02:04:46.918Z","avatar_url":"https://github.com/jmcheon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Datascience X Logistic Regression - Harry Potter and a Data Scientist\n\u003e*_Summary: Write a classifier and save Hogwarts!_*\n\n| Requirements | Skills |\n|--------------|--------|\n| - `python3.11`\u003cbr\u003e - `numpy`\u003cbr\u003e - `pandas`\u003cbr\u003e - `matplotlib`\u003cbr\u003e - `scikit-learn`\u003cbr\u003e - `seaborn` | - `DB \u0026 Data`\u003cbr\u003e - `Algorithms \u0026 AI` |\n\n\n## 0. Installation\n```bash\nsh ./launch_conda.sh\nconda activate 42AI-${USER}\n```\n\n## 1. Data Analysis\n### Description\n| Column name                   | data type    |\n|:------------------------------|:------------:|\n| Index                         | int          |\n| Hogwarts House                | object (str) |\n| First Name                    | object (str) |\n| Last Name                     | object (str) |\n| Birthday                      | object (str) |\n| Best Hand                     | object (str) |\n| Arithmancy                    | float        |\n| Astronomy                     | float        |\n| Herbology                     | float        |\n| Defense Against the Dark Arts | float        |\n| Divination                    | float        |\n| Muggle Studies                | float        |\n| Ancient Runes                 | float        |\n| History of Magic              | float        |\n| Transfiguration               | float        |\n| Potions                       | float        |\n| Care of Magical Creatures     | float        |\n| Charms                        | float        |\n| Flying                        | float        |\n\n\n##### Categorical data\n```\nIndex                 0           1           2           3     ...        1596         1597        1598        1599\nHogwarts House   Ravenclaw   Slytherin   Ravenclaw  Gryffindor  ...   Slytherin   Gryffindor  Hufflepuff  Hufflepuff\nFirst Name          Tamara       Erich    Stephany       Vesta  ...      Shelli     Benjamin   Charlotte       Kylie\nLast Name              Hsu     Paredes       Braun   Mcmichael  ...        Lock  Christensen      Dillon       Nowak\nBirthday        2000-03-30  1999-10-14  1999-11-03  2000-08-19  ...  1998-03-12   1999-10-24  2001-09-21  2000-08-21\nBest Hand             Left       Right        Left        Left  ...        Left        Right        Left        Left\n```\n##### Numerical data\n\n```\n                                count          mean           std           min           25%           50%           75%            max                     \nArithmancy                     1566.0  49634.570243  16679.806036 -24370.000000  38511.500000  49013.500000  60811.250000  104956.000000\nAstronomy                      1568.0     39.797131    520.298268   -966.740546   -489.551387    260.289446    524.771949    1016.211940\nHerbology                      1567.0      1.141020      5.219682    -10.295663     -4.308182      3.469012      5.419183      11.612895\nDefense Against the Dark Arts  1569.0     -0.387863      5.212794    -10.162119     -5.259095     -2.589342      4.904680       9.667405\nDivination                     1561.0      3.153910      4.155301     -8.727000      3.099000      4.624000      5.667000      10.032000\nMuggle Studies                 1565.0   -224.589915    486.344840  -1086.496835   -577.580096   -419.164294    254.994857    1092.388611\nAncient Runes                  1565.0    495.747970    106.285165    283.869609    397.511047    463.918305    597.492230     745.396220\nHistory of Magic               1557.0      2.963095      4.425775     -8.858993      2.218653      4.378176      5.825242      11.889713\nTransfiguration                1566.0   1030.096946     44.125116    906.627320   1026.209993   1045.506996   1058.436410    1098.958201\nPotions                        1570.0      5.950373      3.147854     -4.697484      3.646785      5.874837      8.248173      13.536762\nCare of Magical Creatures      1560.0     -0.053427      0.971457     -3.313676     -0.671606     -0.044811      0.589919       3.056546\nCharms                         1600.0   -243.374409      8.783640   -261.048920   -250.652600   -244.867765   -232.552305    -225.428140\nFlying                         1600.0     21.958012     97.631602   -181.470000    -41.870000     -2.515000     50.560000     279.070000\n```\n\n## 2. Data Visualization\n|[histogram.py](./histogram.py)|[scatter.py](./scatter.py)    |\n|---------------------------------------------|-------------------------------------------------------|\n|![histogram](https://github.com/jmcheon/dslr/assets/40683323/37f1aff8-fa15-4786-849c-dca507659868)|![scatter](https://github.com/jmcheon/dslr/assets/40683323/d0291802-b765-47ab-b4af-fd1293ee49b3)|\n\n### 2.1 Histogram\nMake a script called histogram.[extension] which displays a histogram answering the next question : \n\nWhich Hogwarts course has a homogeneous score distribution between all four houses?\n```\nvariances:\nArithmancy                       2.782159e+08\nAstronomy                        2.707103e+05\nHerbology                        2.724508e+01\nDefense Against the Dark Arts    2.717322e+01\nDivination                       1.726653e+01\nMuggle Studies                   2.365313e+05\nAncient Runes                    1.129654e+04\nHistory of Magic                 1.958748e+01\nTransfiguration                  1.947026e+03\nPotions                          9.908986e+00\nCare of Magical Creatures        9.437286e-01\nCharms                           7.715233e+01\nFlying                           9.531930e+03\ndtype: float64\n```\n\n### 2.2 Scatter plot\nMake a script called scatter_plot.[extension] which displays a scatter plot answering the next question : \n\nWhat are the two features that are similar?\n```\nFeature 1                     Feature 2                     Threshold\nAstronomy                     Defense Against the Dark Arts 0.9999999999999984\nMuggle Studies                Charms                        0.8476070313934801\nHistory of Magic              Transfiguration               0.8492027176461879\nHistory of Magic              Flying                        0.8962834248882747\nTransfiguration               Flying                        0.8736726050021425\n```\n\n### 2.3 Pair plot\nMake a script called pair_plot.[extension] which displays a pair plot or scatter plot matrix (according to the library that you are using). \n![pair plot](https://github.com/jmcheon/dslr/assets/40683323/188ab916-fa6f-4436-823a-46d0859de23a)\n\nFrom this visualization, what features are you going to use for your logistic regression?\n\n\n## 3. Logistic Regression\n\n#### What is one-vs-all method\n\nThe one-vs-all (OvA) method, also known as one-vs-rest (OvR), is a strategy used in multi-class classification problems in machine learning. It involves training multiple binary classifiers, one for each class, to distinguish between that specific class and all the other classes combined.\n\n#### Logistic regression\n\nLogistic regression is a supervised machine learning algorithm used primarily for binary classification problems. Its goal is to predict one of two possible outcomes (usually represented as 0 and 1), based on the given input features.\n\nIt is a type of generalized linear model (GLM) that uses a logistic function (sigmoid function) to model the probability of an instance belonging to the positive class, given its features.\n\n- [logreg_train.py](./logreg_train.py) saves ./weights.csv\n```\nUsage:  python logreg_train.py [data path] (for batch gradient descent)\n        python logreg_train.py [data path] [batch option]\n        three batch options: batch, sgd (for stochastic), mini (for mini-batch)\n```\n- [logreg_predict.py](./logreg_predict.py) takes ./weights.csv and saves ./houses.csv\n- [evaluate.py](./evaluate.py) - evaluates on dataset_truth.csv with houses.csv\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003eStochastic\u003c/th\u003e\n    \u003cth\u003eMini batch\u003c/th\u003e\n    \u003cth\u003eBatch\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"https://github.com/jmcheon/dslr/assets/40683323/a5868045-6f6e-4a6b-bbb0-47369729723d\" width=\"300\" height=\"400\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://github.com/jmcheon/dslr/assets/40683323/dfb63958-9597-4f31-9831-f480b2db9988\" width=\"300\" height=\"400\"\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"https://github.com/jmcheon/dslr/assets/40683323/9c472695-eb61-4d82-bb7f-907753ab214f\" width=\"300\" height=\"400\"\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcheon%2Fdslr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmcheon%2Fdslr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmcheon%2Fdslr/lists"}