Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How the pipeline works: alt text

The make_pipeline function takes an arbitrary number of scikit-learn transformers (objects that support the fit and transform methods as input), followed by a scikit-learn estimator that implements the fit and predict methods. In our preceding code example, we provided two scikit-learn transformers, StandardScaler and PCA, and a LogisticRegression estimator as inputs to the make_pipeline function, which constructs a scikit-learn Pipeline object from these objects. We can think of a scikit-learn Pipeline as a meta-estimator or wrapper around those individual transformers and estimators. If we call the fit method of Pipeline, the data will be passed down a series of transformers via fit and transform calls on these intermediate steps until it arrives at the estimator object (the final element in a pipeline). The estimator will then be fitted to the transformed training data. When we executed the fit method on the pipe_lr pipeline in the preceding code example, StandardScaler first performed fit and transform calls on the training data. Second, the transformed training data was passed on to the next object in the pipeline, PCA. Similar to the previous step, PCA also executed fit and transform on the scaled input data and passed it to the final element of the pipeline, the estimator. Finally, the LogisticRegression estimator was fit to the training data after it underwent transformations via StandardScaler and PCA. Again, we should note that there is no limit to the number of intermediate steps in a pipeline; however, if we want to use the pipeline for prediction tasks, the last pipeline element has to be an estimator. Similar to calling fit on a pipeline, pipelines also implement a predict method if the last step in the pipeline is an estimator. If we feed a dataset to the predict call of a Pipeline object instance, the data will pass through the intermediate steps via transform calls. In the final step, the estimator object will then return a prediction on the transformed data.

Using k-fold cross-validation to assess model performance

The holdout method

alt text Model selection refers to given classification problem for whihc we want to select optimal values of tuning problems(Hyperparameters)

What is K-Fold Cross-Validation?

K-fold cross-validation is a way to test how well a machine learning model will perform on unseen data by splitting the dataset into k equal parts (folds). Instead of training once and testing once (like the simple train-test split), we train and test k times, each time using a different fold as the test set.

How It Works

  • Split the dataset into k folds (say, k = 5).
  • Iteration 1: Train on folds 1–4, test on fold 5.
  • Iteration 2: Train on folds 1–3 + 5, test on fold 4.
  • Repeat until each fold has been used as the test set once.
  • Average the results across all k runs → this gives a more reliable performance estimate.

LOOCV(leave-one-out cross-validation (LOOCV)) . In LOOCV, we set the number of folds equal to the number of training examples (k = n) so that only one training example is used for testing during each iteration, which is a recommended approach for working with very small datasets.

About

In this repo I pipeline stratified K-fold cross-validation, sequential feature scaling and dimensionality reduction via PCA, ensemble hyperparameter tuning methodologies (GridSearchCV, RandomizedSearchCV, HalvingRandomSearchCV), multi-metric performance evaluation including ROC-AUC curves, class imbalance mitigation

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages