# Tag Info

Accepted

### Train/Test/Validation Set Splitting in Sklearn

You could just use sklearn.model_selection.train_test_split twice. First to split to train, test and then split train again into validation and train. Something ...
• 2,412

### Train/Test/Validation Set Splitting in Sklearn

There is a great answer to this question over on SO that uses numpy and pandas. The command (see the answer for the discussion): ...
• 895
Accepted

### Merging multiple data frames row-wise in PySpark

Stolen from: https://stackoverflow.com/questions/33743978/spark-union-of-multiple-rdds Outside of chaining unions this is the only way to do it for DataFrames. ...
• 9,038
Accepted

### What is the difference between bootstrapping and cross-validation?

Both cross validation and bootstrapping are resampling methods. bootstrap resamples with replacement (and usually produces new "surrogate" data sets with the same number of cases as the original ...
Accepted

### Why use both validation set and test set?

Let's assume that you are training a model whose performance depends on a set of hyperparameters. In the case of a neural network, these parameters may be for instance the learning rate or the number ...
• 1,687
Accepted

### How to use the output of GridSearch?

Decided to go away and find the answers that would satisfy my question, and write them up here for anyone else wondering. The .best_estimator_ attribute is an instance of the specified model type, ...
• 1,642
Accepted

### How does the validation_split parameter of Keras' fit function work?

You actually would not want to resample your validation set after each epoch. If you did this your model would be trained on every single sample in your dataset and thus this will cause overfitting. ...
• 8,518

### Train/Test/Validation Set Splitting in Sklearn

Adding to @hh32's answer, while respecting any predefined proportions such as (75, 15, 10): ...
Accepted

### How to calculate the fold number (k-fold) in cross validation?

The number of folds is usually determined by the number of instances contained in your dataset. For example, if you have 10 instances in your data, 10-fold cross-validation wouldn't make sense. $k$-...
• 8,518
Accepted

### Cross validation Vs. Train Validate Test

If k-fold cross-validation is used to optimize the model parameters, the training set is split into k parts. Training happens k times, each time leaving out a different part of the training set. ...
• 471
Accepted

### Cross Validation in Keras

From the Keras documentation, you can load the data into Train and Test sets like this: (X_train, y_train), (X_test, y_test) = mnist.load_data() As for cross ...

### Why use both validation set and test set?

The test set and cross validation set have different purposes. If you drop either one, you lose its benefits: The cross validation set is used to help detect over-fitting and to assist in hyper-...
• 27.4k
Accepted

### When do I have to use aucPR instead of auROC? (and vice versa)

Yes, you are correct that the dominant difference between the area under the curve of a receiver operator characteristic curve (ROC-AUC) and the area under the curve of a Precision-Recall curve (PR-...
• 6,678

### Merging multiple data frames row-wise in PySpark

Sometime, when the dataframes to combine do not have the same order of columns, it is better to df2.select(df1.columns) in order to ensure both df have the same ...
• 261
Accepted

### How to choose a classifier after cross-validation?

You do cross-validation when you want to do any of these two things: Model Selection Error Estimation of a Model Model selection can come in different scenarios: Selecting one algorithm vs others ...
• 1,470
Accepted

### Cross validation for highly imbalanced data with undersampling

You should always do your evaluation of model performance on data that has not been over/undersampled. You can setup a pipeline with scikit-learn to perform your undersampling on the training set and ...
• 662

### How to calculate the fold number (k-fold) in cross validation?

Depends on how much CPU juice you are willing to afford for the same. Having a lower K means less variance and thus, more bias, while having a higher K means more variance and thus, and lower bias. ...
• 8,036
Accepted

### What is GridSearchCV doing after it finishes evaluating the performance of parameter combinations that takes so long?

Yep I figured it out. The answer is that by default GridSearchCV's last act is to expose the API of the estimator object you passed so that you can directly call things like ...
• 1,694
Accepted

### Can overfitting occur even with validation loss still dropping?

I am not sure if the validation set is balanced or not. You have a severe data imbalance problem. If you sample equally and randomly from each class to train your network, and then a percentage of ...
• 1,849
Accepted

### How to estimate GridSearchCV computing time?

You could fit your model/pipeline (with default parameters) to your data once and see how long it takes to train. Then you would multiply that by how many times you want to train the model through ...
• 7,568
Accepted

### Why you shouldn't upsample before cross validation

To see clearly why the procedure of upsampling before CV is mistaken and it leads to data leakage and other undesired consequences, it is useful to imagine first the simpler "baseline" case, ...
• 1,810

### Why is the k-fold cross-validation needed?

Given the randomization, it is unlikely that there will be a dramatic change from one run into the next one in the loop of the cross-validation. This assumption is wrong, it's true only if the ...
• 22.2k

### Train/Test/Validation Set Splitting in Sklearn

You can use train_test_split twice. I think this is most straightforward. ...
• 191
Accepted

### Which is first ? Tuning the parameters or selecting the model

You can tune parameters only if you have already trained the model, otherwise there is nothing to tune. However, i've also read that model selection shoud be done before tuning the parameters. ...
Accepted

### Validation vs. test vs. training accuracy. Which one should I compare for claiming overfit?

Which two accuracies I compare to see if the model is overfitting or not? You should compare the training and test accuracies to identify over-fitting. A training accuracy that is subjectively far ...
• 8,629
Accepted

### Cross-validation: K-fold vs Repeated random sub-sampling

If you have an adequate number of samples and want to use all the data, then k-fold cross-validation is the way to go. Having ~1,500 seems like a lot but whether it is adequate for k-fold cross-...
• 836

### Does modeling with Random Forests require cross-validation?

By default random forest picks up 2/3rd data for training and rest for testing for regression and almost 70% data for training and rest for testing during classification.By principle since it ...
• 571
Accepted

### Nested cross-validation and selecting the best regression model - is this the right SKLearn process?

Yours is not an example of nested cross-validation. Nested cross-validation is useful to figure out whether, say, a random forest or a SVM is better suited for your problem. Nested CV only outputs a ...

### How to choose a classifier after cross-validation?

No. You don't select any of the k classifiers built during k-fold cross-validation. First of all, the purpose of cross-validation is not to come up with a predictive model, but to evaluate how ...
• 1,153
Question 1: Why do most CNN models not apply the cross-validation technique? $k$-fold cross-validation is often used for simple models with few parameters, models with simple hyperparameters and ...