PR ZXV
PR ZXV
: 201803100920017
Experiment 1
Aim: To study various machine learning libraries like- Scipy, Sklearn, Keras,
TensorFlow and PyTorch with their uses.
Scipy:
SciPy is a very popular library among Machine Learning enthusiasts as it contains different modules for
optimization, linear algebra, integration and statistics. There is a difference between the SciPy library
and the SciPy stack. The SciPy is one of the core packages that make up the SciPy stack. SciPy is also
very useful for image manipulation.
Use:
SciPy is a library that uses NumPy for more mathematical functions. SciPy uses NumPy arrays as the
basic data structure, and comes with modules for various commonly used tasks in scientific
programming, including linear algebra, integration (calculus), ordinary differential equation solving, and
signal processing.
Sklearn:
Skikit-learn is one of the most popular ML libraries for classical ML algorithms. It is built on top of two
basic Python libraries, viz., NumPy and SciPy. Scikit-learn supports most of the supervised and
unsupervised learning algorithms. Scikit-learn can also be used for data-mining and data-analysis, which
makes it a great tool who is starting out with ML.
Use:
Scikit-learn is a free machine learning library for Python. It features various algorithms like support
vector machine, random forests, and k-neighbours, and it also supports Python numerical and scientific
libraries like NumPy and SciPy .
Classification
Regression
Clustering
Dimensionality Reduction
Model Selection
Preprocessing
Built around the idea of being easy to use but still be flexible, Scikit-learn is focussed on data modelling
and not on other tasks such as loading, handling, manipulation and visualization of data. It is considered
sufficient enough to be used as an end-to-end ML, from the research phase to the deployment. For a
deeper understanding of scikit-learn, you can check out the Scikit-learn tutorials.
Tensorflow:
TensorFlow is a very popular open-source library for high performance numerical computation
developed by the Google Brain team in Google. As the name suggests, Tensorflow is a framework that
involves defining and running computations involving tensors. It can train and run deep neural networks
that can be used to develop several AI applications. TensorFlow is widely used in the field of deep
learning research and application.
Use:
TensorFlow is an open source library for numerical computation and large-scale machine
learning. TensorFlow bundles together a slew of machine learning and deep learning (aka neural
networking) models and algorithms and makes them useful by way of a common metaphor.
Using TensorFlow, you can create and train ML models on not just computers but also mobile devices
and servers by using TensorFlow Lite and TensorFlow Serving that offers the same benefits but for
mobile platforms and high-performance servers.
Keras:
Keras is a very popular Machine Learning library for Python. It is a high-level neural networks API
capable of running on top of TensorFlow, CNTK, or Theano. It can run seamlessly on both CPU and
GPU. Keras makes it really for ML beginners to build and design a Neural Network. One of the best
thing about Keras is that it allows for easy and fast prototyping.
Neural layers
Activation and cost functions
Objectives
Batch normalization
Dropout
Pooling
Use:
Keras is a powerful and easy-to-use free open source Python library for developing and evaluating deep
learning models. It wraps the efficient numerical computation libraries Theano and TensorFlow and allows you
to define and train neural network models in just a few lines of code.
Keras extends the usability of TensorFlow with these additional features for ML and DL programming.
With a helpful community and a dedicated Slack channel, getting support is easy. Support for the
convolutional and recurrent neural network also exists along with standard neural networks. You can
also refer to other example models in Keras and Computer Vision class from Stanford.
Pytorch:
PyTorch is a popular open-source Machine Learning library for Python based on Torch, which is an
open-source Machine Learning library which is implemented in C with a wrapper in Lua. It has an
extensive choice of tools and libraries that supports on Computer Vision, Natural Language
Processing(NLP) and many more ML programs. It allows developers to perform computations on
Tensors with GPU acceleration and also helps in creating computational graphs.
Use:
PyTorch is an open source machine learning library used for developing and training neural network based deep
learning models. It is primarily developed by Facebook's AI research group. PyTorch can be used with Python as
well as a C++. Naturally, the Python interface is more polished.
Developed by Facebook, PyTorch is one of the few machine learning libraries for Python. Apart from
Python, PyTorch also has support for C++ with its C++ interface if you’re into that. Considered among
the top contenders in the race of being the best Machine Learning and Deep Learning framework,
PyTorch faces touch competition from TensorFlow. You can refer to the PyTorch tutorials for other
details.
Basic PyTorch Workflow
Experiment 2
for i in range(1,king+1):
f=f*cards
cards=cards-1
a=f/king#1326
l=4
for i in range(1,king+1):
g=g*l
l=l-1
k=g/king#6
print(k)
print(a)
drawing_kings = (a/k)
x=1/drawing_kings
print('probability:-',x)
Output:
Output:
Experiment 3
CGPIT/B.TECH (CE)/D2D/SEM-7/Machine Intelligence
Enrollment No.: 201803100920017
def BirthdayParadox(N):
p=1
for i in range(1,N):
probab = i/366
p *= (1-probab)
q = (1-p)
print(q)
BirthdayParadox(N)
Output:
Experiment 4
β 0 b0 = y - b1 * X
2
[ ( x −X )∗( y i−Y ) ] }
Coefficient of Determination R ={ 1 ∗∑ i
N
2
( )
( σ x∗σ y )
import numpy as np
import pandas as pd
data = pd.read_csv('100men.csv')
def predict_coeff(x,y):
n = len(x)
m_x = np.mean(x)
m_y = np.mean(y)
print("Mean Of X: ",m_x)
print("Mean Of Y: ",m_y)
b = np.sum((x - m_x)**2)
b1 = numer / b
Y = b0 + (b1 * a)
x = data['xn'].values
y = data['tn'].values
predict_coeff(x,y)
Output: