When to question output of modelFind effective feature on machine learning classification task with scikit-learnClassifying Email in RUsage of Precision Recall on an unbalanced datasetHow to quantify the performance of the classifier (multi-class SVM) using the test data?Precision and Recall if not binaryPoor performance of SVM after training for rare eventsPoor performance for unbalanced datasetHow to calculate Accuracy, Precision, Recall and F1 score based on predict_proba matrix?How to get accuracy, F1, precision and recall, for a keras model?Improve precision of binary classification - SVM in Matlab

Can disgust be a key component of horror?

creating a ":KeepCursor" command

Does the UK parliament need to pass secondary legislation to accept the Article 50 extension

How should I address a possible mistake to co-authors in a submitted paper

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

Why is it that I can sometimes guess the next note?

Biological Blimps: Propulsion

Plot of a tornado-shaped surface

Quasinilpotent , non-compact operators

Can a college of swords bard use blade flourish on an OA from dissonant whispers?

Why would a new[] expression ever invoke a destructor?

Why can Carol Danvers change her suit colours in the first place?

What if you are holding an Iron Flask with a demon inside and walk into Antimagic Field?

How do apertures which seem too large to physically fit work?

Why does the Sun have different day lengths, but not the gas giants?

How to hide some fields of struct in C?

When were female captains banned from Starfleet?

System.QueryException unexpected token

Creepy dinosaur pc game identification

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Probability that THHT occurs in a sequence of 10 coin tosses

How much character growth crosses the line into breaking the character

Angel of Condemnation - Exile creature with second ability

Redundant comparison & "if" before assignment



When to question output of model


Find effective feature on machine learning classification task with scikit-learnClassifying Email in RUsage of Precision Recall on an unbalanced datasetHow to quantify the performance of the classifier (multi-class SVM) using the test data?Precision and Recall if not binaryPoor performance of SVM after training for rare eventsPoor performance for unbalanced datasetHow to calculate Accuracy, Precision, Recall and F1 score based on predict_proba matrix?How to get accuracy, F1, precision and recall, for a keras model?Improve precision of binary classification - SVM in Matlab













0












$begingroup$


I'm unsure of how to ask a question without making it seem like a code review question. At what point does one question whether they've actually implemented the algorithm and-or model correctly? Getting spot-on results is great and all, but seems highly suspect. Also, what checks can be done to ensure that the algorithm and-or model is being implemented correctly? The reason I'm asking is because I'm getting perfect classification and subsequently accuracy, precision, etc. w/ the implementation of SVM.



I am including the code, but feel free to ignore.



# Make a copy of the df
iris_df_copy = iris_df.copy()

# Create a new column, labeled 'T/F', whose value will be based on the value in the 'Class' column. If the value in the
# 'Class' column is 'Iris-setosa', then set the value of the 'T/F' column to 1. If the value in the 'Class' column is
# not 'Iris-setosa', then set the value of the 'T/F' column to 0.
iris_df_copy.loc[iris_df_copy.Class == 'Iris-setosa', 'T/F'] = 1
iris_df_copy.loc[iris_df_copy.Class != 'Iris-setosa', 'T/F'] = 0

X_svm = np.array(iris_df_copy[['Sepal_Length', 'Sepal_Width', 'Petal_Length', 'Petal_Width']])
y_svm = np.ravel(iris_df_copy[['T/F']])

# Split the samples into two subsets, use one for training and the other for testing
X_train_svm, X_test_svm, y_train_svm, y_test_svm = train_test_split(X_svm, y_svm, test_size=0.25, random_state=4)

# Instantiate the learning model - Linear SVM
linear_svm = svm.SVC(kernel='linear')

# Fit the model - Linear SVM
linear_svm.fit(X_train_svm, y_train_svm)

# Predict the response - Linear SVM
linear_svm_pred = linear_svm.predict(X_test_svm)

