cross-validation

Should Cross Validation Score be performed on original or split data?

空扰寡人 提交于 2021-02-11 14:46:21
问题 When I want to evaluate my model with cross validation, should I perform cross validation on original (data thats not split on train and test) or on train / test data? I know that training data is used for fitting the model, and testing for evaluating. If I use cross validation, should I still split the data into train and test, or not? features = df.iloc[:,4:-1] results = df.iloc[:,-1] x_train, x_test, y_train, y_test = train_test_split(features, results, test_size=0.3, random_state=0) clf =

Using custom estimator with cross_val_score fails

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 12:29:09
问题 I am trying to use cross_val_score with a customized estimator. It is important that this estimator receives a member variable which can be used later inside the fit function. But it seems inside cross_val_score the member variables are destroyed (or a new instance of the estimator is being created). Here is the minimal code which can reproduce the error: from sklearn.model_selection import cross_val_score from sklearn.base import BaseEstimator class MyEstimator(BaseEstimator): def __init__

'PolynomialFeatures' object has no attribute 'predict'

跟風遠走 提交于 2021-02-10 11:55:51
问题 I want to apply k-fold cross validation on the following regression models: Linear Regression Polynomial Regression Support Vector Regression Decision Tree Regression Random Forest Regression I am able to apply k-fold cross validation on all except polynomial regression which gives me this error PolynomialFeatures' object has no attribute 'predict . How to work around this issue. Also am I doing the job correctly, actually my main motive is to see which model is performing better, so is there

'PolynomialFeatures' object has no attribute 'predict'

核能气质少年 提交于 2021-02-10 11:55:15
问题 I want to apply k-fold cross validation on the following regression models: Linear Regression Polynomial Regression Support Vector Regression Decision Tree Regression Random Forest Regression I am able to apply k-fold cross validation on all except polynomial regression which gives me this error PolynomialFeatures' object has no attribute 'predict . How to work around this issue. Also am I doing the job correctly, actually my main motive is to see which model is performing better, so is there

K fold cross validation using keras

余生颓废 提交于 2021-02-06 19:17:30
问题 It seems that k-fold cross validation in convn net is not taken seriously due to huge running time of the neural network. I have a small data-set and I am interested in doing k-fold cross validation using the example given here. Is it possible? Thanks. 回答1: If you are using images with data generators, here's one way to do 10-fold cross-validation with Keras and scikit-learn. The strategy is to copy the files to training , validation , and test subfolders according to each fold. import numpy

K fold cross validation using keras

ぐ巨炮叔叔 提交于 2021-02-06 19:16:51
问题 It seems that k-fold cross validation in convn net is not taken seriously due to huge running time of the neural network. I have a small data-set and I am interested in doing k-fold cross validation using the example given here. Is it possible? Thanks. 回答1: If you are using images with data generators, here's one way to do 10-fold cross-validation with Keras and scikit-learn. The strategy is to copy the files to training , validation , and test subfolders according to each fold. import numpy

K fold cross validation using keras

℡╲_俬逩灬. 提交于 2021-02-06 19:16:19
问题 It seems that k-fold cross validation in convn net is not taken seriously due to huge running time of the neural network. I have a small data-set and I am interested in doing k-fold cross validation using the example given here. Is it possible? Thanks. 回答1: If you are using images with data generators, here's one way to do 10-fold cross-validation with Keras and scikit-learn. The strategy is to copy the files to training , validation , and test subfolders according to each fold. import numpy

K fold cross validation using keras

匆匆过客 提交于 2021-02-06 19:13:46
问题 It seems that k-fold cross validation in convn net is not taken seriously due to huge running time of the neural network. I have a small data-set and I am interested in doing k-fold cross validation using the example given here. Is it possible? Thanks. 回答1: If you are using images with data generators, here's one way to do 10-fold cross-validation with Keras and scikit-learn. The strategy is to copy the files to training , validation , and test subfolders according to each fold. import numpy

K fold cross validation using keras

三世轮回 提交于 2021-02-06 19:09:44
问题 It seems that k-fold cross validation in convn net is not taken seriously due to huge running time of the neural network. I have a small data-set and I am interested in doing k-fold cross validation using the example given here. Is it possible? Thanks. 回答1: If you are using images with data generators, here's one way to do 10-fold cross-validation with Keras and scikit-learn. The strategy is to copy the files to training , validation , and test subfolders according to each fold. import numpy

Why is cross_val_predict so much slower than fit for KNeighborsClassifier?

我们两清 提交于 2021-02-06 12:55:23
问题 Running locally on a Jupyter notebook and using the MNIST dataset (28k entries, 28x28 pixels per image, the following takes 27 seconds . from sklearn.neighbors import KNeighborsClassifier knn_clf = KNeighborsClassifier(n_jobs=1) knn_clf.fit(pixels, labels) However, the following takes 1722 seconds , in other words ~64 times longer : from sklearn.model_selection import cross_val_predict y_train_pred = cross_val_predict(knn_clf, pixels, labels, cv = 3, n_jobs=1) My naive understanding is that