Binary Classification Models in Machine Learning

Поделиться
HTML-код
  • Опубликовано: 27 авг 2024
  • Read the Dataset
    import pandas as pd
    df=pd.read_csv(path)
    print(df.shape)
    Convert categorical to numerical:
    from sklearn.preprocessing import LabelEncoder
    df[[columns]]=df[columns]].apply(LabelEncoder().fit_transform)
    X and Y
    X=df.iloc[:,:-1]
    Y=df.iloc[:,-1]
    from sklearn.model_selection import train_test_split
    X_train,X_val,Y_train,Y_val=train_test_split(X,Y,test_size=0.2,random_state=42)
    To create more than one model
    models = {} //dictionary
    Logistic Regression
    from sklearn.linear_model import LogisticRegression
    models['Logistic Regression'] = LogisticRegression()
    #similary create other models
    from sklearn.metrics import accuracy_score, precision_score, recall_score
    accuracy, precision, recall = {}, {}, {}
    for key in models.keys():
    Fit the classifier model
    models[key].fit(X_train, Y_train)
    Prediction
    predictions = models[key].predict(X_val)
    Calculate Accuracy, Precision and Recall Metrics
    accuracy[key] = accuracy_score(predictions, Y_val)
    precision[key] = precision_score(predictions, Y_val)
    recall[key] = recall_score(predictions, Y_val)
    Y_predict = models[key].predict(X_val)
    auc = roc_auc_score(Y_val, Y_predict)
    print('Classification Report:',key)
    print(classification_report(Y_val,predictions))
    false_positive_rate, true_positive_rate, thresholds = roc_curve(Y_val, predictions)
    print('ROC_AUC_SCORE is',roc_auc_score(Y_val, predictions))
    #fpr, tpr, _ = roc_curve(y_test, predictions[:,1])
    plt.plot(false_positive_rate, true_positive_rate)
    plt.xlabel('FPR')
    plt.ylabel('TPR')
    plt.title('ROC curve')
    plt.show()
    sns.heatmap(confusion_matrix(Y_val,predictions),fmt='',annot=True) What is a binary classifier in machine learning?
    Binary Classification: In binary classification, the goal is to classify the input into one of two classes or categories. Example - On the basis of the given health conditions of a person, we have to determine whether the person has a certain disease or not.

Комментарии • 12

  • @codewithkhurram313
    @codewithkhurram313 3 месяца назад +1

    Its 5.08 AM and today is my midterm exam and our AI teacher teaches us by copying the lectures of Stanford university. He didn't even tell us that Logistic Regression ,..... Neutral Networks are algorithms used for Binary Classification. And he is going to give us problems in exams related to all these. But thanks for showing us how things are practically done.

  • @yashodharpathak189
    @yashodharpathak189 Месяц назад

    Thanks for the wonderful video mam! I have a doubt. Do we require to do feature scaling of all numerical variables before fitting the models or these models take care of it automatically?

    • @investime247
      @investime247  Месяц назад

      Need to do for all numerical variables

  • @larbi-belaissaoui
    @larbi-belaissaoui 2 месяца назад

    THANKS YOU FOR THIS

  • @Go-yg9rg
    @Go-yg9rg 8 месяцев назад

    predictions = models[key].predict(X_val)
    Y_predict = models[key].predict(X_val)
    why do you use two variable, acctully are same ?

  • @fireninjagaming2499
    @fireninjagaming2499 3 месяца назад

    Dataset need him mam please share you mam

  • @rajeshvermarehariya7299
    @rajeshvermarehariya7299 5 месяцев назад +1

    Mam please share the link of colab

  • @mudhassir.
    @mudhassir. Месяц назад

    Hi mam enakku DL la orusila doubts irukku mam
    Unga insta id kudunga mam
    Naa voice note mooliyama explain panren. Enakku help pannunga mam please mam please

    • @investime247
      @investime247  Месяц назад

      Hema_david2510

    • @mudhassir.
      @mudhassir. Месяц назад

      @@investime247 mam insta la ping pannirukken paarunga mam pls

    • @mudhassir.
      @mudhassir. Месяц назад

      @@investime247 mam insta la msg pannirukken. Please reply pannunga mam