MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to do upsampling and down sampling using keras?

# How to do upsampling and down sampling using keras?

This recipe helps you do upsampling and down sampling using keras

```
import numpy as np
from keras.models import Sequential
from keras.layers import UpSampling2D
```

We will define an input array and reshape it, to feed it to the model.

```
# define input data
X = np.array([10, 6, 3, 20])
# show input data for context
print(X)
# reshape input data into one sample a sample with a channel
X = X.reshape((1, 2, 2, 1))
# define model
model = Sequential()
model.add(UpSampling2D(input_shape=(2, 2, 1)))
# summarize the model
model.summary()
# make a prediction with the model
y_pred = model.predict(X)
# reshape output to remove channel to make printing easier
y_pred = y_pred.reshape((4, 4))
# summarize output
print(y_pred)
```

[10 6 3 20] Model: "sequential_1" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= up_sampling2d_1 (UpSampling2 (None, 4, 4, 1) 0 ================================================================= Total params: 0 Trainable params: 0 Non-trainable params: 0 _________________________________________________________________ [[10. 10. 6. 6.] [10. 10. 6. 6.] [ 3. 3. 20. 20.] [ 3. 3. 20. 20.]]

Define the model as Sequential and add UpSampling to it.

```
# define model
model = Sequential()
model.add(UpSampling2D(input_shape=(2, 2, 1)))
# summarize the model
model.summary()
```

```
y_pred = model.predict(X)
# reshape output to remove channel to make printing easier
y_pred = y_pred.reshape((4, 4))
# summarize output
print(y_pred)
```

The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.