To develop machine learning models using patient and migraine features that can predict treatment responses to commonly used migraine preventive medications. Currently, there is no accurate way to predict response to migraine preventive medications, and the standard trial-and-error approach is inefficient. In this cohort study, we analyzed data from the Mayo Clinic Headache database prospectively collected from 2001 to December 2023. Adult patients with migraine completed questionnaires during their initial headache consultation to record detailed clinical features and then at each follow-up to track preventive medication changes and monthly headache days. We included patients treated with at least one of the following migraine preventive medications: topiramate, beta-blockers (propranolol, metoprolol, atenolol, nadolol, timolol), tricyclic antidepressants (amitriptyline, nortriptyline), verapamil, gabapentin, onabotulinumtoxinA, and calcitonin gene-related peptide (CGRP) monoclonal antibodies (mAbs) (erenumab, fremanezumab, galcanezumab, eptinezumab). We pre-trained a deep neural network, "TabNet," using 145 variables, then employed TabNet-embedded data to construct prediction models for each medication to predict binary outcomes (responder vs. non-responder). A treatment responder was defined as having at least a 30% reduction in monthly headache days from baseline. All model performances were evaluated, and metrics were reported in the held-out test set (train 85%, test 15%). SHapley Additive exPlanations (SHAP) were conducted to determine variable importance. Our final analysis included 4260 patients. The responder rate for each medication ranged from 28.7% to 34.9%, and the mean time to treatment outcome for each medication ranged from 151.3 to 209.5 days. The CGRP mAb prediction model achieved a high area under the receiver operating characteristics curve (AUC) of 0.825 (95% confidence interval [CI] 0.726, 0.920) and an accuracy of 0.80 (95% CI 0.70, 0.88). The AUCs of prediction models for beta-blockers, tricyclic antidepressants, topiramate, verapamil, gabapentin, and onabotulinumtoxinA were: 0.664 (95% CI 0.579, 0.745), 0.611 (95% CI 0.562, 0.682), 0.605 (95% CI 0.520, 0.688), 0.673 (95% CI 0.569, 0.724), 0.628 (0.533, 0.661), and 0.581 (95% CI 0.550, 0.632), respectively. Baseline monthly headache days, age, body mass index (BMI), duration of migraine attacks, responses to previous medication trials, cranial autonomic symptoms, family history of headache, and migraine attack triggers were among the most important variables across all models. A variable could have different contributions; for example, lower BMI predicts responsiveness to CGRP mAbs and beta-blockers, while higher BMI predicts responsiveness to onabotulinumtoxinA, topiramate, and gabapentin. We developed an accurate prediction model for CGRP mAbs treatment response, leveraging detailed migraine features gathered from a headache questionnaire before starting treatment. Employing the same methods, the model performances for other medications were less impressive, though similar to the machine learning models reported in the literature for other diseases. This may be due to CGRP mAbs being migraine-specific. Incorporating medical comorbidities, genomic, and imaging factors might enhance the model performance. We demonstrated that migraine characteristics are important in predicting treatment responses and identified the most crucial predictors for each of the seven types of preventive medications. Our results suggest that precision migraine treatment is feasible.