Questions tagged [k-fold]

A technique in cross-validation where the data is partitioned into k subsets (or "folds"), where the first k-1 folds are used for training and the last fold for evaluation. The process is repeated k times, leaving out a different fold for evaluation each time.

284 questions
0
votes
1 answer

Splitting a list of folds into training and validation sets

I have created code that splits data into folds (7 in this case). In effect, I have a list of lists of 7 folds of data. I now want to go through these and split into training and validation sets within each fold and store these as data frames. As a…
DWS
  • 1
  • 2
0
votes
0 answers

Using Kfold for cross validation

I am using the following code for 5 fold cross validation. I am getting error as kfold is not iterable. I have tried to use shuffle, writing number of folds different way but still getting error. from sklearn.model_selection import…
0
votes
0 answers

If not chosen all the data in the train partition, is it still k-fold cross validation?

I have a dataset of 900 images, distributed across 6 classes, with 150 images per class. To develop a classifier and assess its performance, I will utilize k-fold cross-validation. In this case, I will employ 3-fold cross-validation. For each fold,…
noone
  • 6,168
  • 2
  • 42
  • 51
0
votes
0 answers

StratifiedKFold called from multiprocessing loop gives same results for each process

I'm writing a custom GridSearchCV function by calling StratifiedKFold from my multiprocess loop StratifiedKFold is giving the same accuracy n times, n = number of processes import multiprocessing PROCESSES = 5 with multiprocessing.Pool(PROCESSES)…
sam
  • 13
  • 3
0
votes
1 answer

Print classification result with k fold classification with sklearn package

I have a dataset that I spilt by the holdout method using sklearn. The following is the procedure from sklearn.model_selection import train_test_split (X_train, X_test, y_train, y_test)=train_test_split(X,y,test_size=0.3, stratify=y) I am using…
Encipher
  • 1,370
  • 1
  • 14
  • 31
0
votes
1 answer

Neural network regression: the Difference between training MAE and cross-validation results

I'm working on a regression task using a neural network implemented in Keras. I trained the model for 1000 epochs, and on the last epoch, I obtained a mean absolute error (MAE) value of 3.8 However, when I performed cross-validation using…
0
votes
1 answer

How to use cross_cal_score for MNIST dataset? How to fix: "ValueError: Shapes (None, 1) and (None, 10) are incompatible"

How to use cross_cal_score for MNIST dataset? Shapes between the output of my model and the y in cross_cal_score are incompatible. I would like to perform k-fold cross validation for MNIST dataset (an example in DEEP LEARNING: FROM BASICS TO…
0
votes
1 answer

How to save history for k-fold cross-validation Tensorflow model?

I have a Tensorflow workflow set-up to split my training data and use k-fold cross-validation where the script iterates k-times and trains a new model on each subset of the data. However, I'm having an issue saving the individual training history…
0
votes
1 answer

How to use K-Fold cross validation with DenseNet121 model

I am working on classification of images breast cancer using DensetNet121 pretrained model. I split the dataset into training, testing and validation. I want to apply k-fold cross validation. I used cross_validation from sklearn library, but I get…
Eda
  • 565
  • 1
  • 7
  • 18
0
votes
1 answer

K-fold to train a machine learning model

I have a big question today for which I can't figure out the real solution. I make a stratified K-folding to my gridsearch (to search the good hyperparameter for my ML model). Can I take the best fold for training my final model. For example, there…
0
votes
0 answers

Large differences in accuracy between different folds in kFold validation

I am using the VGG16 model on spectrograms without any pre-training. I am currently doing KFold validation but while in one the accuracy reaches 99%, in another one it stays at 53%. Can anyone help me with it? Why and how to solve it? On the fold…
0
votes
0 answers

What is the purpose of using get_n_splits instead of an integer value?

n_folds = 5 def rmsle(model): kf = KFold(n_folds, shuffle=True, random_state=42).get_n_splits(train.values) rmse = np.sqrt(-cross_val_score(model, train.values, y_train, scoring="neg_mean_squared_error", cv = kf)) return(rmse) I'm new…
0
votes
0 answers

Python Validation/Test in K-fold when feeding into Neural Networks

I am using tensorflow neural network to predict on the whole dataset using K-fold method. https://www.tensorflow.org/tutorials/structured_data/feature_columns train, test = train_test_split(dataframe, test_size=0.2) train, val =…
0
votes
0 answers

Equivalence of cv.glmnet for quantile regression R

Does any one know how to do K fold cross validation (with lasso penalty) for quantile regression including the weight of variables ? I found rqPen but it doesn't take account weight of variables. Linear regression : cv.glmnet(X,Y lambda=...,…
0
votes
0 answers

k-fold Cross-validation in segmention by cnn

I wrote a code for the segmentation of iris images and got relatively good results. But I need to do it better. I want to use k-fold cross validation. I wrote a code for the segmentation of iris images and got relatively good results. But I need to…