Is this a data issue, or a model issue? A Keras binary classification model Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election ResultsConvolution Neural Network Loss and performanceTensorflow regression predicting 1 for all inputsNeural network accuracy for simple classificationSimple prediction with KerasValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (0,)How to set input for proper fit with lstm?Xor gate accuracy improvementIs my model over-fitting (LSTM,GRU)Value error in Merging two different models in kerasIN CIFAR 10 DATASET

Multi tool use
Multi tool use

How to find out what spells would be useless to a blind NPC spellcaster?

Coloring maths inside a tcolorbox

How come Sam didn't become Lord of Horn Hill?

String `!23` is replaced with `docker` in command line

Why do people hide their license plates in the EU?

What's the purpose of writing one's academic biography in the third person?

What LEGO pieces have "real-world" functionality?

What is the role of the transistor and diode in a soft start circuit?

How to answer "Have you ever been terminated?"

Echoing a tail command produces unexpected output?

How does debian/ubuntu knows a package has a updated version

What is the meaning of the new sigil in Game of Thrones Season 8 intro?

What is Arya's weapon design?

Generate an RGB colour grid

Why didn't this character "real die" when they blew their stack out in Altered Carbon?

English words in a non-english sci-fi novel

Book where humans were engineered with genes from animal species to survive hostile planets

How discoverable are IPv6 addresses and AAAA names by potential attackers?

At the end of Thor: Ragnarok why don't the Asgardians turn and head for the Bifrost as per their original plan?

Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?

Why did the rest of the Eastern Bloc not invade Yugoslavia?

Why are Kinder Surprise Eggs illegal in the USA?

Can a USB port passively 'listen only'?

When were vectors invented?



Is this a data issue, or a model issue? A Keras binary classification model



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election ResultsConvolution Neural Network Loss and performanceTensorflow regression predicting 1 for all inputsNeural network accuracy for simple classificationSimple prediction with KerasValueError: Error when checking target: expected dense_2 to have shape (1,) but got array with shape (0,)How to set input for proper fit with lstm?Xor gate accuracy improvementIs my model over-fitting (LSTM,GRU)Value error in Merging two different models in kerasIN CIFAR 10 DATASET










0












$begingroup$


I've been trying to create a binary classification model that predicts wether there will be a train delay based on the train and time. Here is a link to the data



The issue I'm having is that my accuracy goes to 94.07 in the first 5 epochs. Meanwhile, my class prediction will always be 0 and never 1.



From what I understand, this is "Accuracy Paradox". A symptom of Class Imbalance. To combat this, I implemented Kfold.



kfold = StratifiedKFold(n_splits=10,shuffle=True)
cvs_scores = []

for train,test in kfold.split(X,Y):

history = model.fit(X[train],Y[train],epochs=50,batch_size=15, shuffle = False, verbose = 1)
scores = model.evaluate(X[test],Y[test],verbose=0)

print("%s: %.2f%%" % (model.metrics_names[1],scores[1]*100))
cvs_scores.append(scores[1] * 100)

print("%.2f%% (+/- %.2f%%)" % (numpy.mean(cvs_scores),numpy.std(cvs_scores)))


No luck. Still had the same issue as before.



Here is how I import my data:



raw_data = pd.read_csv('MTA_DELAY_DATA_DUMP - Sheet1.csv')

X = raw_data.iloc[1:-2,0:2].dropna().values
Y = raw_data.iloc[1:-2,2:3].dropna().astype(int).values


My Model:



model = Sequential()
model.add(Dense(32, kernel_initializer='uniform', activation='relu',input_dim =2))
model.add(Dense(16, kernel_initializer='uniform', activation='relu'))
model.add(Dense(8, kernel_initializer='uniform', activation='relu'))
model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))

model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.001),metrics=['accuracy'])
history = model.fit(X,Y,epochs=150,batch_size=15, shuffle = False, verbose = 1)


I tried assigning class weights to balance the data out. Even manually deleting 0's in the data, but nothing seems to result in accurate predictions. Am I doing something wrong in the model, or is this simply data that cannot be utilized by machine learning?









share







New contributor




