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
0 answers

How to extract mape values with SVR Algorithm using kfold cross validation?

#MAPE SVR ####### K-fold cross validation ####### # Defining a custom function to calculate accuracy # Make sure there are no zeros in the Target variable if you are using MAPE from sklearn.model_selection import train_test_split,…
0
votes
0 answers

3 folds CV with Random Forest

I have trouble perfomring this code. I do not know how to implement k=3 fold for the following: background on Liver file, 345 obs, 7 variables, the last variable is binary response: gr 1 is severe, gr 2 is non severe. This was an assignment and I am…
JSG
  • 11
  • 1
0
votes
1 answer

"ValueError: Supported target types are: ('binary', 'multiclass'). Got 'unknown' instead." in dataset kfold split

I have encountered this error "ValueError: Supported target types are: ('binary', 'multiclass'). Got 'unknown' instead." while running this python code line 5 1 print(data.datasetsNames) 2 for dataset in data.datasetsNames: 3 X, Y,…
0
votes
0 answers

Calculate metrics after K-Fold Cross Validation

I'm doing a thesis on ML: I have to run 4 models (linear regression, robust regression, binary logistic regression and naive bayes classifier) on severals CSV files. I started my approach reading the official reference and trying something. Being my…
0
votes
1 answer

Trying to use a KFold split to create test and train datasets and the test_index values are different for each split after the second split

Please see code below. For some reason when i split using the kfold method, after the second split, the length of the sample changes. import pandas as pd from matplotlib import pyplot as plt import seaborn as sns import numpy as np from…
0
votes
1 answer

How to properly use MeanEncoder for categorical encoding in a k fold loop

I want to use MeanEncoder from the feature-engine in my k-fold loop for encoding categorical data. It seems that after the tranform step the encoder introduces NaN values for certain columns in my dataset. The code is as follows from…
0
votes
0 answers

How to obtain Accuracy, Cohen's Kappa, and AUC values from k fold cross validation?

I would like to obtain not only Accuracy and Cohen's kappa values from a k-fold cross validation, but AUC as well. I know how to obtain the avereage Accuracy, Cohen's Kappa, and AUC, as well as the Accuracy and Cohen's kappa for each fold, but I…
Kinz
  • 33
  • 4
0
votes
1 answer

Matlab's TreeBagger and k-fold cross validation

I am trying to get the 5-fold cross validation error of a model created with TreeBagger using the function crossval but I keep getting an error Error using crossval>evalFun The function 'regrTree' generated the following error: Too many input…
xoani
  • 107
  • 1
  • 1
  • 13
0
votes
1 answer

Does StratifiedKFold splits the same each time a for loop is called?

I use StratifiedKFold and a form of grid search for my Logistic Regression. skf = StratifiedKFold(n_splits=6, shuffle=True, random_state=SEED) I call this for loop for each combination of parameters: for fold, (trn_idx, test_idx) in…
Yana
  • 785
  • 8
  • 23
0
votes
1 answer

Alternative to Using Repeated Stratified K Fold with Multiple Outputs?

I am exploring the number of features that would be best to use for my models. I understand that a Repeated Stratified K Fold requires 1 1D array output while I am trying to evaluate the number of features for an output that has multiple outputs. Is…
0
votes
2 answers

Passing one variable from one class to another

i am take the no. of iteration in for loop running from a different class. for e in range(1,EPOCHS+1 ): g=0 for j in range (jin): g=g+1 print(g) train_epoch_loss = 0 train_epoch_acc = 0 p1=cross(g) #pw=pq.save(g) …
luffy
  • 11
  • 3
0
votes
0 answers

K fold cross validation not working properly

I have created a transfer learning model with RESNET-50. I am using K-fold cross-validation in my model. However, my model is not performing properly. Although I didn't get any error messages, my accuracy values are very weird. They are the same…
farabee
  • 3
  • 1
  • 7
0
votes
0 answers

Generate and assemble model predictions for each stratified kfold test split

I would like to generate multiple test data splits using stratified KFold (skf) and then generate/assemble predictions for each of these test data splits (and hence all of the data) using a sklearn model. I am at a wits end on how to do this…
veg2020
  • 956
  • 10
  • 27
0
votes
1 answer

evaluation about K-fold cross validation

After K-fold cross validation, which evaluation metric was averaged? Precision and recall, or F-measure? import pandas as pd import numpy as np from sklearn.model_selection import KFold KFold(n_splits=2, random_state=None, shuffle=False)
ryrie23
  • 51
  • 6
0
votes
1 answer

plot and save history of kfold training

i am trying to train model with kfold cross validation , now i want to keep history for plotting and saving the history. how can i do that? it seems that some questions post answers of this question but i want to save and plot all history once, not…
Ali Zareshahi
  • 508
  • 5
  • 15