ML Exp. 1-10 Output
ML Exp. 1-10 Output
THEORY:
Introduction to Anaconda
Anaconda distribution, a comprehensive platform for data science and scientific computing in
Python. Anaconda simplifies the process of setting up and working with various libraries and
tools commonly used in data science, machine learning, and scientific computing.
Experiment Steps:
1. Installation of Anaconda
1. Download Anaconda:
Go to the Anaconda website.
Choose the appropriate version for your operating system (Windows, macOS,
Linux) and download the installer.
2. Install Anaconda:
Follow the installation instructions for your operating system.
During installation, you can choose to add Anaconda to your system PATH,
which makes it easier to access Anaconda from the command line.
3. Verify Installation:
Open a new terminal or command prompt.
Type conda --version to check if the installation was successful.
2. Anaconda Navigator
1. Launch Anaconda Navigator:
Open Anaconda Navigator from your applications or Start menu.
2. Explore Navigator:
Get familiar with the Anaconda Navigator interface.
Identify the key components such as Home, Environments, and Jupyter
Notebooks.
3. Creating and Managing Environments
1. Create a New Environment:
Use Anaconda Navigator to create a new environment.
Choose the Python version and give your environment a name.
2. Manage Environments:
Activate and deactivate environments.
Install and remove packages using the Conda package manager.
4. Jupyter Notebooks with Anaconda
1. Launch Jupyter Notebook:
Open Jupyter Notebook from Anaconda Navigator.
2. Create a New Notebook:
Create a new Jupyter Notebook within your Anaconda environment.
3. Execute Code in Notebook:
Write and execute a simple Python code snippet in the Jupyter Notebook.
5. Conclusion
This lab document provides a structured outline for conducting an introduction to Anaconda
and Google Colab experiment.In this experiment, we have been introduced to the Anaconda
distribution and its capabilities. and learned how to install Anaconda, create and manage
Python environments, and use Jupyter Notebooks for interactive coding.
Additional Resources
Anaconda Documentation: Anaconda Documentation
Jupyter Notebook Documentation: Jupyter Notebook Documentation
Installing Anaconda and Python
To learn machine learning, we will use the Python programming language in this tutorial. So,
in order to use Python for machine learning, we need to install it in our computer system with
compatible IDEs (Integrated Development Environment).
In this topic, we will learn to install Python and an IDE with the help of Anaconda
distribution.
Anaconda distribution provides installation of Python with various IDE's such as Jupyter
Notebook, Spyder, Anaconda prompt, etc. Hence it is a very convenient packaged solution
which you can easily download and install in your computer. It will automatically install
Python and some basic IDEs and libraries with it.
Below some steps are given to show the downloading and installing process of Anaconda and
IDE:
To download Anaconda in your system, firstly, open your favorite browser and type
Download Anaconda Python, and then click on the first link as given in the below
image. Alternatively, you can directly download it by clicking on this link,
https://www.anaconda.com/distribution/#download-section.
After clicking on the first link, you will reach to download page of Anaconda, as
shown in the below image:
Since, Anaconda is available for Windows, Linux, and Mac OS, hence, you can
download it as per your OS type by clicking on available options shown in below
image. It will provide you Python 2.7 and Python 3.7 versions, but the latest version is
3.7, hence we will download Python 3.7 version. After clicking on the download option,
it will start downloading on your computer.
Note: In this topic, we are downloading Anaconda for Windows you can choose it as
per your OS.
Step- 2: Install AnacondaPython (Python 3.7version):
Once the downloading process gets completed, go to downloads → double click on the ".exe"
file (Anaconda3-2019.03-Windows-x86_64.exe) of Anaconda. It will open a setup window
for Anaconda installations as given in below image, then click on Next.
It will open a License agreement window click on "I Agree" option and move further.
In the next window, you will get two options for installations as given in the below
image. Select the first option (Just me) and click on Next.
Now you will get a window for installing location, here, you can leave it as default or
change it by browsing a location, and then click on Next. Consider the below image:
Now select the second option, and click on install.
Note: Here, we will use the Spyder IDE to run Python programs.
Step- 3: OpenAnacondaNavigator
Below some steps are given to show the downloading and installing process of Anaconda and
IDE:
To download Anaconda in your system, firstly, open your favorite browser and type
Download Anaconda Python, and then click on the first link as given in the below
image. Alternatively, you can directly download it by clicking on this link,
https://www.anaconda.com/distribution/#download-section.
After clicking on the first link, you will reach to download page of Anaconda, as
shown in the below image:
Since, Anaconda is available for Windows, Linux, and Mac OS, hence, you can
download it as per your OS type by clicking on available options shown in below
image. It will provide you Python 2.7 and Python 3.7 versions, but the latest version is
3.7, hence we will download Python 3.7 version. After clicking on the download option,
it will start downloading on your computer.
Note: In this topic, we are downloading Anaconda for Windows you can choose it as
per your OS.
Once the downloading process gets completed, go to downloads → double click on the ".exe"
file (Anaconda3-2019.03-Windows-x86_64.exe) of Anaconda. It will open a setup window
for Anaconda installations as given in below image, then click on Next.
It will open a License agreement window click on "I Agree" option and move further.
In the next window, you will get two options for installations as given in the below
image. Select the first option (Just me) and click on Next.
Now you will get a window for installing location, here, you can leave it as default or
change it by browsing a location, and then click on Next. Consider the below image:
• Now installation is completed, tick the checkbox if you want to learn more about
Anaconda and Anaconda cloud. Click on Finish to end the process.
Note: Here, we will use the Spyder IDE to run Python programs.
Step- 3: OpenAnacondaNavigator
After opening the navigator, launch the Spyder IDE by clicking on the Launch button
given below the Spyder. It will install the Spyder IDE in your system.
Run your Python program in Spyder IDE.
Write your first program, and save it using the .py extension.
Run the program using the triangle Run button.
You can check the program's output on console pane at the bottom right side.
On your first visit, you will see a Welcome To Colaboratory notebook with links to video
introductions and basic information on how to use Colab.
Create aworkbook
If you are not yet logged in to a Google account, the system will prompt you to log in.
The notebook will by default have a generic name; click on the filename field to rename it.
The file type, IPYNB, is short for "IPython notebook" because IPython was the forerunner of
Jupyter Notebook.
The interface allows you to insert various kinds of cells, mainly text and code, which have
their own shortcut buttons under the menu bar via the Insert menu.
Because notebooks are meant for sharing, there are accommodations throughout for
structured documentation.
You can insert Python code to execute in a code cell. The code can be entirely standalone or
imported from various Python libraries.
A notebook can be treated as a rolling log of work, with earlier code snippets being no longer
executed in favor of later ones, or treated as an evolving set of code blocks intended for
ongoing execution. The Runtime menu offers execution options, such as Run all, Run
before or Run the focused cell, to match either approach.
Each code cell has a run icon on the left edge, as shown above. You can type code into a cell
and hit the run icon to execute it immediately.
If the code generates an error, the error output will appear beneath the cell. Correcting the
problem and hitting run again replaces the error info with program output. The first line of
code, in its own cell, imports the NumPy library, which is the source of the arange function.
Colab has many common libraries pre-loaded for easy import into programs.
A text cell provides basic rich text using Markdown formatting by default and allows for the
insertion of images, HTML code and LaTeX formatting.
As you add text on the left side of the text cell, the formatted output appears on the right.
Once you stop editing a block, only the final formatted version shows.
After getting comfortable with the interface and using it for initial test coding, you must
eventually provide the code with data to analyze or otherwise manipulate.
Colab can mount a user's Google Drive to the VM hosting their notebook using a code cell.
Once you hit run, Google will ask for permission to mount the drive.
If you allow it to connect, you will then have access to the files in your Google Drive via the
/my_drive path.
If you prefer not to grant access to your Drive space, you can upload files or any network file
space mounted as a drive from your local machine instead.
with file access, many functions are available to read data in various ways. For example,
importing the Pandas library gives access to functions such as read_csv and read_json.
Save and share
By default, Colab puts notebooks in a Colab Notebooks folder under My Drive in Google
Drive.
The File menu enables notebooks to be saved as named revisions in the version history,
relocated using Move, or saved as a copy in Drive or GitHub. It also allows you to download
and upload notebooks. Tools based on Jupyter provide broad compatibilities, so you can
create notebooks in one place and then upload and use them in another.
You can use the Share button in the upper right to grant other Google users access to the
notebook and to copy links.
Google also provides example notebooks illustrating available resources, such as pre-trained
image classifiers and language transformers, as well as addressing common business
problems, such as working with BigQuery or performing time series analytics. It also
provides links to introductory Python coding notebooks.
Experiment No. 2
Objective: The objective of this experiment is to provide students with hands-on experience
in using popular machine learning libraries and tools. Participants will explore libraries such
as scikit-learn, TensorFlow, and PyTorch, and familiarize themselves with essential machine
learning tasks.
Prerequisites
Basic understanding of Python programming language.
Familiarity with fundamental machine learning concepts.
RESOURCES REQUIRED: H/W :- P4 machine
S/W :- Jupyter Notebook
Theory:
Here are some of the best libraries of Python used for Machine Learning:
NumPy
SciPy
Scikit-learn
Pandas
Matplotlib
Seaborn
TensorFlow
Keras
• PyTorch
With NumPy, you can define arbitrary data types and easily integrate with most databases.
NumPy can also serve as an efficient multi-dimensional container for any generic data that is
in any datatype. The key features of NumPy include powerful N-dimensional array object,
broadcasting functions, and out-of-box tools to integrate C/C++ and Fortran code.
Advantages:
Disadvantages:
Code:
import numpy as nup
P = nup.array([10, 12])
S = nup.array([9, 11])
Output:
Inner product of vectors: 222
Advantages:
Disadvantages:
Example 1:
Output:
Output:
3) Scikit-learn
The following features of scikit-learn make it one of the best machine learning libraries in
Python:
Example:
Output:
DecisionTreeClassifier()
precision recall f1-score support
[[50 0 0]
[ 0 50 0]
[ 0 0 50]]
4) Pandas
Pandas is a Python library that is mainly used for data analysis. The
users have to prepare the dataset before using it for training the
machine learning. Pandas make it easy for the developers as it is
developed specifically for data extraction. It has a wide variety of
tools for analysing data in detail, providing high-level data structures.
Advantages:
Disadvantages:
Series (1-dimensional)
DataFrame (2-dimensional)
These two put together can handle a vast majority of data requirements and use cases from
most sectors like science, statistics, social, finance, and of course, analytics and other areas of
engineering.
Pandas support and perform well with different kinds of data including the below :
Tabular data with columns of heterogeneous data. For instance, consider the data
coming from the SQL table or Excel spreadsheet.
Ordered and unordered time series data. The frequency of time series need not be
fixed, unlike other libraries and tools. Pandas is exceptionally robust in handling
uneven time-series data
Arbitrary matrix data with the homogeneous or heterogeneous type of data in the rows
and columns
Any other form of statistical or observational data sets. The data need not be labeled
at all. Pandas data structure can process it even without labeling.
It was launched as an open-source Python library in 2009. Currently, it has become one of the
favourite Python libraries for machine learning among many ML enthusiasts. The reason
is it offers some robust techniques for data analysis and data manipulation. This library is
extensively used in academia. Moreover, it supports different commercial domains like
business and web analytics, economics, statistics, neuroscience, finance, advertising, etc. It
also works as a foundational library for many advanced Python libraries.
Here are some of its key features:
Example:
Output:
5) Matplotlib
Matplotlib is a Python library that is used for data visualization. It is used by developers
when they want to visualize the data and its patterns. It is a 2-D plotting library that is used to
create 2-D graphs and plots.
It has a module pyplot which is used for plotting graphs, and it provides different features for
control line styles, font properties, formatting axes and many more. Matplotlib provides
different types of graphs and plots such as histograms, error charts, bar charts and many more.
Example 1:
Output:
Example 2:
Output:
Matplotlib is a data visualization library that is used for 2D plotting to produce publication-
quality image plots and figures in a variety of formats. The library helps to generate
histograms, plots, error charts, scatter plots, bar charts with just a few lines of code.
It is the oldest Python machine learning library. However, it is still not obsolete. It is one of
the most innovative data visualization libraries for Python. So, the ML community admires it.
The following features of the Matplotlib library make it a famous Python machine learning
among the ML community:
Advantages:
Disadvantages:
• It has a strong dependency on NumPy and other such libraries for the SciPy stack.
It has a high learning curve as its use takes quite a lot of knowledge and application
from the learner’s end.
It can be confusing for developers as it provides two distinct frameworks, object-
oriented and MATLAB.
It is primarily used for data visualization. It is not suitable for data analysis. To get
both data visualization and data analysis, we will have to integrate it with other
libraries.
6) Seaborn
Advantages:
It produces graphs that are more appealing than those created with Matplotlib.
It has integrated packages that are unavailable in Matplotlib.
It uses less code for visualizing graphs.
It is integrated with pandas for visualizing and analyzing data.
Disadvantages:
7) TensorFlow
TensorFlow exposes a very stable Python and C++ APIs. It can expose, backward compatible
APIs for other languages too, but they might be unstable. TensorFlow has a flexible
architecture with which it can run on a variety of computational platforms CPUs, GPUs, and
TPUs. TPU stands for Tensor processing unit, a hardware chip built around TensorFlow for
machine learning and artificial intelligence.
TensorFlow empowers some of the largest contemporary AI models globally. Alternatively, it
is recognized as an end-to-end Deep Learning and Machine Learning library to solve practical
challenges.
The following key features of TensorFlow make it one of the best machine learning
libraries Python:
8) Keras
Keras works with neural-network building blocks like layers, objectives, activation functions,
and optimizers. Keras also have a bunch of features to work on images and text images that
comes handy when writing Deep Neural Network code.
Apart from the standard neural network, Keras supports convolutional and recurrent neural
networks.
It was released in 2015 and by now, it is a cutting-edge open-source Python deep learning
framework and API. It is identical to Tensorflow in several aspects. But it is designed with a
human-based approach to make DL and ML accessible and easy for everybody.
You can conclude that Keras is one of the versatile machine learning libraries Python
because it includes:
9) PyTorch
PyTorch has a range of tools and libraries that support
computer vision, machine learning, and natural language
processing. The PyTorch library is open-source and is
based on the Torch library. The most significant advantage
of PyTorch library is it’s ease of learning and using.
PyTorch can smoothly integrate with the python data science stack, including NumPy. You will
hardly make out a difference between NumPy and PyTorch. PyTorch also allows developers to
perform computations on Tensors. PyTorch has a robust framework to build computational
graphs on the go and even change them in runtime. Other advantages of PyTorch include multi
GPU support, simplified preprocessors, and custom data loaders.
Conclusion:
In this Experiment, we have discussed about different libraries of Python and Machine
learning which are used for performing Machine learning tasks. We have also shown
different examples of each library.
Code:
def hebbian_learning(samples):
print(f'{"INPUT":^8} {"TARGET":^16}{"WEIGHT CHANGES":^15}
{"WEIGHTS":^25}') w1,
w2, b = 0, 0, 0
print(' ' * 45, f'({w1:2}, {w2:2}, {b:2})')
for x1, x2, y in samples:
w1 = w1 + x1 * y
w2 = w2 + x2 * y
b=b+y
print(f'({x1:2}, {x2:2}) {y:2} ({x1*y:2}, {x2*y:2}, {y:2}) ({w1:2}, {w2:2},
{b:2})')
AND_samples =
{ 'binary_input_binary_output': [
[1, 1, 1],
[1, 0, 0],
[0, 1, 0],
[0, 0, 0]
],
'binary_input_bipolar_output':
[ [1, 1, 1],
[1, 0, -1],
[0, 1, -1],
[0, 0, -1]
],
'bipolar_input_bipolar_output':
[ [ 1, 1, 1],
[ 1, -1, -1],
[-1, 1, -1],
[-1, -1, -1]
]
}
OR_samples =
{ 'binary_input_binary_output': [
[1, 1, 1],
[1, 0, 1],
[0, 1, 1],
[0, 0, 0]
],
'binary_input_bipolar_output':
[ [1, 1, 1],
[1, 0, 1],
[0, 1, 1],
[0, 0, -1]
],
'bipolar_input_bipolar_output':
[ [ 1, 1, 1],
[ 1, -1, 1],
[-1, 1, 1],
[-1, -1, -1]
]
}
XOR_samples =
{ 'binary_input_binary_output': [
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 0, 0]
],
'binary_input_bipolar_output':
[ [1, 1, -1],
[1, 0, 1],
[0, 1, 1],
[0, 0, -1]
],
'bipolar_input_bipolar_output':
[ [ 1, 1, -1],
[ 1, -1, 1],
[-1, 1, 1],
[-1, -1, -1]
]
}
#For AND gate
print('-',20, 'HEBBIAN LEARNING', '-',20)
print('AND with Binary Input and Binary Output')
hebbian_learning(AND_samples['binary_input_binary_output'])
print('AND with Binary Input and Bipolar Output')
hebbian_learning(AND_samples['binary_input_bipolar_output'])
print('AND with Bipolar Input and Bipolar Output')
hebbian_learning(AND_samples['bipolar_input_bipolar_output'])
#OR Gate
print('-',20, 'HEBBIAN LEARNING', '-',20)
print('OR with binary input and binary output')
hebbian_learning(OR_samples['binary_input_binary_output'])
print('OR with binary input and bipolar output')
hebbian_learning(OR_samples['binary_input_bipolar_output'])
print('OR with bipolar input and bipolar output')
hebbian_learning(OR_samples['bipolar_input_bipolar_output'])
#XOR Gate
print('-',20, 'HEBBIAN LEARNING', '-',20)
print('XOR with binary input and binary output')
hebbian_learning(XOR_samples['binary_input_binary_output'])
print('XOR with binary input and bipolar output')
hebbian_learning(XOR_samples['binary_input_bipolar_output'])
print('XOR with bipolar input and bipolar output')
hebbian_learning(XOR_samples['bipolar_input_bipolar_output'])
Output:
- 20 HEBBIAN LEARNING - 20
AND with Binary Input and Binary Output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) 1 ( 1, 1, 1) ( 1, 1, 1)
( 1, 0) 0 ( 0, 0, 0) ( 1, 1, 1)
( 0, 1) 0 ( 0, 0, 0) ( 1, 1, 1)
( 0, 0) 0 ( 0, 0, 0) ( 1, 1, 1)
AND with Binary Input and Bipolar Output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) 1 ( 1, 1, 1) ( 1, 1, 1)
( 1, 0) -1 (-1, 0, -1) ( 0, 1, 0)
( 0, 1) -1 ( 0, -1, -1) ( 0, 0, -1)
( 0, 0) -1 ( 0, 0, -1) ( 0, 0, -2)
AND with Bipolar Input and Bipolar Output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) 1 ( 1, 1, 1) ( 1, 1, 1)
( 1, -1) -1 (-1, 1, -1) ( 0, 2, 0)
(-1, 1) -1 ( 1, -1, -1) ( 1, 1, -1)
(-1, -1) -1 ( 1, 1, -1) ( 2, 2, -2)
- 20 HEBBIAN LEARNING - 20
OR with binary input and binary output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) 1 ( 1, 1, 1) ( 1, 1, 1)
( 1, 0) 1 ( 1, 0, 1) ( 2, 1, 2)
( 0, 1) 1 ( 0, 1, 1) ( 2, 2, 3)
( 0, 0) 0 ( 0, 0, 0) ( 2, 2, 3)
OR with binary input and bipolar output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) 1 ( 1, 1, 1) ( 1, 1, 1)
( 1, 0) 1 ( 1, 0, 1) ( 2, 1, 2)
( 0, 1) 1 ( 0, 1, 1) ( 2, 2, 3)
( 0, 0) -1 ( 0, 0, -1) ( 2, 2, 2)
( 1, 1) 1 ( 1, 1, 1) ( 1, 1, 1)
( 1, -1) 1 ( 1, -1, 1) ( 2, 0, 2)
(-1, 1) 1 (-1, 1, 1) ( 1, 1, 3)
(-1, -1) -1 ( 1, 1, -1) ( 2, 2, 2)
- 20 HEBBIAN LEARNING - 20
XOR with binary input and binary output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) 0 ( 0, 0, 0) ( 0, 0, 0)
( 1, 0) 1 ( 1, 0, 1) ( 1, 0, 1)
( 0, 1) 1 ( 0, 1, 1) ( 1, 1, 2)
( 0, 0) 0 ( 0, 0, 0) ( 1, 1, 2)
XOR with binary input and bipolar output
INPUT TARGET WEIGHT CHANGES WEIGHTS
( 0, 0, 0)
( 1, 1) -1 (-1, -1, -1) (-1, -1, -1)
( 1, 0) 1 ( 1, 0, 1) ( 0, -1, 0)
( 0, 1) 1 ( 0, 1, 1) ( 0, 0, 1)
( 0, 0) -1 ( 0, 0, -1) ( 0, 0, 0)
( 0, 0, 0)
( 1, 1) -1 (-1, -1, -1) (-1, -1, -1)
( 1, -1) 1 ( 1, -1, 1) ( 0, -2, 0)
(-1, 1) 1 (-1, 1, 1) (-1, -1, 1)
(-1, -1) -1 ( 1, 1, -1) ( 0, 0, 0)
Code :
sample = hstack((sample1,sample2))
Output:
The plot clearly shows the expected distribution with the peak for the first
process is 20 and the second process is 40. And for many points in the middle of
the distribution, it is unclear as to which distribution they are picked up from.
We can model the problem of estimating the density of this data set using the
Gaussian Mixture Model.
# Example of fitting a gaussian mixture model with expectation
maximization
import numpy as np
from numpy.random import normal
from sklearn.mixture import GaussianMixture
import numpy as np
import matplotlib.pyplot as plt
class McCullochPittsModel:
def init (self, weights, threshold):
self.weights = weights
self.threshold = threshold
# Example usage
weights = np.array([1, -1])
threshold = 0
# Test inputs
inputs = np.array([
[0, 1], # Should output 1
[1, 1], # Should output 0
[1, 0] # Should output 1
])
# Make predictions
predictions = np.array([mpm.predict(x) for x in inputs])
print(predictions)
# Example graph
x = np.linspace(-0.5, 1.5, 100) y
= -x + 1
plt.plot(x, y, '-r', label='y=2x+1')
plt.plot()
plt.scatter(inputs[:,0][predictions==1], inputs[:,1][predictions==1], c='b')
plt.xlabel('Wind')
plt.ylabel('Temp')
plt.title('McCulloch Pitts Model Example')
plt.legend()
plt.show()
Output: [0 1 1]
Code:
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.decomposition import PCA
from matplotlib.colors import ListedColormap
# Iris Classification
# Import Packages
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
columns = ['Sepal length', 'Sepal width', 'Petal length', 'Petal width', 'Class_labels'] # As per the
iris dataset information
Y_Data_reshaped = Y_Data.reshape(4, 3)
Y_Data_reshaped = np.swapaxes(Y_Data_reshaped, 0, 1)
X_axis = np.arange(len(columns)-1)
width = 0.25
X_new = np.array([[3, 2, 1, 0.2], [ 4.9, 2.2, 3.8, 1.1 ], [ 5.3, 2.5, 4.6, 1.9 ]])
#Prediction of the species from the input vector
prediction = svn.predict(X_new)
print("Prediction of Species: {}".format(prediction))
Output:
Code:
window = Tk()
window.title("Handwritten digit recognition")
l1 = Label()
def MyProject():
global l1
widget = cv
# Setting co-ordinates of canvas
x = window.winfo_rootx() + widget.winfo_x()
y = window.winfo_rooty() + widget.winfo_y()
x1 = x + widget.winfo_width()
y1 = y + widget.winfo_height()
# Loading Thetas
Theta1 = np.loadtxt('Theta1.txt')
Theta2 = np.loadtxt('Theta2.txt')
# Activate canvas
def event_activation(event):
global lastx, lasty
cv.bind('<B1-Motion>', draw_lines)
lastx, lasty = event.x, event.y
# To draw on canvas
def draw_lines(event):
global lastx, lasty
x, y = event.x, event.y
cv.create_line((lastx, lasty, x, y), width=30, fill='white', capstyle=ROUND, smooth=TRUE,
splinesteps=12)
lastx, lasty = x, y
# Label
L1 = Label(window, text="Handwritten Digit Recoginition", font=('Algerian', 25), fg="blue")
L1.place(x=35, y=10)