[{"data":1,"prerenderedAt":549},["ShallowReactive",2],{"content-query-XHqOzoGjRG":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"heading":10,"prompt":11,"tags":15,"files":17,"nav":17,"presets":18,"gallery":30,"body":32,"_type":542,"_id":543,"_source":544,"_file":545,"_stem":546,"_extension":547,"sitemap":548},"/tools/logistic-regression","tools",false,"","Logistic Regression Calculator for Excel & CSV","Run logistic regression online from Excel or CSV data. Estimate odds ratios, predicted probabilities, ROC curves, and classification metrics with AI.","Logistic Regression",{"prefix":12,"label":13,"placeholder":14},"Run logistic regression","Describe the columns for logistic regression you want to run","e.g. logistic regression to predict column A using column B",[16],"statistics",true,[19,25],{"label":20,"prompt":21,"dataset_url":22,"dataset_title":23,"dataset_citation":24},"COVID outcome by vaccination","logistic regression predicting whether a COVID outcome is a death (vs case) based on vaccination status and age group","https://data.cdc.gov/api/views/3rge-nu2a/rows.csv?accessType=DOWNLOAD","Rates of COVID-19 Cases or Deaths by Age Group and Vaccination Status","CDC",{"label":26,"prompt":27,"dataset_url":28,"dataset_title":29,"dataset_citation":24},"High vs. low heart disease mortality","logistic regression: create a binary outcome where counties are classified as above or below median heart disease mortality rate, then predict this using year and available numeric columns","https://data.cdc.gov/api/views/55yu-xksw/rows.csv?accessType=DOWNLOAD","Heart Disease Mortality Data Among US Adults (35+) by State/Territory and County - 2019-2021",[31],"/img/tools/logistic-regression.png",{"type":33,"children":34,"toc":533},"root",[35,44,58,63,83,89,129,151,157,281,287,378,384,461,467,484,501,517],{"type":36,"tag":37,"props":38,"children":40},"element","h2",{"id":39},"what-is-logistic-regression",[41],{"type":42,"value":43},"text","What Is Logistic Regression?",{"type":36,"tag":45,"props":46,"children":47},"p",{},[48,50,56],{"type":42,"value":49},"Logistic regression predicts the ",{"type":36,"tag":51,"props":52,"children":53},"strong",{},[54],{"type":42,"value":55},"probability of a binary outcome",{"type":42,"value":57}," — yes/no, pass/fail, churned/retained, diseased/healthy. Despite the name, it is a classification method, not a regression in the traditional sense.",{"type":36,"tag":45,"props":59,"children":60},{},[61],{"type":42,"value":62},"Use logistic regression when:",{"type":36,"tag":64,"props":65,"children":66},"ul",{},[67,73,78],{"type":36,"tag":68,"props":69,"children":70},"li",{},[71],{"type":42,"value":72},"Your outcome variable has exactly two categories (0/1, True/False)",{"type":36,"tag":68,"props":74,"children":75},{},[76],{"type":42,"value":77},"You want to understand which predictors increase or decrease the probability of the outcome",{"type":36,"tag":68,"props":79,"children":80},{},[81],{"type":42,"value":82},"You need interpretable coefficients, not just a black-box prediction",{"type":36,"tag":37,"props":84,"children":86},{"id":85},"how-it-works",[87],{"type":42,"value":88},"How It Works",{"type":36,"tag":90,"props":91,"children":92},"ol",{},[93,103,119],{"type":36,"tag":68,"props":94,"children":95},{},[96,101],{"type":36,"tag":51,"props":97,"children":98},{},[99],{"type":42,"value":100},"Upload your data",{"type":42,"value":102}," — CSV or Excel with predictor columns and a binary outcome column",{"type":36,"tag":68,"props":104,"children":105},{},[106,111,113],{"type":36,"tag":51,"props":107,"children":108},{},[109],{"type":42,"value":110},"Describe the model",{"type":42,"value":112}," — e.g. ",{"type":36,"tag":114,"props":115,"children":116},"em",{},[117],{"type":42,"value":118},"\"logistic regression predicting churn (0/1) using tenure, monthly_charges, and contract_type\"",{"type":36,"tag":68,"props":120,"children":121},{},[122,127],{"type":36,"tag":51,"props":123,"children":124},{},[125],{"type":42,"value":126},"Get full results",{"type":42,"value":128}," — coefficients, odds ratios, p-values, confusion matrix, and ROC curve",{"type":36,"tag":45,"props":130,"children":131},{},[132,134,141,143,149],{"type":42,"value":133},"The AI generates Python code using ",{"type":36,"tag":135,"props":136,"children":138},"a",{"href":137},"https://scikit-learn.org/",[139],{"type":42,"value":140},"scikit-learn",{"type":42,"value":142}," and ",{"type":36,"tag":135,"props":144,"children":146},{"href":145},"https://www.statsmodels.org/",[147],{"type":42,"value":148},"statsmodels",{"type":42,"value":150},".",{"type":36,"tag":37,"props":152,"children":154},{"id":153},"interpreting-the-results",[155],{"type":42,"value":156},"Interpreting the Results",{"type":36,"tag":158,"props":159,"children":160},"table",{},[161,180],{"type":36,"tag":162,"props":163,"children":164},"thead",{},[165],{"type":36,"tag":166,"props":167,"children":168},"tr",{},[169,175],{"type":36,"tag":170,"props":171,"children":172},"th",{},[173],{"type":42,"value":174},"Output",{"type":36,"tag":170,"props":176,"children":177},{},[178],{"type":42,"value":179},"What it means",{"type":36,"tag":181,"props":182,"children":183},"tbody",{},[184,201,217,233,249,265],{"type":36,"tag":166,"props":185,"children":186},{},[187,196],{"type":36,"tag":188,"props":189,"children":190},"td",{},[191],{"type":36,"tag":51,"props":192,"children":193},{},[194],{"type":42,"value":195},"Coefficient",{"type":36,"tag":188,"props":197,"children":198},{},[199],{"type":42,"value":200},"Direction of each predictor's effect on the log-odds of the outcome",{"type":36,"tag":166,"props":202,"children":203},{},[204,212],{"type":36,"tag":188,"props":205,"children":206},{},[207],{"type":36,"tag":51,"props":208,"children":209},{},[210],{"type":42,"value":211},"Odds ratio (exp(coef))",{"type":36,"tag":188,"props":213,"children":214},{},[215],{"type":42,"value":216},"Multiplicative change in odds for a one-unit increase in the predictor; OR > 1 increases odds, OR \u003C 1 decreases odds",{"type":36,"tag":166,"props":218,"children":219},{},[220,228],{"type":36,"tag":188,"props":221,"children":222},{},[223],{"type":36,"tag":51,"props":224,"children":225},{},[226],{"type":42,"value":227},"p-value",{"type":36,"tag":188,"props":229,"children":230},{},[231],{"type":42,"value":232},"Statistical significance of each predictor",{"type":36,"tag":166,"props":234,"children":235},{},[236,244],{"type":36,"tag":188,"props":237,"children":238},{},[239],{"type":36,"tag":51,"props":240,"children":241},{},[242],{"type":42,"value":243},"Accuracy",{"type":36,"tag":188,"props":245,"children":246},{},[247],{"type":42,"value":248},"Percentage of correctly classified observations",{"type":36,"tag":166,"props":250,"children":251},{},[252,260],{"type":36,"tag":188,"props":253,"children":254},{},[255],{"type":36,"tag":51,"props":256,"children":257},{},[258],{"type":42,"value":259},"AUC (ROC curve)",{"type":36,"tag":188,"props":261,"children":262},{},[263],{"type":42,"value":264},"Overall discriminative ability of the model; 0.5 = random, 1.0 = perfect",{"type":36,"tag":166,"props":266,"children":267},{},[268,276],{"type":36,"tag":188,"props":269,"children":270},{},[271],{"type":36,"tag":51,"props":272,"children":273},{},[274],{"type":42,"value":275},"Confusion matrix",{"type":36,"tag":188,"props":277,"children":278},{},[279],{"type":42,"value":280},"Breakdown of true positives, false positives, true negatives, false negatives",{"type":36,"tag":37,"props":282,"children":284},{"id":283},"example-prompts",[285],{"type":42,"value":286},"Example Prompts",{"type":36,"tag":158,"props":288,"children":289},{},[290,306],{"type":36,"tag":162,"props":291,"children":292},{},[293],{"type":36,"tag":166,"props":294,"children":295},{},[296,301],{"type":36,"tag":170,"props":297,"children":298},{},[299],{"type":42,"value":300},"Scenario",{"type":36,"tag":170,"props":302,"children":303},{},[304],{"type":42,"value":305},"What to type",{"type":36,"tag":181,"props":307,"children":308},{},[309,327,344,361],{"type":36,"tag":166,"props":310,"children":311},{},[312,317],{"type":36,"tag":188,"props":313,"children":314},{},[315],{"type":42,"value":316},"Customer churn",{"type":36,"tag":188,"props":318,"children":319},{},[320],{"type":36,"tag":321,"props":322,"children":324},"code",{"className":323},[],[325],{"type":42,"value":326},"logistic regression: predict churn using tenure, monthly_charges, and contract_type",{"type":36,"tag":166,"props":328,"children":329},{},[330,335],{"type":36,"tag":188,"props":331,"children":332},{},[333],{"type":42,"value":334},"Loan default",{"type":36,"tag":188,"props":336,"children":337},{},[338],{"type":36,"tag":321,"props":339,"children":341},{"className":340},[],[342],{"type":42,"value":343},"predict default (0/1) from credit_score, income, and loan_amount",{"type":36,"tag":166,"props":345,"children":346},{},[347,352],{"type":36,"tag":188,"props":348,"children":349},{},[350],{"type":42,"value":351},"Medical diagnosis",{"type":36,"tag":188,"props":353,"children":354},{},[355],{"type":36,"tag":321,"props":356,"children":358},{"className":357},[],[359],{"type":42,"value":360},"logistic regression of disease_present on age, bmi, and blood_pressure",{"type":36,"tag":166,"props":362,"children":363},{},[364,369],{"type":36,"tag":188,"props":365,"children":366},{},[367],{"type":42,"value":368},"Pass/fail prediction",{"type":36,"tag":188,"props":370,"children":371},{},[372],{"type":36,"tag":321,"props":373,"children":375},{"className":374},[],[376],{"type":42,"value":377},"predict exam_pass using hours_studied and attendance_rate",{"type":36,"tag":37,"props":379,"children":381},{"id":380},"logistic-vs-linear-regression",[382],{"type":42,"value":383},"Logistic vs. Linear Regression",{"type":36,"tag":158,"props":385,"children":386},{},[387,405],{"type":36,"tag":162,"props":388,"children":389},{},[390],{"type":36,"tag":166,"props":391,"children":392},{},[393,396,401],{"type":36,"tag":170,"props":394,"children":395},{},[],{"type":36,"tag":170,"props":397,"children":398},{},[399],{"type":42,"value":400},"Linear Regression",{"type":36,"tag":170,"props":402,"children":403},{},[404],{"type":42,"value":10},{"type":36,"tag":181,"props":406,"children":407},{},[408,426,443],{"type":36,"tag":166,"props":409,"children":410},{},[411,416,421],{"type":36,"tag":188,"props":412,"children":413},{},[414],{"type":42,"value":415},"Outcome type",{"type":36,"tag":188,"props":417,"children":418},{},[419],{"type":42,"value":420},"Continuous (e.g. price, score)",{"type":36,"tag":188,"props":422,"children":423},{},[424],{"type":42,"value":425},"Binary (e.g. yes/no, 0/1)",{"type":36,"tag":166,"props":427,"children":428},{},[429,433,438],{"type":36,"tag":188,"props":430,"children":431},{},[432],{"type":42,"value":174},{"type":36,"tag":188,"props":434,"children":435},{},[436],{"type":42,"value":437},"Predicted value",{"type":36,"tag":188,"props":439,"children":440},{},[441],{"type":42,"value":442},"Predicted probability (0–1)",{"type":36,"tag":166,"props":444,"children":445},{},[446,451,456],{"type":36,"tag":188,"props":447,"children":448},{},[449],{"type":42,"value":450},"Evaluation metric",{"type":36,"tag":188,"props":452,"children":453},{},[454],{"type":42,"value":455},"R², RMSE",{"type":36,"tag":188,"props":457,"children":458},{},[459],{"type":42,"value":460},"Accuracy, AUC, F1-score",{"type":36,"tag":37,"props":462,"children":464},{"id":463},"frequently-asked-questions",[465],{"type":42,"value":466},"Frequently Asked Questions",{"type":36,"tag":45,"props":468,"children":469},{},[470,475,477,482],{"type":36,"tag":51,"props":471,"children":472},{},[473],{"type":42,"value":474},"Do I need to scale my predictor variables?",{"type":42,"value":476},"\nScaling is not required for interpretation, but it helps convergence and makes coefficients comparable. Ask the AI to ",{"type":36,"tag":114,"props":478,"children":479},{},[480],{"type":42,"value":481},"\"standardize predictors before fitting\"",{"type":42,"value":483}," if you want normalized coefficients.",{"type":36,"tag":45,"props":485,"children":486},{},[487,492,494,499],{"type":36,"tag":51,"props":488,"children":489},{},[490],{"type":42,"value":491},"My outcome is imbalanced — 95% are 0, 5% are 1. What should I do?",{"type":42,"value":493},"\nClass imbalance inflates accuracy but hurts recall on the minority class. Ask the AI to ",{"type":36,"tag":114,"props":495,"children":496},{},[497],{"type":42,"value":498},"\"use class weighting to handle imbalanced classes\"",{"type":42,"value":500}," and evaluate using AUC or F1-score instead of accuracy.",{"type":36,"tag":45,"props":502,"children":503},{},[504,509,511,516],{"type":36,"tag":51,"props":505,"children":506},{},[507],{"type":42,"value":508},"What if I have more than two outcome categories?",{"type":42,"value":510},"\nUse multinomial logistic regression. Ask the AI to ",{"type":36,"tag":114,"props":512,"children":513},{},[514],{"type":42,"value":515},"\"run multinomial logistic regression predicting category using predictors A, B, C\"",{"type":42,"value":150},{"type":36,"tag":45,"props":518,"children":519},{},[520,525,527,532],{"type":36,"tag":51,"props":521,"children":522},{},[523],{"type":42,"value":524},"How do I make predictions for new data?",{"type":42,"value":526},"\nAfter fitting, ask: ",{"type":36,"tag":114,"props":528,"children":529},{},[530],{"type":42,"value":531},"\"predict the probability of churn for tenure=12, monthly_charges=65, contract_type=Month-to-month\"",{"type":42,"value":150},{"title":7,"searchDepth":534,"depth":534,"links":535},2,[536,537,538,539,540,541],{"id":39,"depth":534,"text":43},{"id":85,"depth":534,"text":88},{"id":153,"depth":534,"text":156},{"id":283,"depth":534,"text":286},{"id":380,"depth":534,"text":383},{"id":463,"depth":534,"text":466},"markdown","content:tools:0009.logistic-regression.md","content","tools/0009.logistic-regression.md","tools/0009.logistic-regression","md",{"loc":4},1775502468196]