Multiple Regression Implementation in Python
Multiple Regression Implementation in Python
Description: Multiple Regression is a statistical method used to model the relationship between a
dependent variable and two or more independent variables. It aims to find the best-fitting hyperplane that
predicts the dependent variable based on the multiple independent [Link]
Goal:
The goal is to find the values of m1,m2,…,mnm_1, m_2, \dots, m_nm1,m2,…,mn and bbb that minimize
the error between the predicted and actual values.
Key Concepts:
● Best Fit Hyperplane: The hyperplane that minimizes the sum of squared errors (differences
between actual and predicted values of yyy).
● R-squared: A metric used to evaluate how well the model explains the variance in the data.
Ranges from 0 to 1.
Implementation:
import pandas as pd
import [Link] as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from [Link] import LabelEncoder
from [Link] import mean_squared_error, r2_score
# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train model
model = LinearRegression()
[Link](X_train, y_train)
# Predict
y_pred = [Link](X_test)
# Evaluate
print("Mean Squared Error:", mean_squared_error(y_test, y_pred))
print("R² Score:", r2_score(y_test, y_pred))
# Coefficients
coeff_df = [Link]({
'Feature': features,
'Coefficient': model.coef_
})
Description: Statistical operations on real-world data involve applying various statistical techniques to
analyze and interpret data collected from real-world phenomena. These operations help in understanding
patterns, making predictions, and drawing conclusions from empirical data. The goal is to summarize,
infer, and model the underlying processes governing the data.
● Descriptive Statistics: Techniques used to summarize and describe the main features of a
dataset, such as:
○ Mean: The average value of a dataset.
○ Median: The middle value of the dataset when arranged in ascending order.
○ Mode: The most frequent value in the dataset.
○ Standard Deviation: A measure of the spread or dispersion of the data.
○ Variance: The square of the standard deviation, showing the degree of variation in the
data.
● Inferential Statistics: Methods that use sample data to make inferences about a larger
population, such as:
○ Linear Regression: As described earlier, used for predicting a dependent variable based
on one or more independent variables.
○ Logistic Regression: Used for binary classification tasks (e.g., predicting whether an
event will happen or not).
● Correlation Analysis: A method to determine the strength and direction of the relationship
between two variables, typically using:
Goal:
The goal of performing statistical operations on real-world data is to gain actionable insights, make
informed decisions, and provide evidence to support hypotheses or predictions.
Key Concepts:
● Data Cleaning: Ensuring that the data is free from errors, missing values, or outliers before
applying statistical methods.
● Sampling: The process of selecting a subset of data from a larger population for analysis.
● Modeling and Prediction: Using the results of statistical operations to build models that can
predict future outcomes based on historical data.
Flow Chart:
[Link](figsize=(7, 5))
[Link]([Link](), annot=True, cmap='coolwarm')
[Link]("Correlation Matrix Heatmap")
plt.tight_layout()
[Link]()
Description:
Data Visualization is the graphical representation of data to help understand trends, patterns, and outliers
in a dataset. It enables users to interpret complex data more easily and make decisions based on visual
insights. Visualization techniques are commonly used to communicate information clearly and effectively
to stakeholders or in reports.
● Bar Charts: Represent categorical data with rectangular bars, where the length of each bar
corresponds to the value of the category.
● Line Graphs: Show trends over time by connecting data points with a line. They are ideal for
visualizing continuous data.
● Pie Charts: Display proportions of a whole using slices. Each slice represents a category's
contribution to the total.
● Scatter Plots: Show the relationship between two continuous variables by plotting points on a
Cartesian plane. They help in identifying correlations or patterns.
● Histograms: Show the distribution of a single continuous variable by dividing the range of data
into bins and plotting the frequency of data points in each bin.
● Heatmaps: Use color gradients to represent data values in a matrix form. Useful for identifying
patterns in large datasets, such as correlation matrices.
● Box Plots: Display the distribution of a dataset through its quartiles and highlight outliers. They
are useful for comparing distributions across different groups.
Goal:
The goal of data visualization is to present data in a way that is easy to interpret, facilitates
understanding, and allows stakeholders to make decisions quickly based on clear insights from the data.
Key Concepts:
● Clarity: Visualizations should simplify complex data and make it accessible and understandable.
● Design Principles: Proper use of color, scale, and layout to make visualizations effective.
Avoiding misleading visuals is key.
● Interactivity: Interactive visualizations allow users to explore the data by zooming, filtering, or
hovering over elements for more details.
● Dashboarding: Combining multiple visualizations into a single interface to provide an overview
of key metrics, trends, and insights.
● Matplotlib / Seaborn (Python): Popular libraries for static and interactive plots.
Implementation:
import pandas as pd
import [Link] as plt
import seaborn as sns
from [Link] import LabelEncoder
# Load dataset
df = pd.read_csv("Dataset/[Link]")
Objective : Implement various Data Transformation Techniques. Perform data scaling or normalization
on numerical features. Encode categorical variables using techniques like one-hot encoding or label
encoding.
Description:
Data transformation techniques are crucial preprocessing steps in any machine learning pipeline. These
techniques help prepare raw data into a suitable format for training models. The main goals are to ensure
that numerical values are on a comparable scale, to handle categorical variables effectively, and to
improve model performance and convergence speed.
1. Scaling / Normalization (for Numerical Features): Scaling techniques bring all numerical
values into a uniform range, which helps algorithms (especially those based on distance metrics
or gradient descent) perform optimally.
2. Encoding Categorical Variables: Many machine learning models cannot work with raw
categorical data. Encoding converts categorical values into a numerical format.
Label Encoding:
Converts each category to a unique integer. Useful for ordinal data (e.g., "Low" < "Medium" <
"High").
One-Hot Encoding:
Creates binary columns for each category. Useful for nominal data (e.g., colors, product types).
For example, Color = Red becomes:
Red: 1, Blue: 0, Green: 0.
Key Concepts:
● Why Scale?
Algorithms like KNN, SVM, and Gradient Descent-based models are sensitive to the scale of
input features.
● Why Encoding?
Categorical features must be numeric for models to interpret them. Encoding allows the model to
handle both ordinal and nominal data effectively.
Goal:
To transform raw data into a numerical and scaled format that can be efficiently processed by machine
learning models. Proper transformation improves model accuracy, convergence, and generalization.
Implementation:
import pandas as pd
from [Link] import StandardScaler, MinMaxScaler, Normalizer, LabelEncoder,
OneHotEncoder
# Load dataset
df = pd.read_csv("Dataset/[Link]")
# ============================
# 1. Encode Categorical Columns
# ============================
# ============================
# 2. Scale Numerical Features
# ============================
# ============================
# 3. Show Results
# ============================
print("\n--- Label Encoded + One-Hot Encoded Data Sample ---\n", [Link]())
print("\n--- Standard Scaled Data Sample ---\n", df_standard[numerical_cols].head())
print("\n--- Min-Max Scaled Data Sample ---\n", df_minmax[numerical_cols].head())
print("\n--- Normalized Data Sample ---\n", df_normalized[numerical_cols].head())
Description:
Splitting a dataset into training and testing sets is a fundamental step in the machine learning pipeline. It
helps to evaluate the performance of a model by training it on one subset (training set) and testing it on
another (testing set), ensuring that the model generalizes well to unseen data. Typically, the dataset is split
in such a way that the model can learn from a portion of the data and be evaluated on a separate portion to
check for overfitting.
3. Shuffling: Randomly shuffle the dataset before splitting to ensure that the training and testing
sets are representative of the overall data distribution.
4. Splitting Ratio: Common splitting ratios are:
○ 70% / 30%: 70% of the data for training and 30% for testing.
○ 80% / 20%: 80% of the data for training and 20% for testing.
○ 90% / 10%: 90% of the data for training and 10% for testing.
The exact ratio depends on the dataset size and the problem.
5. Stratified Splitting (if applicable): For classification problems, it's important to maintain the
distribution of the classes in both the training and testing sets. This ensures that the model is
trained on a balanced representation of each class.
Key Concepts:
● Training Set: The subset of data used to train the model. It teaches the model to learn patterns
and relationships.
● Testing Set: The subset of data used to evaluate the model's performance. It tests how well the
model generalizes to new, unseen data.
● Random State: A random seed for reproducibility, ensuring that the data split is the same every
time the code is run.
● Stratified Split: Ensures that the class distribution in the training and testing sets is similar,
especially in imbalanced datasets.
Goal:
The goal of splitting the dataset is to ensure that the model is not overfitting to the training data and can
generalize effectively when faced with new data during testing.
Implementation:
import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
Output:
Objective : Build a classification model to predict the species of iris flowers using the famous Iris dataset
Logistic Regression
Description:
A classification model is a type of machine learning algorithm used to predict a categorical label or class
for a given input. In classification tasks, the goal is to assign each input data point to one of the
predefined classes based on its features. The model learns patterns in the training data and then applies
those patterns to predict the class of unseen data in the testing set.
● Training the Model: The process of teaching the model using labeled data so that it learns to
map inputs to correct class labels.
● Prediction: Using the trained model to classify new, unseen data into predefined classes.
● Evaluation Metrics:
○ Accuracy: The overall proportion of correct predictions.
○ Precision: The ratio of true positives to the total predicted positives.
○ Recall: The ratio of true positives to the total actual positives.
○ F1-score: The harmonic mean of precision and recall, useful when balancing the trade-
off between the two.
Goal:
The goal of building a classification model is to correctly predict the class label of new data based on the
learned patterns from the training data. This model is then evaluated and refined to improve accuracy and
generalization.
Flow Chart:
Implementation:
# Load dataset
df = pd.read_csv("Dataset/[Link]")
# Split dataset
X_train, X_test, y_train, y_test = train_test_split(X, y_encoded, test_size=0.2, random_state=42)
# Predict
y_pred = [Link](X_test)
# Evaluation
print("Accuracy:", accuracy_score(y_test, y_pred))
print("\nClassification Report:\n", classification_report(y_test, y_pred, target_names=le.classes_))
print("Confusion Matrix:\n", confusion_matrix(y_test, y_pred))
Objective : Train and evaluate each model using appropriate metrics (e.g., accuracy, precision, recall, F1-
score).
Description:
Training and evaluating a machine learning model involves using appropriate metrics to assess its
performance. These metrics help determine how well the model is learning from the data and generalizing
to unseen examples. The choice of evaluation metrics depends on the type of model (e.g., classification or
regression) and the nature of the problem (e.g., balanced or imbalanced classes).
For classification tasks, metrics like accuracy, precision, recall, and F1-score are commonly used to
evaluate model performance.
○ Choose an appropriate algorithm for the problem (e.g., Logistic Regression, Random
Forest, SVM).
○ Fit the model to the training data to learn the relationships between the features and the
target variable.
2. Make Predictions:
○ Once the model is trained, use it to predict the labels for the testing set or new data.
○ Accuracy: Measures the overall correctness of the model, calculated as the proportion of
correct predictions.
○ Precision: The proportion of true positive predictions out of all positive predictions made
by the model. Useful when the cost of false positives is high (e.g., in spam detection).
○ Recall (Sensitivity): The proportion of true positive predictions out of all actual positive
instances in the dataset. Crucial when the cost of false negatives is high (e.g., in medical
○ F1-Score: The harmonic mean of precision and recall, providing a balance between the
two. It is particularly useful when the classes are imbalanced.
○ Confusion Matrix: A table that shows the performance of the classification model by
comparing actual vs. predicted values, containing true positives (TP), false positives (FP),
true negatives (TN), and false negatives (FN).
○ Use the chosen metrics to evaluate the performance of the model on the testing set.
Key Concepts:
● Accuracy: Measures how often the model correctly predicts the class label.
● Precision: Important when false positives are costly; it ensures the model only predicts positives
when confident.
● Recall: Important when false negatives are costly; it ensures the model identifies as many
positives as possible.
● F1-Score: Balances precision and recall, providing a single metric for models with imbalanced
classes.
● Confusion Matrix: A detailed breakdown of how well the model performs in terms of true and
false positives and negatives.
Goal:
The goal of training and evaluating a model using appropriate metrics is to assess its effectiveness and
reliability. By using a combination of metrics, you can gain a deeper understanding of the model's
strengths and weaknesses and determine whether it is suitable for deployment in real-world applications.
Implementation:
from [Link] import load_iris
from sklearn.model_selection import train_test_split
from [Link] import StandardScaler
from [Link] import accuracy_score, precision_score, recall_score, f1_score
from sklearn.linear_model import LogisticRegression
from [Link] import DecisionTreeClassifier
from [Link] import RandomForestClassifier
from [Link] import SVC
from sklearn.naive_bayes import GaussianNB
#Standardize features
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = [Link](X_test)
Description:
A Multilayer Perceptron (MLP) is a class of feedforward artificial neural network consisting of multiple
layers of nodes, often organized into an input layer, one or more hidden layers, and an output layer. It is a
supervised learning algorithm used for classification and regression tasks. MLPs can learn complex
relationships in data through backpropagation, making them powerful tools for modeling nonlinear data.
Structure of MLP:
● Input Layer: The first layer, where data is fed into the model. Each node in the input layer
corresponds to a feature in the dataset.
● Hidden Layers: One or more layers of neurons that perform computations and learn patterns in
the data. The number of neurons and layers can vary based on the problem and complexity of the
data.
● Output Layer: The final layer that produces predictions. For classification tasks, the output layer
typically uses a softmax (for multi-class problems) or sigmoid (for binary classification)
activation function.
Key Components:
1. Neurons (Nodes): The basic unit of an MLP. Each neuron computes a weighted sum of its inputs
and applies an activation function.
2. Weights: Parameters that define the importance of each input to the neuron. Weights are learned
during training through backpropagation.
3. Bias: An additional parameter added to the weighted sum before applying the activation function
to shift the activation.
4. Activation Function: A mathematical function that determines the output of a neuron. Common
activation functions include:
○ Sigmoid: Used for binary classification, squashes output to a value between 0 and 1.
○ ReLU (Rectified Linear Unit): Used in hidden layers, outputs zero if the input is less
than zero, and the input itself if it is greater than zero.
1. Forward Propagation: Input data is passed through the network, where it is processed by each
layer and the final output is produced.
2. Loss Function: The loss function calculates the error between the predicted output and the actual
label (e.g., Cross-Entropy for classification).
3. Backpropagation: The process of adjusting the weights and biases using the gradient of the loss
function. It aims to minimize the error by updating parameters.
4. Optimization: Typically, gradient descent or variants (like Adam) are used to minimize the loss
function by iteratively adjusting the model’s weights.
Key Concepts:
● Feedforward Network: The architecture where data flows in one direction, from input to output,
with no loops.
● Backpropagation: The process of updating weights and biases to minimize the model’s error.
● Gradient Descent: An optimization technique used to minimize the loss function by adjusting
weights based on the gradient of the error.
● Overfitting and Underfitting: Overfitting occurs when the model is too complex and fits the
training data too well, whereas underfitting occurs when the model is too simple and fails to
capture the underlying patterns in the data.
Goal:
The goal of using a Multilayer Perceptron is to model complex relationships between input data and
output labels. By learning from the data through backpropagation and optimizing weights, MLPs can be
applied to various machine learning tasks such as classification, regression, and pattern recognition.
Implementation:
import pandas as pd
from sklearn.model_selection import train_test_split
from [Link] import LabelEncoder, StandardScaler
from sklearn.neural_network import MLPClassifier
from [Link] import classification_report, confusion_matrix, accuracy_score
# Load dataset
df = pd.read_csv("Dataset/[Link]")
# Predict
y_pred = [Link](X_test)
# Evaluate
print("Accuracy:", accuracy_score(y_test, y_pred))
print("\nClassification Report:\n", classification_report(y_test, y_pred, target_names=le.classes_))
print("Confusion Matrix:\n", confusion_matrix(y_test, y_pred))
Output:
Objective : WAP in python to implement ANN model for fashion MNIST dataset.
Description:
An Artificial Neural Network (ANN) is a computational model inspired by the structure and function of
the human brain. It is composed of interconnected nodes (or neurons) arranged in layers, which work
together to recognize patterns and make predictions. ANNs are used for a wide range of tasks, including
classification, regression, and pattern recognition, and are a key component of deep learning models.
Structure of an ANN:
1. Input Layer: The first layer that receives the input features. Each neuron in this layer
corresponds to one feature of the input data.
2. Hidden Layers: Layers between the input and output layers, where computation takes place. An
ANN can have multiple hidden layers, allowing the model to learn complex patterns.
3. Output Layer: The final layer that provides the model's predictions. For classification, it
produces class labels; for regression, it gives continuous values.
4. Neurons (Nodes): Basic computational units that process information. Each neuron receives
inputs, applies a weight to them, adds a bias, and then passes the result through an activation
function.
5. Weights: Parameters that control the strength of the connection between neurons. Weights are
learned during training to minimize the error.
6. Bias: A parameter added to the weighted sum of inputs to shift the activation function. Bias helps
the model adjust the output independently of the input.
7. Activation Function: A mathematical function that introduces non-linearity into the network.
Common activation functions include:
○ ReLU (Rectified Linear Unit): Outputs zero for negative inputs and the input itself for
positive inputs, commonly used in hidden layers.
○ Softmax: Used in the output layer for multi-class classification, converting outputs into
probabilities.
1. Forward Propagation: Input data is passed through the network, layer by layer, to generate an
output.
2. Loss Function: The difference between the predicted output and the actual target is computed
using a loss function (e.g., Cross-Entropy for classification or Mean Squared Error for
regression).
3. Backpropagation: The process of updating the weights and biases using the gradient of the loss
function with respect to each parameter. This allows the model to minimize the error and improve
its predictions.
4. Optimization Algorithm: The weights are updated using optimization algorithms like Gradient
Descent, Stochastic Gradient Descent (SGD), or Adam to minimize the loss.
Key Concepts:
● Neural Network Architecture: The arrangement of neurons in layers (input, hidden, and output)
plays a crucial role in determining the model's capacity to learn from data.
● Forward Propagation: The process where input data flows through the network to produce an
output.
● Backpropagation: A technique used to minimize the error by adjusting weights based on the
gradient of the loss function.
● Activation Functions: Functions like ReLU, Sigmoid, and Softmax allow the network to model
complex, non-linear relationships in data.
● Optimization: Methods like Gradient Descent or Adam are used to update the model parameters
in order to reduce the loss.
Goal:
The goal of an Artificial Neural Network is to learn from the input data and make accurate predictions or
classifications. By adjusting weights and biases through backpropagation, ANNs improve their ability to
generalize to new, unseen data. ANNs are widely used in applications like image recognition, speech
recognition, natural language processing, and more.
Implementation:
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from [Link] import LabelEncoder, StandardScaler
from [Link] import Sequential
from [Link] import Dense
#feature scaling
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
Output:
Objective : WAP in python to understand various activation functions and its uses.
Description:
Activation functions are mathematical functions used in neural networks to introduce non-linearity into
the model. They determine the output of a neuron based on its input, helping the network learn complex
patterns. Without activation functions, neural networks would only be able to model linear relationships,
limiting their ability to solve complex problems.
○ Range: (0, 1)
○ Commonly used in the output layer for binary classification tasks, where the output needs
to be a probability (between 0 and 1).
○ Cons: Can cause vanishing gradients, where large negative or positive inputs result in
gradients close to zero, slowing down learning.
○ Range: [0, ∞)
○ The most commonly used activation function in the hidden layers of neural networks.
○ Pros: Efficient and helps mitigate the vanishing gradient problem. It speeds up training in
deep networks.
○ Cons: Can lead to dead neurons (a phenomenon where neurons never activate, resulting
in no gradient for them during backpropagation). This is known as the "dying ReLU"
problem.
○ Range: (-∞, ∞)
○ A modified version of ReLU that allows a small, non-zero gradient when xxx is less than
zero, helping prevent dead neurons.
○ Cons: Still not a perfect solution and can result in slightly slower training compared to
ReLU.
○ Range: (-1, 1)
○ A scaled version of the sigmoid function, where the output is centered around zero,
making it less likely to cause the vanishing gradient problem.
○ Cons: Like sigmoid, it can still suffer from vanishing gradients for very large or very
small values of xxx.
○ Range: (0, 1) for each class, and the sum of all outputs equals 1.
○ Pros: Converts raw network output into probability distributions over multiple classes,
making it suitable for multi-class classification tasks.
○ Range: (-∞, ∞)
○ Pros: Can outperform ReLU in some cases, especially in deeper networks, as it avoids
the dead neuron problem and has a smoother gradient.
○ Range: (-α, ∞)
○ Pros: Solves the vanishing gradient problem better than ReLU by allowing negative
values. It can help improve learning in deeper networks.
○ Cons: More computationally expensive than ReLU, and the choice of α\alphaα can affect
performance
Key Concepts:
● Non-linearity: Activation functions allow neural networks to model complex relationships that
are not just linear.
● Vanishing Gradient Problem: Some activation functions like Sigmoid and Tanh can cause
gradients to become very small, making learning slow or even impossible in deep networks.
● Dead Neurons: ReLU can cause neurons to become "dead" (always outputting zero), making
them unable to contribute to learning.
Goal:
The goal of using activation functions is to enable the neural network to learn complex patterns in data.
Flow Chart:
Implementation:
import numpy as np
import [Link] as plt
def step(x):
return [Link](x >= 0, 1, 0)
def tanh(x):
"""Tangent function: squashes values b/w -1 and 1"""
return [Link](x)
def relu(x):
"""ReLU function: outputs x if +ve, else 0"""
return [Link](0,x)
plt.tight_layout()
[Link]()
Description:
A Convolutional Neural Network (CNN) is a specialized type of deep neural network designed for
processing structured grid data, such as images, video, or audio. CNNs are widely used for image
recognition, classification, and processing tasks due to their ability to automatically learn spatial
hierarchies of features (edges, shapes, textures, etc.) from the data.
CNNs consist of multiple layers, including convolutional layers, pooling layers, and fully connected
layers. The architecture enables the model to capture both local and global patterns in data, making it
highly effective for tasks involving visual or temporal patterns.
Structure of CNN:
1. Input Layer:
○ The raw data (e.g., image) is input into the network. For images, this is typically a 3D
matrix (height, width, channels), where the channels represent the color channels (RGB).
2. Convolutional Layer:
○ The core building block of a CNN. This layer applies convolution operations using a set
of filters (kernels) that slide over the input image. The result is a set of feature maps that
capture spatial hierarchies in the data.
○ Filters (Kernels): Small, learnable weight matrices that are convolved with the input to
extract local features like edges, corners, or textures.
○ Stride and Padding: The stride determines how much the filter moves after each
operation, while padding is used to preserve the input dimensions by adding zeros around
the border.
○ After each convolution operation, a non-linear activation function like ReLU is applied to
introduce non-linearity, enabling the network to learn more complex patterns.
○ Typically used after a convolutional layer, pooling reduces the spatial dimensions (height
and width) of the feature maps while retaining the most important information. Common
pooling operations include:
○ After several convolution and pooling layers, the CNN is usually followed by fully
connected layers (also known as dense layers), which are similar to those in regular
neural networks. These layers are responsible for combining features learned by the
convolutional layers to make predictions.
6. Output Layer:
○ For classification tasks, the output layer typically uses a softmax activation function (for
multi-class classification) or a sigmoid activation function (for binary classification) to
produce the final prediction probabilities.
Key Concepts:
● Convolution: A mathematical operation that involves sliding a filter over the input image to
extract local patterns. The result of a convolution operation is a feature map.
● Feature Maps: Output from the convolutional layer, representing the learned features at different
spatial locations.
● Stride: The number of pixels the filter shifts during convolution. Larger strides result in smaller
feature maps.
● Padding: Adding extra pixels around the input image to preserve its dimensions after
convolution.
● Pooling: A downsampling operation that reduces the dimensionality of feature maps, helping to
reduce computational complexity and mitigate overfitting.
Goal:
The goal of a CNN is to automatically and adaptively learn spatial hierarchies of features from input data,
making it particularly well-suited for tasks like image classification, object detection, and facial
Implementation:
from [Link] import mnist
from [Link] import Sequential
from [Link] import Conv2D, MaxPool2D, Flatten, Dropout, Dense
#Loading dataset
(X_train, y_train), (X_test, y_test) = mnist.load_data()
#reshape data
X_train = X_train.reshape((X_train.shape[0],X_train.shape[1], X_train.shape[2],1))
X_test = X_test.reshape((X_test.shape[0], X_test.shape[1],X_test.shape[2],1))
#define model
model = Sequential()
Output: