**Table of Contents**

- Wrappers for Sklearn API
- Code Example
- Video Tutorial

**1 Wrappers for Sklearn API:**

- In this blog, we are going to learn about Keras wrappers for the sklearn API.
- We use them in our deep neural network analysis. We already know Keras is a popular library for deep learning, but the focus of the library is only on deep learning. On the other hand, the sklearn Library in Python is used for efficient numerical computation.
- It is a fully-featured library for general machine learning and provides many utilities that are useful in the development of deep learning modules.
- Keras library provides wrappers for deep learning modules to be used as classification or regulation estimators inside could learn.
- These wrappers are available in Keras. Keras model, which will then be used to feed and predict can takes both model parameters and fitting parameters.
- It also accepts parameters for calling fit, predicts, predict_proba and score methods.

**Code Example**

- Let’s see how we can implement this in Jupyter
- First, we import sequential model API from Keras in this demonstration, we only use dense layers, so we have to import them from Keras.

- This Keras classifier is used for the classification problems, which is available in sklearn.
- We will also import stratified fold and cross Välidation from SkLearn.
- load_text from numpy will help us to load the data. we load our diabetes dataset, which is available in our working directory. Our dataset contains seven hundred sixty-eight samples of nine features.

- We split our dataset into inputs with eight features and the final column as output.
- So our input data contains seven hundred sixty-eight samples of eight features, so it will be our input dimension in the model.
- Now we create a function that will generate and compile our model, this function will be used as an argument of Carus classifier. We generate a simple sequential model with only dense layers. First, the hidden layer contains four neurons with the activation function value.

- We have to mention our input dimension in this first layer. The final output layer contains only one node as this is a binary classification problem. We use the sigmoid activation function, so the output will be in the range of zero and one.
- The functions will also compile our model as this is a classification problem. We use binary cross-entropy as the loss function. We are going to define Adam as an optimizer. We will also choose accuracy as a metric.
- We passed this function to Keras classifier by the building of an argument we set epochs as hundred, so at the time of model training, it will iterate a hundred times. We said Betsi as hundred as we have seven hundred sixty-eight samples, there will be eight batches of hundred samples each.
- These verbal zero will run it silently. These are automatically bundled up and passed on the feed function, which is called internally by the Keras classifier.
- Then we use sklearn stratified fold, to perform stratified cross-validation. This is a resampling technique that we can provide a robust estimate of the performance of a machine learning model on unseen data.

Finally, we use the skLearn Function Cross_val_ score to evaluate our model using the cross-validation scheme. So our model is around 67.84 percent accurate.