How to Plot an ROC Curve in Python | Machine Learning in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น • 81

  • @myyoutubeaccount4537
    @myyoutubeaccount4537 4 ปีที่แล้ว +6

    Really clean code. I read it and understood immediately all of it. I was only bothered by the X,Y instead of the more conventional X,y.

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Thanks for watching and for the comments 😃

  • @jasonlu3603
    @jasonlu3603 3 ปีที่แล้ว +4

    Thank you, been struggling for a couple of days (after even using the sklearn library example) to understand ROC curve for data mining / machine learning class.

    • @DataProfessor
      @DataProfessor  3 ปีที่แล้ว +1

      Awesome, hope it worked out.

  • @latte-carnival9964
    @latte-carnival9964 4 ปีที่แล้ว +4

    Watching this trying to get through my internship because they expect us to know all this stuff I guess lol. Thanks brah.

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Thanks Robin for watching, good luck in the internship 👍

  • @yassir_b
    @yassir_b 2 ปีที่แล้ว

    Your code is so well organized and clean. Thank you very much!

  • @luciferkhusrao
    @luciferkhusrao 4 ปีที่แล้ว +2

    Awesome content. I wish you get a million subscribers within 1 year

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      Wow, thanks for the kind wishes 😃

  • @ishmamhussainkhan1217
    @ishmamhussainkhan1217 4 ปีที่แล้ว +2

    Sir with help of this i can predict knn auc score but after that when i write
    r_fpr, r_tpr, _ = roc_curve(y_test, r_probs)
    the above code shows error "y_true takes value in {'Abnormal', 'Normal'} and pos_label is not specified: either make y_true take value in {0, 1} or {-1, 1} or pass pos_label explicitly"
    how do i solve it

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Hi Ishmam, I've modified the Jupyter notebook described in the video tutorial to also include knn and it is available on the Data Professor GitHub at github.com/dataprofessor/code/blob/master/python/ROC_curve_kNN.ipynb

    • @ishmamhussainkhan1217
      @ishmamhussainkhan1217 4 ปีที่แล้ว

      @@DataProfessor Sir i actually i did exactly like that and after that i got the error.I was actually reading data with pandas from a csv file.i also used label encoder to ensure there are no strings and still after that got the error.

  • @debanjansen1282
    @debanjansen1282 ปีที่แล้ว

    How to do that for molecular docking ligand enrichment study.. I have 2 csv files. One contains docking score of true inhibitors and another decoy inhibitors. Plz guide

  • @atulsingh978
    @atulsingh978 2 ปีที่แล้ว +1

    Thank you so much😊😊😊😊

  • @NectX
    @NectX 3 ปีที่แล้ว +2

    THANK YOU SO MUCH FOR THE HELP!

  • @farhadkhan3893
    @farhadkhan3893 2 ปีที่แล้ว +1

    Thank you for encouraging , tutorial is very good

  • @analuciademoraislimalucial6039
    @analuciademoraislimalucial6039 3 ปีที่แล้ว +2

    Thanks thanks thanks. I love this chanel

    • @DataProfessor
      @DataProfessor  3 ปีที่แล้ว

      Glad you enjoyed the contents here! Would greatly appreciate if you could spread the word, Thanks!

  • @scoopoftheworld988
    @scoopoftheworld988 3 ปีที่แล้ว +2

    Thank you very much sir. Bless you

  • @XxGothicfanxX
    @XxGothicfanxX 4 ปีที่แล้ว +2

    Thank you for explaining and showing it!

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      A pleasure. Glad it was helpful!

  • @Teresap151
    @Teresap151 4 ปีที่แล้ว +2

    Great job! Thank you for making it simple.

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      A pleasure! Thanks for watching!

  • @ShibbirTalks
    @ShibbirTalks 3 ปีที่แล้ว

    IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed --- I got this error while using for my code. plz tell the solution

  • @santhoship9084
    @santhoship9084 3 ปีที่แล้ว +2

    may god bless you. This video really saved me ^ _ ^

    • @DataProfessor
      @DataProfessor  3 ปีที่แล้ว

      I'm so glad! Thanks for watching!

  • @amrutaavibho444
    @amrutaavibho444 2 ปีที่แล้ว +1

    Thank you! Very incredibly helpful, sir :)

  • @shibbirahmed7929
    @shibbirahmed7929 3 ปีที่แล้ว +2

    Thanks for this informative video. Sir, I have a question. If I want to apply this code to display roc curve of ML models for five different class of sentiments, what should be included in this code? please reply as quickly as possible.

    • @DataProfessor
      @DataProfessor  3 ปีที่แล้ว

      Thanks for watching, for different class labels, you can check out this code example and adapt for your project scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html#plot-roc-curves-for-the-multilabel-problem

  • @gdpraveenkumar823
    @gdpraveenkumar823 3 ปีที่แล้ว

    How to create this type of chart in .CSV file in matplot library ? Is possible means share the link

  • @waltonhouse4692
    @waltonhouse4692 4 ปีที่แล้ว +3

    Amazing! Thank You!

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Walton, Thanks for the kind words!

  • @Ash-bc8vw
    @Ash-bc8vw 3 ปีที่แล้ว

    Guys I found the threshold , its 0.8 for random forest now how do I make the necessary changes in my model?

  • @uisenough
    @uisenough 4 ปีที่แล้ว +3

    thank you for the video.
    I got this error while plotting:
    ValueError: multi_class must be in ('ovo', 'ovr').
    What can I do. And is roc is only valid for data with 2 class labels?

  • @aguyfromparalleluniverse
    @aguyfromparalleluniverse 2 ปีที่แล้ว +1

    thankyou sooo much sir

  • @shraddha9066
    @shraddha9066 4 ปีที่แล้ว +2

    Hey , Very informitive and helping video. I have one doubt though, does the Y attribute for KNN classification need to be binary in order to plot in roc curve?

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Yes, the Y needs to be qualitative/categorical labels for ROC to work.

  • @HimaniChauhan
    @HimaniChauhan 4 ปีที่แล้ว +1

    what to do if predict_proba is not available when probability=false

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Can you try setting probability=True

    • @HimaniChauhan
      @HimaniChauhan 4 ปีที่แล้ว +1

      @@DataProfessor sir is svm doesn't support this function predict_proba and can I use dataset which I can read in python that is CSV file instead of synthetic dataset to generate roc curve

    • @HimaniChauhan
      @HimaniChauhan 4 ปีที่แล้ว

      @@DataProfessor sir is svm doesn't support this function predict_proba and can I use dataset which I can read in python that is CSV file instead of synthetic dataset to generate roc curve

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      @@HimaniChauhan There is a workaround that may work. Can you have a look at this link: www.kaggle.com/c/home-credit-default-risk/discussion/63499

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      @@HimaniChauhan To use CSV file instead of synthetic dataset, you can read it in using:
      import pandas as pd
      df = pd.read_csv("data.csv")
      X = df.iloc[:,:-1]
      Y = df.iloc[:,-1]
      You can then use X and Y as your input argument for model building

  • @sameerbairwa3718
    @sameerbairwa3718 4 ปีที่แล้ว

    can i plot roc curve from saved model ?

  • @farhadkhan6087
    @farhadkhan6087 2 ปีที่แล้ว +1

    Thank you Sir

  • @pa4761
    @pa4761 4 ปีที่แล้ว

    There's only 6 thresholds from roc_curve function, how can I add more?

  • @goodsms1730
    @goodsms1730 4 ปีที่แล้ว

    I got an error
    ValueError: could not convert string to float: 'data'
    How can you help?

  • @christianespana1
    @christianespana1 4 ปีที่แล้ว +2

    I want to ask you a favor. can you explain how to plot ROC curve using Image Generator(flow from directory) in classification multi classes?

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      Hi, please refer to this for coding example scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html?highlight=roc#plot-roc-curves-for-the-multilabel-problem

  • @aggorjefferson8308
    @aggorjefferson8308 ปีที่แล้ว

    Thank you so much!

  • @magicpoom1
    @magicpoom1 4 ปีที่แล้ว +1

    Thanks you for video. Could your please suggest a book or video about machine leaning to learn?

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      Warawat, thanks for your comment. For the moment, I recommend the following 2 books. For the principles, I would recommend "The hundred-page machine learning book" themlbook.com/ For practice, I recommend the "Python Data Science Handbook" jakevdp.github.io/PythonDataScienceHandbook/

    • @shwetaredkar734
      @shwetaredkar734 4 ปีที่แล้ว +1

      @@DataProfessor Thank you for suggesting the books.

  • @farissariski8082
    @farissariski8082 4 ปีที่แล้ว +1

    can i plot ROC with confusion matrix only?

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      I would plot the ROC and show the confusion matrix as a table.

    • @prajwol_poudel
      @prajwol_poudel 2 ปีที่แล้ว

      No, you'll need the probabilities your model assigns for the classes and the actual class to plot the roc curve.

  • @subashchandrapakhrin3537
    @subashchandrapakhrin3537 4 ปีที่แล้ว +2

    Thank You

  • @pentagon3218
    @pentagon3218 3 ปีที่แล้ว

    Sir I am new to this field.
    I want to know the meaning of these codes.
    r_probs = [0 for _ in range(len(Y_test))]
    rf_probs = rf.predict_proba(X_test)
    nb_probs = nb.predict_proba(X_test)
    Is there any other way of writing this?

    • @pentagon3218
      @pentagon3218 3 ปีที่แล้ว

      I want to know how to apply it in real dataset available out there in the internet. Thank you and sorry for my lack of knowledge.

  • @HellRaiZOR13
    @HellRaiZOR13 4 ปีที่แล้ว +2

    Nice video

  • @sageguru3654
    @sageguru3654 3 ปีที่แล้ว +1

    Good Evening sir, I just want to know how to adjust cut off / threshold of a logistic regression model. Thank you, So much sir.

    • @DataProfessor
      @DataProfessor  3 ปีที่แล้ว +1

      Hi, I believe the answer you're looking for lies in this Stack Overflow post stackoverflow.com/questions/19984957/scikit-learn-predict-default-threshold?rq=1

  • @shwetaredkar734
    @shwetaredkar734 4 ปีที่แล้ว +1

    Could you please show the same example using 10 fold-cv instead of train test split. Thanks

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      Thanks Shweta for the suggestion. I will make a video shortly.

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      I’m working on making a Jupyter notebook of it, I’ll paste the link here when I’m finished

    • @shwetaredkar734
      @shwetaredkar734 4 ปีที่แล้ว +1

      @@DataProfessor Okay. Thank you. Also, if possible please educate us on how to test an independent/external dataset on the trained model.

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      @@shwetaredkar734 Sure, I've previously made a video and drawn an infographic on the overview of machine learning model building. Explanation on the external set (test set) is also provided. th-cam.com/video/BOk1hlCPW0c/w-d-xo.html

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว +1

      @@shwetaredkar734 Thanks for your comment. To apply the trained model to make prediction on the class label using clf.predict(X_test). Please see one of the recent video th-cam.com/video/XmSlFPDjKdc/w-d-xo.html

  • @lakpatamang2866
    @lakpatamang2866 4 ปีที่แล้ว

    how to plot false negative rate with false positive rate?

  • @viveknair9917
    @viveknair9917 4 ปีที่แล้ว

    How to plot a ROC curve using qPCR data?

  • @varunpathak6109
    @varunpathak6109 4 ปีที่แล้ว +1

    Can we make a forest plot???????????

    • @DataProfessor
      @DataProfessor  4 ปีที่แล้ว

      Yes you can, check out the pythonmeta library (pip install PythonMeta) which allows you to make forest plot
      You can also try making one using their web demo pymeta.com/

  • @angelomaurodiez4713
    @angelomaurodiez4713 2 ปีที่แล้ว

    I LOVE YOU

  • @vatsk
    @vatsk 2 ปีที่แล้ว

    Are you dutch?