PavlovsCat 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've been trying to create a binary classification model that predicts wether there will be a train delay based on the train and time. Here is a link to the data



    The issue I'm having is that my accuracy goes to 94.07 in the first 5 epochs. Meanwhile, my class prediction will always be 0 and never 1.



    From what I understand, this is "Accuracy Paradox". A symptom of Class Imbalance. To combat this, I implemented Kfold.



    kfold = StratifiedKFold(n_splits=10,shuffle=True)
    cvs_scores = []

    for train,test in kfold.split(X,Y):

    history = model.fit(X[train],Y[train],epochs=50,batch_size=15, shuffle = False, verbose = 1)
    scores = model.evaluate(X[test],Y[test],verbose=0)

    print("%s: %.2f%%" % (model.metrics_names[1],scores[1]*100))
    cvs_scores.append(scores[1] * 100)

    print("%.2f%% (+/- %.2f%%)" % (numpy.mean(cvs_scores),numpy.std(cvs_scores)))


    No luck. Still had the same issue as before.



    Here is how I import my data:



    raw_data = pd.read_csv('MTA_DELAY_DATA_DUMP - Sheet1.csv')

    X = raw_data.iloc[1:-2,0:2].dropna().values
    Y = raw_data.iloc[1:-2,2:3].dropna().astype(int).values


    My Model:



    model = Sequential()
    model.add(Dense(32, kernel_initializer='uniform', activation='relu',input_dim =2))
    model.add(Dense(16, kernel_initializer='uniform', activation='relu'))
    model.add(Dense(8, kernel_initializer='uniform', activation='relu'))
    model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))

    model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.001),metrics=['accuracy'])
    history = model.fit(X,Y,epochs=150,batch_size=15, shuffle = False, verbose = 1)


    I tried assigning class weights to balance the data out. Even manually deleting 0's in the data, but nothing seems to result in accurate predictions. Am I doing something wrong in the model, or is this simply data that cannot be utilized by machine learning?









    share







    New contributor




    PavlovsCat 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've been trying to create a binary classification model that predicts wether there will be a train delay based on the train and time. Here is a link to the data



      The issue I'm having is that my accuracy goes to 94.07 in the first 5 epochs. Meanwhile, my class prediction will always be 0 and never 1.



      From what I understand, this is "Accuracy Paradox". A symptom of Class Imbalance. To combat this, I implemented Kfold.



      kfold = StratifiedKFold(n_splits=10,shuffle=True)
      cvs_scores = []

      for train,test in kfold.split(X,Y):

      history = model.fit(X[train],Y[train],epochs=50,batch_size=15, shuffle = False, verbose = 1)
      scores = model.evaluate(X[test],Y[test],verbose=0)

      print("%s: %.2f%%" % (model.metrics_names[1],scores[1]*100))
      cvs_scores.append(scores[1] * 100)

      print("%.2f%% (+/- %.2f%%)" % (numpy.mean(cvs_scores),numpy.std(cvs_scores)))


      No luck. Still had the same issue as before.



      Here is how I import my data:



      raw_data = pd.read_csv('MTA_DELAY_DATA_DUMP - Sheet1.csv')

      X = raw_data.iloc[1:-2,0:2].dropna().values
      Y = raw_data.iloc[1:-2,2:3].dropna().astype(int).values


      My Model:



      model = Sequential()
      model.add(Dense(32, kernel_initializer='uniform', activation='relu',input_dim =2))
      model.add(Dense(16, kernel_initializer='uniform', activation='relu'))
      model.add(Dense(8, kernel_initializer='uniform', activation='relu'))
      model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))

      model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.001),metrics=['accuracy'])
      history = model.fit(X,Y,epochs=150,batch_size=15, shuffle = False, verbose = 1)


      I tried assigning class weights to balance the data out. Even manually deleting 0's in the data, but nothing seems to result in accurate predictions. Am I doing something wrong in the model, or is this simply data that cannot be utilized by machine learning?









      share







      New contributor




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







      $endgroup$




      I've been trying to create a binary classification model that predicts wether there will be a train delay based on the train and time. Here is a link to the data



      The issue I'm having is that my accuracy goes to 94.07 in the first 5 epochs. Meanwhile, my class prediction will always be 0 and never 1.



      From what I understand, this is "Accuracy Paradox". A symptom of Class Imbalance. To combat this, I implemented Kfold.



      kfold = StratifiedKFold(n_splits=10,shuffle=True)
      cvs_scores = []

      for train,test in kfold.split(X,Y):

      history = model.fit(X[train],Y[train],epochs=50,batch_size=15, shuffle = False, verbose = 1)
      scores = model.evaluate(X[test],Y[test],verbose=0)

      print("%s: %.2f%%" % (model.metrics_names[1],scores[1]*100))
      cvs_scores.append(scores[1] * 100)

      print("%.2f%% (+/- %.2f%%)" % (numpy.mean(cvs_scores),numpy.std(cvs_scores)))


      No luck. Still had the same issue as before.



      Here is how I import my data:



      raw_data = pd.read_csv('MTA_DELAY_DATA_DUMP - Sheet1.csv')

      X = raw_data.iloc[1:-2,0:2].dropna().values
      Y = raw_data.iloc[1:-2,2:3].dropna().astype(int).values


      My Model:



      model = Sequential()
      model.add(Dense(32, kernel_initializer='uniform', activation='relu',input_dim =2))
      model.add(Dense(16, kernel_initializer='uniform', activation='relu'))
      model.add(Dense(8, kernel_initializer='uniform', activation='relu'))
      model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))

      model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.001),metrics=['accuracy'])
      history = model.fit(X,Y,epochs=150,batch_size=15, shuffle = False, verbose = 1)


      I tried assigning class weights to balance the data out. Even manually deleting 0's in the data, but nothing seems to result in accurate predictions. Am I doing something wrong in the model, or is this simply data that cannot be utilized by machine learning?







      machine-learning deep-learning keras dataset data-cleaning





      share







      New contributor




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










      share







      New contributor




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








      share



      share






      New contributor




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









      asked 7 mins ago









      PavlovsCatPavlovsCat

      1




      1




      New contributor




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





      New contributor





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






      PavlovsCat 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.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
          );



          );






          PavlovsCat 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%2f49448%2fis-this-a-data-issue-or-a-model-issue-a-keras-binary-classification-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








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









          draft saved

          draft discarded


















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












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











          PavlovsCat 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%2f49448%2fis-this-a-data-issue-or-a-model-issue-a-keras-binary-classification-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







          XWnpIMZ,gKj79,XJgfjgP2uxlnLq4jO,bZt,PnbsjjajgUuBNWLoGocKa
          91V1CO32Yl IFE7bMnlLR6FhJ XRYUwG

          Popular posts from this blog

          Францішак Багушэвіч Змест Сям'я | Біяграфія | Творчасць | Мова Багушэвіча | Ацэнкі дзейнасці | Цікавыя факты | Спадчына | Выбраная бібліяграфія | Ушанаванне памяці | У філатэліі | Зноскі | Літаратура | Спасылкі | НавігацыяЛяхоўскі У. Рупіўся дзеля Бога і людзей: Жыццёвы шлях Лявона Вітан-Дубейкаўскага // Вольскі і Памідораў з песняй пра немца Адвакат, паэт, народны заступнік Ашмянскі веснікВ Минске появится площадь Богушевича и улица Сырокомли, Белорусская деловая газета, 19 июля 2001 г.Айцец беларускай нацыянальнай ідэі паўстаў у бронзе Сяргей Аляксандравіч Адашкевіч (1918, Мінск). 80-я гады. Бюст «Францішак Багушэвіч».Яўген Мікалаевіч Ціхановіч. «Партрэт Францішка Багушэвіча»Мікола Мікалаевіч Купава. «Партрэт зачынальніка новай беларускай літаратуры Францішка Багушэвіча»Уладзімір Іванавіч Мелехаў. На помніку «Змагарам за родную мову» Барэльеф «Францішак Багушэвіч»Памяць пра Багушэвіча на Віленшчыне Страчаная сталіца. Беларускія шыльды на вуліцах Вільні«Krynica». Ideologia i przywódcy białoruskiego katolicyzmuФранцішак БагушэвічТворы на knihi.comТворы Францішка Багушэвіча на bellib.byСодаль Уладзімір. Францішак Багушэвіч на Лідчыне;Луцкевіч Антон. Жыцьцё і творчасьць Фр. Багушэвіча ў успамінах ягоных сучасьнікаў // Запісы Беларускага Навуковага таварыства. Вільня, 1938. Сшытак 1. С. 16-34.Большая российская1188761710000 0000 5537 633Xn9209310021619551927869394п

          Partai Komunis Tiongkok Daftar isi Kepemimpinan | Pranala luar | Referensi | Menu navigasidiperiksa1 perubahan tertundacpc.people.com.cnSitus resmiSurat kabar resmi"Why the Communist Party is alive, well and flourishing in China"0307-1235"Full text of Constitution of Communist Party of China"smengembangkannyas

          На ростанях Змест Гісторыя напісання | Месца дзеяння | Час дзеяння | Назва | Праблематыка трылогіі | Аўтабіяграфічнасць | Трылогія ў тэатры і кіно | Пераклады | У культуры | Зноскі Літаратура | Спасылкі | НавігацыяДагледжаная версіяправерана1 зменаДагледжаная версіяправерана1 зменаАкадэмік МІЦКЕВІЧ Канстанцін Міхайлавіч (Якуб Колас) Прадмова М. І. Мушынскага, доктара філалагічных навук, члена-карэспандэнта Нацыянальнай акадэміі навук Рэспублікі Беларусь, прафесараНашаніўцы ў трылогіі Якуба Коласа «На ростанях»: вобразы і прататыпы125 лет Янке МавруКнижно-документальная выставка к 125-летию со дня рождения Якуба Коласа (1882—1956)Колас Якуб. Новая зямля (паэма), На ростанях (трылогія). Сулкоўскі Уладзімір. Радзіма Якуба Коласа (серыял жывапісных палотнаў)Вокладка кнігіІлюстрацыя М. С. БасалыгіНа ростаняхАўдыёверсія трылогііВ. Жолтак У Люсiнскай школе 1959