# Confusion matrix and quantitative metrics - Linear SVM
print("The confusion matrix is: " + np.str(confusion_matrix(y_test_svm, linear_svm_pred)))
print("The accuracy score is: " + np.str(accuracy_score(y_test_svm, linear_svm_pred)))
print("The precision is: " + np.str(precision_score(y_test_svm, linear_svm_pred, average="macro")))
print("The recall is: " + np.str(recall_score(y_test_svm, linear_svm_pred, average="macro")))










share|improve this question







New contributor




user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    0












    $begingroup$


    I'm unsure of how to ask a question without making it seem like a code review question. At what point does one question whether they've actually implemented the algorithm and-or model correctly? Getting spot-on results is great and all, but seems highly suspect. Also, what checks can be done to ensure that the algorithm and-or model is being implemented correctly? The reason I'm asking is because I'm getting perfect classification and subsequently accuracy, precision, etc. w/ the implementation of SVM.



    I am including the code, but feel free to ignore.



    # Make a copy of the df
    iris_df_copy = iris_df.copy()

    # Create a new column, labeled 'T/F', whose value will be based on the value in the 'Class' column. If the value in the
    # 'Class' column is 'Iris-setosa', then set the value of the 'T/F' column to 1. If the value in the 'Class' column is
    # not 'Iris-setosa', then set the value of the 'T/F' column to 0.
    iris_df_copy.loc[iris_df_copy.Class == 'Iris-setosa', 'T/F'] = 1
    iris_df_copy.loc[iris_df_copy.Class != 'Iris-setosa', 'T/F'] = 0

    X_svm = np.array(iris_df_copy[['Sepal_Length', 'Sepal_Width', 'Petal_Length', 'Petal_Width']])
    y_svm = np.ravel(iris_df_copy[['T/F']])

    # Split the samples into two subsets, use one for training and the other for testing
    X_train_svm, X_test_svm, y_train_svm, y_test_svm = train_test_split(X_svm, y_svm, test_size=0.25, random_state=4)

    # Instantiate the learning model - Linear SVM
    linear_svm = svm.SVC(kernel='linear')

    # Fit the model - Linear SVM
    linear_svm.fit(X_train_svm, y_train_svm)

    # Predict the response - Linear SVM
    linear_svm_pred = linear_svm.predict(X_test_svm)

    # Confusion matrix and quantitative metrics - Linear SVM
    print("The confusion matrix is: " + np.str(confusion_matrix(y_test_svm, linear_svm_pred)))
    print("The accuracy score is: " + np.str(accuracy_score(y_test_svm, linear_svm_pred)))
    print("The precision is: " + np.str(precision_score(y_test_svm, linear_svm_pred, average="macro")))
    print("The recall is: " + np.str(recall_score(y_test_svm, linear_svm_pred, average="macro")))










    share|improve this question







    New contributor




    user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      0












      0








      0





      $begingroup$


      I'm unsure of how to ask a question without making it seem like a code review question. At what point does one question whether they've actually implemented the algorithm and-or model correctly? Getting spot-on results is great and all, but seems highly suspect. Also, what checks can be done to ensure that the algorithm and-or model is being implemented correctly? The reason I'm asking is because I'm getting perfect classification and subsequently accuracy, precision, etc. w/ the implementation of SVM.



      I am including the code, but feel free to ignore.



      # Make a copy of the df
      iris_df_copy = iris_df.copy()

      # Create a new column, labeled 'T/F', whose value will be based on the value in the 'Class' column. If the value in the
      # 'Class' column is 'Iris-setosa', then set the value of the 'T/F' column to 1. If the value in the 'Class' column is
      # not 'Iris-setosa', then set the value of the 'T/F' column to 0.
      iris_df_copy.loc[iris_df_copy.Class == 'Iris-setosa', 'T/F'] = 1
      iris_df_copy.loc[iris_df_copy.Class != 'Iris-setosa', 'T/F'] = 0

      X_svm = np.array(iris_df_copy[['Sepal_Length', 'Sepal_Width', 'Petal_Length', 'Petal_Width']])
      y_svm = np.ravel(iris_df_copy[['T/F']])

      # Split the samples into two subsets, use one for training and the other for testing
      X_train_svm, X_test_svm, y_train_svm, y_test_svm = train_test_split(X_svm, y_svm, test_size=0.25, random_state=4)

      # Instantiate the learning model - Linear SVM
      linear_svm = svm.SVC(kernel='linear')

      # Fit the model - Linear SVM
      linear_svm.fit(X_train_svm, y_train_svm)

      # Predict the response - Linear SVM
      linear_svm_pred = linear_svm.predict(X_test_svm)

      # Confusion matrix and quantitative metrics - Linear SVM
      print("The confusion matrix is: " + np.str(confusion_matrix(y_test_svm, linear_svm_pred)))
      print("The accuracy score is: " + np.str(accuracy_score(y_test_svm, linear_svm_pred)))
      print("The precision is: " + np.str(precision_score(y_test_svm, linear_svm_pred, average="macro")))
      print("The recall is: " + np.str(recall_score(y_test_svm, linear_svm_pred, average="macro")))










      share|improve this question







      New contributor




      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I'm unsure of how to ask a question without making it seem like a code review question. At what point does one question whether they've actually implemented the algorithm and-or model correctly? Getting spot-on results is great and all, but seems highly suspect. Also, what checks can be done to ensure that the algorithm and-or model is being implemented correctly? The reason I'm asking is because I'm getting perfect classification and subsequently accuracy, precision, etc. w/ the implementation of SVM.



      I am including the code, but feel free to ignore.



      # Make a copy of the df
      iris_df_copy = iris_df.copy()

      # Create a new column, labeled 'T/F', whose value will be based on the value in the 'Class' column. If the value in the
      # 'Class' column is 'Iris-setosa', then set the value of the 'T/F' column to 1. If the value in the 'Class' column is
      # not 'Iris-setosa', then set the value of the 'T/F' column to 0.
      iris_df_copy.loc[iris_df_copy.Class == 'Iris-setosa', 'T/F'] = 1
      iris_df_copy.loc[iris_df_copy.Class != 'Iris-setosa', 'T/F'] = 0

      X_svm = np.array(iris_df_copy[['Sepal_Length', 'Sepal_Width', 'Petal_Length', 'Petal_Width']])
      y_svm = np.ravel(iris_df_copy[['T/F']])

      # Split the samples into two subsets, use one for training and the other for testing
      X_train_svm, X_test_svm, y_train_svm, y_test_svm = train_test_split(X_svm, y_svm, test_size=0.25, random_state=4)

      # Instantiate the learning model - Linear SVM
      linear_svm = svm.SVC(kernel='linear')

      # Fit the model - Linear SVM
      linear_svm.fit(X_train_svm, y_train_svm)

      # Predict the response - Linear SVM
      linear_svm_pred = linear_svm.predict(X_test_svm)

      # Confusion matrix and quantitative metrics - Linear SVM
      print("The confusion matrix is: " + np.str(confusion_matrix(y_test_svm, linear_svm_pred)))
      print("The accuracy score is: " + np.str(accuracy_score(y_test_svm, linear_svm_pred)))
      print("The precision is: " + np.str(precision_score(y_test_svm, linear_svm_pred, average="macro")))
      print("The recall is: " + np.str(recall_score(y_test_svm, linear_svm_pred, average="macro")))







      machine-learning scikit-learn svm






      share|improve this question







      New contributor




      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 15 mins ago









      user3727648user3727648

      1




      1




      New contributor




      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      user3727648 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "557"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          user3727648 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47814%2fwhen-to-question-output-of-model%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          user3727648 is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          user3727648 is a new contributor. Be nice, and check out our Code of Conduct.












          user3727648 is a new contributor. Be nice, and check out our Code of Conduct.











          user3727648 is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47814%2fwhen-to-question-output-of-model%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown