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.
Questions tagged [k-fold]
284 questions
0
votes
1 answer
K-fold cross validation to reduce overfitting : problem with the implementation
It is the first time I am trying to use cross-validation and I am facing an error.
Firstly my dataset looks like this :
So, in order to avoid/reduce the overfitting of my model I am trying to use a k-fold cross validation.
from…
user15565396
0
votes
1 answer
Does K-Fold iteratively train a model
If you run cross-val_score() or cross_validate() on a dataset, is the estimator trained using all the folds at the end of the run?
I read somewhere that cross-val_score takes a copy of the estimator. Whereas I thought this was how you train a model…

Bryon
- 939
- 13
- 25
0
votes
1 answer
Applying the KFold Cross Validation on nested dictionary
Input dictionary
new_dict1 = {'ABW':{'ABR':1,'BPR':1,'CBR':1,'DBR':0},'BCW':{'ABR':0,'BPR':0,'CBR':1,'DBR':0},
'CBW':{'ABR':1,'BPR':1,'CBR':0,'DBR':0},'MCW':{'ABR':1,'BPR':1,'CBR':0,'DBR':1},
…

Noorulain Islam
- 343
- 2
- 9
0
votes
1 answer
model.fit in a for loop, for K-fold cross validation
I am trying to code a K-fold cross validation with LSTM architecture.
But I got an this error (edit):
Traceback (most recent call last):
File "/Users/me/Desktop/dynamicsoundtreatments/DST-features-RNN.py", line 58, in
…

nbrc
- 31
- 6
0
votes
0 answers
Error in singlefold(obs, k) : insufficient records:2, with k=5 / Unused argument (kfolds = 4)
The code I used:
competition <- ENMevaluate(occ = occ_coord, env = env, bg.coords = bg_coord, method = "randomkfold", RMvalues=seq(0.5, 5, 0.5), fc = c("L", "LQ", "H", "LQH"), algorithm='maxent.jar')
Unable to solve this, previously used a…
0
votes
0 answers
object "i' not found in r forloop. k-fold cross validation
Like the tittle says, I am trying to do k-fold cross validation. my coding skills are very basic, please explain as simply as possible.
"""
library(ISLR)
install.packages("ISLR")
library(ISLR)
install.packages("boot")
library(boot)
data <-…
0
votes
0 answers
How to split a dataset into an overlapping or non-disjoint train-test using k-fold validation python
I am working on a quite different problem where I need to split a dataset into an overlapping or non-disjoint dataset using KFOLD validation in python. I was wondering if there is any way to do that.

Shaykh_Python
- 49
- 6
0
votes
1 answer
"Wrong model type for classification" while using Caret library in R (model with qualitative variable)
I am trying to use k-fold validation to find the better k for kNN. But while I run the following code, it appeared error of "Wrong model type for classification". I had referred to the previous similar question ("Wrong model type for classification"…

文子小
- 13
- 4
0
votes
1 answer
Kfold CV in brms
I am trying to use kfold CV as a means of evaluating a model run using brms and I feel like I'm missing something. As a reproducible example, my data are structured as a binary response (0, 1) dependent on the length of an individual. Here is some…

user1997414
- 189
- 3
- 10
0
votes
1 answer
cross_val_score writes that target variable is unknown
My target variable is Survived and has only 0 and 1 values, have my following code resulted in error:
kfold = StratifiedKFold(n_splits=8,shuffle=True, random_state=42)
rs = 15
clrs =…

Ruslan Pylypyyuk
- 49
- 3
0
votes
1 answer
How to split train data and validation data properly in K fold cross validation
First, as a non-English speaker, I am using a translator to solve my problem. I ask for your understanding if the sentence is awkward and difficult to read.
I try to learn data through Kfold cross validation. However, continuous errors occur in the…

Margaret Stark
- 1
- 2
0
votes
2 answers
How can we include a prediction column in the initial dataset/dataframe after performing K-Fold cross validation?
I would like to run a K-fold cross validation on my data using a classifier. I want to include the prediction (or predicted probability) columns for each sample directly into the initial dataset/dataframe. Any ideas?
from sklearn.metrics import…

Simon Provost
- 356
- 1
- 2
- 15
0
votes
1 answer
Cannot read property 'overview' of undefined
I got the following error
Cannot read property 'overview' of undefined
I cannot figure out what this is.
{{ fold + 2 }}
{{ row.correct }}
{{…
0
votes
0 answers
Why can ROC_AUC score decrease after cross-validation?
Please help, need an advice or link to some manual.
While training the model, performed these steps:
Choosing the model (CatBoostRegressor)
Tuning hyperparameters with Optuna framework
Model with study.best_trial.params scored 0.92
Used this…

Sukharkov
- 1
- 1
- 4
0
votes
1 answer
Actual data from KFold split indices
Suppose I have the following data:
y = np.ones(10)
y[-5:] = 0
X = pd.DataFrame({'a':np.random.randint(10,20, size=(10)),
'b':np.random.randint(80,90, size=(10))})
X
a b
0 11 82
1 19 82
2 15 80
3 15 86
4 14 …
user12587364