{
  "id": 24319,
  "title": "Advice on Neural Network Approach.",
  "url": "/competitions/bosch-production-line-performance/discussion/24319",
  "author_name": "",
  "post_date": "2016-10-12T05:42:33.777Z",
  "votes": null,
  "comment_count": 22,
  "views": 2309,
  "content": "<p>Dear Kagglers,\nI'm trying to implement neural network, 2 hidden layer, using Keras. But it seems to give too many False +ve when using Under sampling of majority class, and too many False -ve when using Over Sampling of minority class. And without sampling trick its simply predicting majority class.\nCan you give some advice?\nThank you</p>\n\n<p>P.S. I know XGBoost is working fine, but I want to try Neural Net, as its a part of my final year project.</p>",
  "messages": [
    {
      "id": "139018",
      "postDate": "10/12/2016 05:42:33",
      "content": "<p>Dear Kagglers,\nI'm trying to implement neural network, 2 hidden layer, using Keras. But it seems to give too many False +ve when using Under sampling of majority class, and too many False -ve when using Over Sampling of minority class. And without sampling trick its simply predicting majority class.\nCan you give some advice?\nThank you</p>\n\n<p>P.S. I know XGBoost is working fine, but I want to try Neural Net, as its a part of my final year project.</p>",
      "rawMarkdown": "Dear Kagglers,\r\nI'm trying to implement neural network, 2 hidden layer, using Keras. But it seems to give too many False +ve when using Under sampling of majority class, and too many False -ve when using Over Sampling of minority class. And without sampling trick its simply predicting majority class.\r\nCan you give some advice?\r\nThank you\r\n\r\nP.S. I know XGBoost is working fine, but I want to try Neural Net, as its a part of my final year project.",
      "votes": null
    },
    {
      "id": "139021",
      "postDate": "10/12/2016 06:07:19",
      "content": "<p>Hi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: <a href=\"https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\">https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n</a></p>\n\n<p>Dataset contains all of +ve samples, and undersampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.</p>",
      "rawMarkdown": "Hi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\r\n\r\nDataset contains all of +ve samples, and undersampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.",
      "votes": null
    },
    {
      "id": "139022",
      "postDate": "10/12/2016 06:15:10",
      "content": "<p>@Amanda Dsouza , are you maintaining the same ratio of majority and minority in the validation set as in train set?</p>",
      "rawMarkdown": "Amanda Dsouza , are you maintaining the same ratio of majority and minority in the validation set as in train set?",
      "votes": null
    },
    {
      "id": "139024",
      "postDate": "10/12/2016 06:28:00",
      "content": "<p>[quote=Amanda Dsouza;139021]</p>\n\n<p>Hi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: <a href=\"https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\">https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n</a></p>\n\n<p>Dataset contains all of +ve samples, and unsampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.</p>\n\n<p>[/quote]</p>\n\n<p>My first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.</p>\n\n<p>Next, try different <a href=\"https://keras.io/optimizers/\"><strong>optimizers</strong></a> and <a href=\"https://keras.io/layers/advanced-activations/\"><strong>activation functions</strong></a>. Lastly, <a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> might help even though it will slow things down.</p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139021]\r\n\r\nHi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\r\n\r\nDataset contains all of +ve samples, and unsampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.\r\n\r\n[/quote]\r\n\r\nMy first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.\r\n\r\nNext, try different [__optimizers__](https://keras.io/optimizers/) and [__activation functions__](https://keras.io/layers/advanced-activations/). Lastly, [__BatchNormalization__](https://keras.io/layers/normalization/) might help even though it will slow things down.",
      "votes": null
    },
    {
      "id": "139027",
      "postDate": "10/12/2016 06:39:16",
      "content": "<p>In both training &amp; validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training &amp; validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.</p>",
      "rawMarkdown": "In both training & validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training & validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.",
      "votes": null
    },
    {
      "id": "139029",
      "postDate": "10/12/2016 06:52:32",
      "content": "<p>[quote=Amanda Dsouza;139027]</p>\n\n<p>In both training &amp; validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training &amp; validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.</p>\n\n<p>[/quote]</p>\n\n<p>Any ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results. </p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139027]\r\n\r\nIn both training & validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training & validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.\r\n\r\n[/quote]\r\n\r\nAny ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results.",
      "votes": null
    },
    {
      "id": "139071",
      "postDate": "10/12/2016 11:52:01",
      "content": "<p>Hi  Chetan Madhok ,</p>\n\n<p>Do you adjust threshold to maximize mcc ?<br>\nOutput of NN would be probability and the way to adjust threshold is also important.</p>",
      "rawMarkdown": "Hi  Chetan Madhok ,\r\n\r\nDo you adjust threshold to maximize mcc ?<br>\r\nOutput of NN would be probability and the way to adjust threshold is also important.",
      "votes": null
    },
    {
      "id": "139089",
      "postDate": "10/12/2016 14:03:10",
      "content": "<p>[quote=toshi_k;139071]</p>\n\n<p>Hi  Chetan Madhok ,</p>\n\n<p>Do you adjust threshold to maximize mcc ?<br>\nOutput of NN would be probability and the way to adjust threshold is also important.</p>\n\n<p>[/quote]</p>\n\n<p>I thought the same, maybe misleading results help in this case to maximize the MCC! \nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!</p>",
      "rawMarkdown": "[quote=toshi_k;139071]\r\n\r\nHi  Chetan Madhok ,\r\n\r\nDo you adjust threshold to maximize mcc ?<br>\r\nOutput of NN would be probability and the way to adjust threshold is also important.\r\n\r\n[/quote]\r\n\r\nI thought the same, maybe misleading results help in this case to maximize the MCC! \r\nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!",
      "votes": null
    },
    {
      "id": "139272",
      "postDate": "10/13/2016 06:31:55",
      "content": "<p>[quote=Chetan Madhok;139029]</p>\n\n<p>[/quote]</p>\n\n<p>Any ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results. </p>\n\n<p>[/quote]</p>\n\n<p>@Chetan, I wonder why that is so. Any thoughts? What if we were to use different samples of negative class in the feature selection process.  </p>",
      "rawMarkdown": "[quote=Chetan Madhok;139029]\r\n\r\n[/quote]\r\n\r\nAny ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results. \r\n\r\n[/quote]\r\n\r\n@Chetan, I wonder why that is so. Any thoughts? What if we were to use different samples of negative class in the feature selection process.",
      "votes": null
    },
    {
      "id": "139273",
      "postDate": "10/13/2016 06:34:30",
      "content": "<p>[quote=Malte Nalenz;139089]</p>\n\n<p>I thought the same, maybe misleading results help in this case to maximize the MCC! \nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!</p>\n\n<p>[/quote]</p>\n\n<p>[UPDATED] @Malte, I used MCC to directly evaluate the neural network. It is available in Keras as 'matthews_correlation'. <a href=\"https://github.com/fchollet/keras/blob/master/keras/metrics.py\">https://github.com/fchollet/keras/blob/master/keras/metrics.py</a> \nThanks for the tip on PCA. I will give it a try.</p>",
      "rawMarkdown": "[quote=Malte Nalenz;139089]\r\n\r\nI thought the same, maybe misleading results help in this case to maximize the MCC! \r\nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!\r\n\r\n[/quote]\r\n\r\n[UPDATED] @Malte, I used MCC to directly evaluate the neural network. It is available in Keras as 'matthews_correlation'. https://github.com/fchollet/keras/blob/master/keras/metrics.py \r\nThanks for the tip on PCA. I will give it a try.",
      "votes": null
    },
    {
      "id": "139274",
      "postDate": "10/13/2016 06:37:19",
      "content": "<p>[quote=Tilii;139024]</p>\n\n<p>My first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.</p>\n\n<p>Next, try different <a href=\"https://keras.io/optimizers/\"><strong>optimizers</strong></a> and <a href=\"https://keras.io/layers/advanced-activations/\"><strong>activation functions</strong></a>. Lastly, <a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> might help even though it will slow things down.</p>\n\n<p>[/quote]</p>\n\n<p>@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process? </p>",
      "rawMarkdown": "[quote=Tilii;139024]\r\n\r\nMy first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.\r\n\r\nNext, try different [__optimizers__](https://keras.io/optimizers/) and [__activation functions__](https://keras.io/layers/advanced-activations/). Lastly, [__BatchNormalization__](https://keras.io/layers/normalization/) might help even though it will slow things down.\r\n\r\n[/quote]\r\n\r\n@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process?",
      "votes": null
    },
    {
      "id": "139275",
      "postDate": "10/13/2016 06:42:08",
      "content": "<p>[quote=Amanda Dsouza;139274]</p>\n\n<p>[quote=Tilii;139024]</p>\n\n<p>My first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.</p>\n\n<p>Next, try different <a href=\"https://keras.io/optimizers/\"><strong>optimizers</strong></a> and <a href=\"https://keras.io/layers/advanced-activations/\"><strong>activation functions</strong></a>. Lastly, <a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> might help even though it will slow things down.</p>\n\n<p>[/quote]</p>\n\n<p>@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process? </p>\n\n<p>[/quote]</p>\n\n<p>Dropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\nexample: a dropout(0.5) would kill 50% of connections between the two layers.</p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139274]\r\n\r\n[quote=Tilii;139024]\r\n\r\nMy first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.\r\n\r\nNext, try different [__optimizers__](https://keras.io/optimizers/) and [__activation functions__](https://keras.io/layers/advanced-activations/). Lastly, [__BatchNormalization__](https://keras.io/layers/normalization/) might help even though it will slow things down.\r\n\r\n[/quote]\r\n\r\n@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process? \r\n\r\n[/quote]\r\n\r\nDropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\r\nexample: a dropout(0.5) would kill 50% of connections between the two layers.",
      "votes": null
    },
    {
      "id": "139276",
      "postDate": "10/13/2016 06:46:56",
      "content": "<p>[quote=Chetan Madhok;139275]</p>\n\n<p>Dropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\nexample: a dropout(0.5) would kill 50% of connections between the two layers.</p>\n\n<p>[/quote]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.</p>",
      "rawMarkdown": "[quote=Chetan Madhok;139275]\r\n\r\nDropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\r\nexample: a dropout(0.5) would kill 50% of connections between the two layers.\r\n\r\n[/quote]\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.",
      "votes": null
    },
    {
      "id": "139277",
      "postDate": "10/13/2016 06:48:48",
      "content": "<p>[quote=Amanda Dsouza;139276]</p>\n\n<p>[quote=Chetan Madhok;139275]</p>\n\n<p>Dropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\nexample: a dropout(0.5) would kill 50% of connections between the two layers.</p>\n\n<p>[/quote]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.\n[/quote]</p>\n\n<p>Then it would be smaller set of Random Features at each iterations, that would decrease the variance and hence more accurate results.</p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139276]\r\n\r\n[quote=Chetan Madhok;139275]\r\n\r\nDropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\r\nexample: a dropout(0.5) would kill 50% of connections between the two layers.\r\n\r\n[/quote]\r\n\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.\r\n[/quote]\r\n\r\n\r\n\r\n Then it would be smaller set of Random Features at each iterations, that would decrease the variance and hence more accurate results.",
      "votes": null
    },
    {
      "id": "139328",
      "postDate": "10/13/2016 13:34:07",
      "content": "<p>Do you use MCC to directly train neural network ?<br></p>\n\n<p><em>keras/metrics.py</em> have matthews_correlation,<br>\n<a href=\"https://github.com/fchollet/keras/blob/master/keras/metrics.py\">https://github.com/fchollet/keras/blob/master/keras/metrics.py</a><br>\nHowever, <em>keras/objectives.py</em> <strong>don't</strong> have matthews_correlation.<br>\n<a href=\"https://github.com/fchollet/keras/blob/master/keras/objectives.py\">https://github.com/fchollet/keras/blob/master/keras/objectives.py</a></p>\n\n<p>You use MCC just for evaluation, don't you ? Which objective do you use ?<br></p>",
      "rawMarkdown": "Do you use MCC to directly train neural network ?<br>\r\n\r\n*keras/metrics.py* have matthews_correlation,<br>\r\nhttps://github.com/fchollet/keras/blob/master/keras/metrics.py<br>\r\nHowever, *keras/objectives.py* **don't** have matthews_correlation.<br>\r\nhttps://github.com/fchollet/keras/blob/master/keras/objectives.py\r\n\r\nYou use MCC just for evaluation, don't you ? Which objective do you use ?<br>",
      "votes": null
    },
    {
      "id": "139329",
      "postDate": "10/13/2016 13:49:33",
      "content": "<p>I played with the neural network approach as well, I used tensorflow.\nI did quite advanced network configuration (including a per station pre-training).\nHowever I stopped the idea after several days of trials.</p>\n\n<p>To save you some time, I can also say that I tried to minimize the MCC as objective.\nBut tensorflow didn't like it at all... It took me a couple of hours to realize that the MCC is not differentiable, and therefore the gradient doesn't allow to identify which weights (neurones) to update.</p>\n\n<p>I tried a few (close) mathematical approximation of the MCC,\nbut as I said, I didn't find anything thing converging reasonably well.\nBut if you do, I'd be super interested to hear about it</p>\n\n<p>Good luck,\nLoic</p>",
      "rawMarkdown": "I played with the neural network approach as well, I used tensorflow.\r\nI did quite advanced network configuration (including a per station pre-training).\r\nHowever I stopped the idea after several days of trials.\r\n\r\nTo save you some time, I can also say that I tried to minimize the MCC as objective.\r\nBut tensorflow didn't like it at all... It took me a couple of hours to realize that the MCC is not differentiable, and therefore the gradient doesn't allow to identify which weights (neurones) to update.\r\n\r\nI tried a few (close) mathematical approximation of the MCC,\r\nbut as I said, I didn't find anything thing converging reasonably well.\r\nBut if you do, I'd be super interested to hear about it\r\n\r\nGood luck,\r\nLoic",
      "votes": null
    },
    {
      "id": "139330",
      "postDate": "10/13/2016 13:54:32",
      "content": "<p>yes, you are right. I use MCC to evaluate training &amp; validation. Loss function is logloss. \nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])</p>",
      "rawMarkdown": "yes, you are right. I use MCC to evaluate training & validation. Loss function is logloss. \r\nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])",
      "votes": null
    },
    {
      "id": "139332",
      "postDate": "10/13/2016 14:03:32",
      "content": "<p>[quote=Amanda Dsouza;139330]</p>\n\n<p>yes, you are right. I use MCC to evaluate training &amp; validation. Loss function is logloss. \nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])</p>\n\n<p>[/quote]</p>\n\n<p>Thank you, Amanda. I understand your approach with keras !</p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139330]\r\n\r\nyes, you are right. I use MCC to evaluate training & validation. Loss function is logloss. \r\nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])\r\n\r\n[/quote]\r\n\r\nThank you, Amanda. I understand your approach with keras !",
      "votes": null
    },
    {
      "id": "139371",
      "postDate": "10/13/2016 18:31:29",
      "content": "<p>[quote=Amanda Dsouza;139276]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.</p>\n\n<p>[/quote]</p>\n\n<p>Dropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.</p>\n\n<p>To put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly &quot;throws away&quot; useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.</p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139276]\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.\r\n\r\n[/quote]\r\n\r\nDropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.\r\n\r\nTo put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly \"throws away\" useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.",
      "votes": null
    },
    {
      "id": "139436",
      "postDate": "10/14/2016 05:56:01",
      "content": "<p>[quote=Tilii;139371]</p>\n\n<p>[quote=Amanda Dsouza;139276]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.</p>\n\n<p>[/quote]</p>\n\n<p>Dropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.</p>\n\n<p>To put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly &quot;throws away&quot; useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.</p>\n\n<p>[/quote]</p>\n\n<p>@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\nException: The first layer in a Sequential model must get an <code>input_shape</code> or <code>batch_input_shape</code> argument.</p>\n\n<p>Also, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?</p>",
      "rawMarkdown": "[quote=Tilii;139371]\r\n\r\n[quote=Amanda Dsouza;139276]\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.\r\n\r\n[/quote]\r\n\r\nDropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.\r\n\r\nTo put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly \"throws away\" useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.\r\n\r\n\r\n\r\n[/quote]\r\n\r\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\r\nException: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.\r\n\r\nAlso, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?",
      "votes": null
    },
    {
      "id": "139671",
      "postDate": "10/15/2016 18:32:22",
      "content": "<p>[quote=Amanda Dsouza;139436]</p>\n\n<p>@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\nException: The first layer in a Sequential model must get an <code>input_shape</code> or <code>batch_input_shape</code> argument.</p>\n\n<p>Also, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?</p>\n\n<p>[/quote]</p>\n\n<p>Dropout can't be the first or the last entry in your model. See <a href=\"https://www.kaggle.com/fchollet/digit-recognizer/simple-deep-mlp-with-keras\"><strong>here</strong></a> for an example.</p>\n\n<p><a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> can be used with any optimizer.</p>",
      "rawMarkdown": "[quote=Amanda Dsouza;139436]\r\n\r\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\r\nException: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.\r\n\r\nAlso, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?\r\n\r\n\r\n[/quote]\r\n\r\nDropout can't be the first or the last entry in your model. See [__here__](https://www.kaggle.com/fchollet/digit-recognizer/simple-deep-mlp-with-keras) for an example.\r\n\r\n[__BatchNormalization__](https://keras.io/layers/normalization/) can be used with any optimizer.",
      "votes": null
    },
    {
      "id": "139733",
      "postDate": "10/16/2016 05:45:11",
      "content": "<p>[quote=Amanda Dsouza;139436]\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\nException: The first layer in a Sequential model must get an <code>input_shape</code> or <code>batch_input_shape</code> argument.</p>\n\n<p>Also, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?</p>\n\n<p>[/quote]</p>\n\n<p>It's easy to add dropouts. <strong>Just make sure you mention the input shape in the first layer.</strong></p>\n\n<pre><code>model = Sequential()\nmodel.add(Dropout(0.2, input_shape=(60,)))\nmodel.add(Dense(60, init='normal', activation='relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(1, init='normal', activation='sigmoid'))\n</code></pre>",
      "rawMarkdown": "[quote=Amanda Dsouza;139436]\r\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\r\nException: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.\r\n\r\nAlso, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?\r\n\r\n[/quote]\r\n\r\nIt's easy to add dropouts. **Just make sure you mention the input shape in the first layer.**\r\n\r\n    model = Sequential()\r\n    model.add(Dropout(0.2, input_shape=(60,)))\r\n    model.add(Dense(60, init='normal', activation='relu'))\r\n    model.add(Dropout(0.2))\r\n    model.add(Dense(1, init='normal', activation='sigmoid'))",
      "votes": null
    },
    {
      "id": "961668",
      "postDate": "08/07/2020 11:34:45",
      "content": "<p>Hello，Chetan Madhok. I want to know what's your best score by Neural Net？Looking forward to your reply.</p>",
      "rawMarkdown": "Hello，Chetan Madhok. I want to know what's your best score by Neural Net？Looking forward to your reply.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 961668,
      "author_name": "jiangjinyu",
      "author_url": "",
      "post_date": "08/07/2020 11:34:45",
      "content": "<p>Hello，Chetan Madhok. I want to know what's your best score by Neural Net？Looking forward to your reply.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139021,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/12/2016 06:07:19",
      "content": "<p>Hi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: <a href=\"https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\">https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n</a></p>\n\n<p>Dataset contains all of +ve samples, and undersampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139022,
      "author_name": "cmadhok94",
      "author_url": "",
      "post_date": "10/12/2016 06:15:10",
      "content": "<p>@Amanda Dsouza , are you maintaining the same ratio of majority and minority in the validation set as in train set?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139024,
      "author_name": "tilii7",
      "author_url": "",
      "post_date": "10/12/2016 06:28:00",
      "content": "<p>[quote=Amanda Dsouza;139021]</p>\n\n<p>Hi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: <a href=\"https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\">https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n</a></p>\n\n<p>Dataset contains all of +ve samples, and unsampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.</p>\n\n<p>[/quote]</p>\n\n<p>My first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.</p>\n\n<p>Next, try different <a href=\"https://keras.io/optimizers/\"><strong>optimizers</strong></a> and <a href=\"https://keras.io/layers/advanced-activations/\"><strong>activation functions</strong></a>. Lastly, <a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> might help even though it will slow things down.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139027,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/12/2016 06:39:16",
      "content": "<p>In both training &amp; validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training &amp; validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139029,
      "author_name": "cmadhok94",
      "author_url": "",
      "post_date": "10/12/2016 06:52:32",
      "content": "<p>[quote=Amanda Dsouza;139027]</p>\n\n<p>In both training &amp; validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training &amp; validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.</p>\n\n<p>[/quote]</p>\n\n<p>Any ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results. </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139071,
      "author_name": "toshik",
      "author_url": "",
      "post_date": "10/12/2016 11:52:01",
      "content": "<p>Hi  Chetan Madhok ,</p>\n\n<p>Do you adjust threshold to maximize mcc ?<br>\nOutput of NN would be probability and the way to adjust threshold is also important.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139089,
      "author_name": "malten",
      "author_url": "",
      "post_date": "10/12/2016 14:03:10",
      "content": "<p>[quote=toshi_k;139071]</p>\n\n<p>Hi  Chetan Madhok ,</p>\n\n<p>Do you adjust threshold to maximize mcc ?<br>\nOutput of NN would be probability and the way to adjust threshold is also important.</p>\n\n<p>[/quote]</p>\n\n<p>I thought the same, maybe misleading results help in this case to maximize the MCC! \nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139272,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/13/2016 06:31:55",
      "content": "<p>[quote=Chetan Madhok;139029]</p>\n\n<p>[/quote]</p>\n\n<p>Any ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results. </p>\n\n<p>[/quote]</p>\n\n<p>@Chetan, I wonder why that is so. Any thoughts? What if we were to use different samples of negative class in the feature selection process.  </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139273,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/13/2016 06:34:30",
      "content": "<p>[quote=Malte Nalenz;139089]</p>\n\n<p>I thought the same, maybe misleading results help in this case to maximize the MCC! \nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!</p>\n\n<p>[/quote]</p>\n\n<p>[UPDATED] @Malte, I used MCC to directly evaluate the neural network. It is available in Keras as 'matthews_correlation'. <a href=\"https://github.com/fchollet/keras/blob/master/keras/metrics.py\">https://github.com/fchollet/keras/blob/master/keras/metrics.py</a> \nThanks for the tip on PCA. I will give it a try.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139274,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/13/2016 06:37:19",
      "content": "<p>[quote=Tilii;139024]</p>\n\n<p>My first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.</p>\n\n<p>Next, try different <a href=\"https://keras.io/optimizers/\"><strong>optimizers</strong></a> and <a href=\"https://keras.io/layers/advanced-activations/\"><strong>activation functions</strong></a>. Lastly, <a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> might help even though it will slow things down.</p>\n\n<p>[/quote]</p>\n\n<p>@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process? </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139275,
      "author_name": "cmadhok94",
      "author_url": "",
      "post_date": "10/13/2016 06:42:08",
      "content": "<p>[quote=Amanda Dsouza;139274]</p>\n\n<p>[quote=Tilii;139024]</p>\n\n<p>My first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.</p>\n\n<p>Next, try different <a href=\"https://keras.io/optimizers/\"><strong>optimizers</strong></a> and <a href=\"https://keras.io/layers/advanced-activations/\"><strong>activation functions</strong></a>. Lastly, <a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> might help even though it will slow things down.</p>\n\n<p>[/quote]</p>\n\n<p>@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process? </p>\n\n<p>[/quote]</p>\n\n<p>Dropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\nexample: a dropout(0.5) would kill 50% of connections between the two layers.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139276,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/13/2016 06:46:56",
      "content": "<p>[quote=Chetan Madhok;139275]</p>\n\n<p>Dropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\nexample: a dropout(0.5) would kill 50% of connections between the two layers.</p>\n\n<p>[/quote]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139277,
      "author_name": "cmadhok94",
      "author_url": "",
      "post_date": "10/13/2016 06:48:48",
      "content": "<p>[quote=Amanda Dsouza;139276]</p>\n\n<p>[quote=Chetan Madhok;139275]</p>\n\n<p>Dropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\nexample: a dropout(0.5) would kill 50% of connections between the two layers.</p>\n\n<p>[/quote]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.\n[/quote]</p>\n\n<p>Then it would be smaller set of Random Features at each iterations, that would decrease the variance and hence more accurate results.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139328,
      "author_name": "toshik",
      "author_url": "",
      "post_date": "10/13/2016 13:34:07",
      "content": "<p>Do you use MCC to directly train neural network ?<br></p>\n\n<p><em>keras/metrics.py</em> have matthews_correlation,<br>\n<a href=\"https://github.com/fchollet/keras/blob/master/keras/metrics.py\">https://github.com/fchollet/keras/blob/master/keras/metrics.py</a><br>\nHowever, <em>keras/objectives.py</em> <strong>don't</strong> have matthews_correlation.<br>\n<a href=\"https://github.com/fchollet/keras/blob/master/keras/objectives.py\">https://github.com/fchollet/keras/blob/master/keras/objectives.py</a></p>\n\n<p>You use MCC just for evaluation, don't you ? Which objective do you use ?<br></p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139329,
      "author_name": "loicus",
      "author_url": "",
      "post_date": "10/13/2016 13:49:33",
      "content": "<p>I played with the neural network approach as well, I used tensorflow.\nI did quite advanced network configuration (including a per station pre-training).\nHowever I stopped the idea after several days of trials.</p>\n\n<p>To save you some time, I can also say that I tried to minimize the MCC as objective.\nBut tensorflow didn't like it at all... It took me a couple of hours to realize that the MCC is not differentiable, and therefore the gradient doesn't allow to identify which weights (neurones) to update.</p>\n\n<p>I tried a few (close) mathematical approximation of the MCC,\nbut as I said, I didn't find anything thing converging reasonably well.\nBut if you do, I'd be super interested to hear about it</p>\n\n<p>Good luck,\nLoic</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139330,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/13/2016 13:54:32",
      "content": "<p>yes, you are right. I use MCC to evaluate training &amp; validation. Loss function is logloss. \nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139332,
      "author_name": "toshik",
      "author_url": "",
      "post_date": "10/13/2016 14:03:32",
      "content": "<p>[quote=Amanda Dsouza;139330]</p>\n\n<p>yes, you are right. I use MCC to evaluate training &amp; validation. Loss function is logloss. \nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])</p>\n\n<p>[/quote]</p>\n\n<p>Thank you, Amanda. I understand your approach with keras !</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139371,
      "author_name": "tilii7",
      "author_url": "",
      "post_date": "10/13/2016 18:31:29",
      "content": "<p>[quote=Amanda Dsouza;139276]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.</p>\n\n<p>[/quote]</p>\n\n<p>Dropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.</p>\n\n<p>To put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly &quot;throws away&quot; useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139436,
      "author_name": "amandadsouza",
      "author_url": "",
      "post_date": "10/14/2016 05:56:01",
      "content": "<p>[quote=Tilii;139371]</p>\n\n<p>[quote=Amanda Dsouza;139276]</p>\n\n<p>Yes, i know, but my question is more why to apply dropout between the input &amp; hidden layer. It seems like that would be the same as using a smaller set of features.</p>\n\n<p>[/quote]</p>\n\n<p>Dropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.</p>\n\n<p>To put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly &quot;throws away&quot; useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.</p>\n\n<p>[/quote]</p>\n\n<p>@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\nException: The first layer in a Sequential model must get an <code>input_shape</code> or <code>batch_input_shape</code> argument.</p>\n\n<p>Also, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139671,
      "author_name": "tilii7",
      "author_url": "",
      "post_date": "10/15/2016 18:32:22",
      "content": "<p>[quote=Amanda Dsouza;139436]</p>\n\n<p>@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\nException: The first layer in a Sequential model must get an <code>input_shape</code> or <code>batch_input_shape</code> argument.</p>\n\n<p>Also, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?</p>\n\n<p>[/quote]</p>\n\n<p>Dropout can't be the first or the last entry in your model. See <a href=\"https://www.kaggle.com/fchollet/digit-recognizer/simple-deep-mlp-with-keras\"><strong>here</strong></a> for an example.</p>\n\n<p><a href=\"https://keras.io/layers/normalization/\"><strong>BatchNormalization</strong></a> can be used with any optimizer.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 139733,
      "author_name": "cmadhok94",
      "author_url": "",
      "post_date": "10/16/2016 05:45:11",
      "content": "<p>[quote=Amanda Dsouza;139436]\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\nException: The first layer in a Sequential model must get an <code>input_shape</code> or <code>batch_input_shape</code> argument.</p>\n\n<p>Also, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?</p>\n\n<p>[/quote]</p>\n\n<p>It's easy to add dropouts. <strong>Just make sure you mention the input shape in the first layer.</strong></p>\n\n<pre><code>model = Sequential()\nmodel.add(Dropout(0.2, input_shape=(60,)))\nmodel.add(Dense(60, init='normal', activation='relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(1, init='normal', activation='sigmoid'))\n</code></pre>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "139018": "Dear Kagglers,\r\nI'm trying to implement neural network, 2 hidden layer, using Keras. But it seems to give too many False +ve when using Under sampling of majority class, and too many False -ve when using Over Sampling of minority class. And without sampling trick its simply predicting majority class.\r\nCan you give some advice?\r\nThank you\r\n\r\nP.S. I know XGBoost is working fine, but I want to try Neural Net, as its a part of my final year project.",
    "139021": "Hi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\r\n\r\nDataset contains all of +ve samples, and undersampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.",
    "139022": "Amanda Dsouza , are you maintaining the same ratio of majority and minority in the validation set as in train set?",
    "139024": "[quote=Amanda Dsouza;139021]\r\n\r\nHi, I would be very interested in some suggestions as well. Here's a link to the experiments I've tried so far: https://medium.com/@dsouza.amanda/learning-from-learning-curves-1a82c6f98f49#.vctunbm7n\r\n\r\nDataset contains all of +ve samples, and unsampled -ve classes to make it a bit balanced. Stratified sampling is used on CV with 3 folds. Code in Python/Keras.\r\n\r\n[/quote]\r\n\r\nMy first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.\r\n\r\nNext, try different [__optimizers__](https://keras.io/optimizers/) and [__activation functions__](https://keras.io/layers/advanced-activations/). Lastly, [__BatchNormalization__](https://keras.io/layers/normalization/) might help even though it will slow things down.",
    "139027": "In both training & validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training & validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.",
    "139029": "[quote=Amanda Dsouza;139027]\r\n\r\nIn both training & validation sets, the split ratio is roughly the same 1:2 for +ve to -ve classes. It looks like Sklearn does an even split of both training & validation. However, I have specified class weights in my neural network model to give more importance to the +ve class.\r\n\r\n[/quote]\r\n\r\nAny ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results.",
    "139071": "Hi  Chetan Madhok ,\r\n\r\nDo you adjust threshold to maximize mcc ?<br>\r\nOutput of NN would be probability and the way to adjust threshold is also important.",
    "139089": "[quote=toshi_k;139071]\r\n\r\nHi  Chetan Madhok ,\r\n\r\nDo you adjust threshold to maximize mcc ?<br>\r\nOutput of NN would be probability and the way to adjust threshold is also important.\r\n\r\n[/quote]\r\n\r\nI thought the same, maybe misleading results help in this case to maximize the MCC! \r\nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!",
    "139272": "[quote=Chetan Madhok;139029]\r\n\r\n[/quote]\r\n\r\nAny ratio other than the original one, i.e. 0.005:99.5 for +ve to -ve is giving misleading results. \r\n\r\n[/quote]\r\n\r\n@Chetan, I wonder why that is so. Any thoughts? What if we were to use different samples of negative class in the feature selection process.",
    "139273": "[quote=Malte Nalenz;139089]\r\n\r\nI thought the same, maybe misleading results help in this case to maximize the MCC! \r\nAmanda, for your experiments did you use some kind of MCC-maximation? If not your results using more or less the raw data seem really good, maybe i should also give neural networks a try. :) For the PCA, i found the following way to perform well: Instead of transforming the data in the whole take each station and perform PCA in it. some of the meassurements are more or less the same inside the station. Using Xgboost this way works well!\r\n\r\n[/quote]\r\n\r\n[UPDATED] @Malte, I used MCC to directly evaluate the neural network. It is available in Keras as 'matthews_correlation'. https://github.com/fchollet/keras/blob/master/keras/metrics.py \r\nThanks for the tip on PCA. I will give it a try.",
    "139274": "[quote=Tilii;139024]\r\n\r\nMy first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.\r\n\r\nNext, try different [__optimizers__](https://keras.io/optimizers/) and [__activation functions__](https://keras.io/layers/advanced-activations/). Lastly, [__BatchNormalization__](https://keras.io/layers/normalization/) might help even though it will slow things down.\r\n\r\n[/quote]\r\n\r\n@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process?",
    "139275": "[quote=Amanda Dsouza;139274]\r\n\r\n[quote=Tilii;139024]\r\n\r\nMy first suggestion is to try the dropout layer between input and hidden, and maybe another one between hidden and output. Start small, say 0.2 and increase up to 0.8.\r\n\r\nNext, try different [__optimizers__](https://keras.io/optimizers/) and [__activation functions__](https://keras.io/layers/advanced-activations/). Lastly, [__BatchNormalization__](https://keras.io/layers/normalization/) might help even though it will slow things down.\r\n\r\n[/quote]\r\n\r\n@Tilii, thanks for the suggestions. What is the purpose of adding dropout between I/P and hidden? Would it be better/same/worse to reduce the feature set using a feature selection process? \r\n\r\n[/quote]\r\n\r\nDropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\r\nexample: a dropout(0.5) would kill 50% of connections between the two layers.",
    "139276": "[quote=Chetan Madhok;139275]\r\n\r\nDropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\r\nexample: a dropout(0.5) would kill 50% of connections between the two layers.\r\n\r\n[/quote]\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.",
    "139277": "[quote=Amanda Dsouza;139276]\r\n\r\n[quote=Chetan Madhok;139275]\r\n\r\nDropouts will kill a few connections between the nodes of different layers. This helps to escape the Local minima and avoids over fitting.\r\nexample: a dropout(0.5) would kill 50% of connections between the two layers.\r\n\r\n[/quote]\r\n\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.\r\n[/quote]\r\n\r\n\r\n\r\n Then it would be smaller set of Random Features at each iterations, that would decrease the variance and hence more accurate results.",
    "139328": "Do you use MCC to directly train neural network ?<br>\r\n\r\n*keras/metrics.py* have matthews_correlation,<br>\r\nhttps://github.com/fchollet/keras/blob/master/keras/metrics.py<br>\r\nHowever, *keras/objectives.py* **don't** have matthews_correlation.<br>\r\nhttps://github.com/fchollet/keras/blob/master/keras/objectives.py\r\n\r\nYou use MCC just for evaluation, don't you ? Which objective do you use ?<br>",
    "139329": "I played with the neural network approach as well, I used tensorflow.\r\nI did quite advanced network configuration (including a per station pre-training).\r\nHowever I stopped the idea after several days of trials.\r\n\r\nTo save you some time, I can also say that I tried to minimize the MCC as objective.\r\nBut tensorflow didn't like it at all... It took me a couple of hours to realize that the MCC is not differentiable, and therefore the gradient doesn't allow to identify which weights (neurones) to update.\r\n\r\nI tried a few (close) mathematical approximation of the MCC,\r\nbut as I said, I didn't find anything thing converging reasonably well.\r\nBut if you do, I'd be super interested to hear about it\r\n\r\nGood luck,\r\nLoic",
    "139330": "yes, you are right. I use MCC to evaluate training & validation. Loss function is logloss. \r\nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])",
    "139332": "[quote=Amanda Dsouza;139330]\r\n\r\nyes, you are right. I use MCC to evaluate training & validation. Loss function is logloss. \r\nmodel.compile(loss='binary_crossentropy', optimizer=rmsprop, metrics=['matthews_correlation'])\r\n\r\n[/quote]\r\n\r\nThank you, Amanda. I understand your approach with keras !",
    "139371": "[quote=Amanda Dsouza;139276]\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.\r\n\r\n[/quote]\r\n\r\nDropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.\r\n\r\nTo put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly \"throws away\" useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.",
    "139436": "[quote=Tilii;139371]\r\n\r\n[quote=Amanda Dsouza;139276]\r\n\r\nYes, i know, but my question is more why to apply dropout between the input & hidden layer. It seems like that would be the same as using a smaller set of features.\r\n\r\n[/quote]\r\n\r\nDropout applies only to the training phase, while validation is done with all units and all data. This is why dropout has the effect of reducing the complex co-adaptations on training data that lead to overfitting, while still retaining the useful data for validation.\r\n\r\nTo put it differently: reducing the number of features presumably throws away useless data (although it may throw away useful data as well if not done properly). Dropout randomly \"throws away\" useful data - but not always the same subset - during training, which has the averaging effect and reduces overfitting.\r\n\r\n\r\n\r\n[/quote]\r\n\r\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\r\nException: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.\r\n\r\nAlso, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?",
    "139671": "[quote=Amanda Dsouza;139436]\r\n\r\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\r\nException: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.\r\n\r\nAlso, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?\r\n\r\n\r\n[/quote]\r\n\r\nDropout can't be the first or the last entry in your model. See [__here__](https://www.kaggle.com/fchollet/digit-recognizer/simple-deep-mlp-with-keras) for an example.\r\n\r\n[__BatchNormalization__](https://keras.io/layers/normalization/) can be used with any optimizer.",
    "139733": "[quote=Amanda Dsouza;139436]\r\n@Tilii, @Chetan, thanks for the explanation. Do you know how this can be done in Keras? I get this exception when I try to add Dropout as a first layer.\r\nException: The first layer in a Sequential model must get an `input_shape` or `batch_input_shape` argument.\r\n\r\nAlso, as regards to Batch Normalization, would you still need to use it if you are using RMSProp for optimization or is it typically for SGD?\r\n\r\n[/quote]\r\n\r\nIt's easy to add dropouts. **Just make sure you mention the input shape in the first layer.**\r\n\r\n    model = Sequential()\r\n    model.add(Dropout(0.2, input_shape=(60,)))\r\n    model.add(Dense(60, init='normal', activation='relu'))\r\n    model.add(Dropout(0.2))\r\n    model.add(Dense(1, init='normal', activation='sigmoid'))",
    "961668": "Hello，Chetan Madhok. I want to know what's your best score by Neural Net？Looking forward to your reply."
  },
  "source": "meta"
}