In: Computer Science
Please analyze and create a starter code in Python using spaCy, that can demonstrate practical use of the package. Also give a brief explanation of what the purpose of the spaCy package is.
Please use 3 different methods such as a loop statement, if statement, tuples, lists etc.
Please provide detailed comments on each line of code.
Please explain the purpose of the method used.
Please write and run your code example.
SciPy is a Python-based ecosystem of open-source software for mathematics, science, and engineering.
INSTALLATION :
Python3 -m pip install --user numpy scipy
Before start to learning SciPy, you need to know basic functionality as well as different types of an array of NumPy
The standard way of import infSciPy modules and Numpy:
from scipy import special #same for other modules
import numpy as np
File Input / Output package:
import numpy as np
from scipy import io as sio
array = np.ones((4, 4))
sio.savemat('example.mat', {'ar': array})
data = sio.loadmat(‘example.mat', struct_as_record=True)
data['ar']
Output
array([[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.]])
Cubic Root Function:
Syntax - scipy.special.cbrt(x)
from scipy.special import cbrt
#Find cubic root of 27 & 64 using cbrt() function
l=[27, 64,125,216] #list
for i in l: #for loop
cb = cbrt(i)
#print value of cb
print(cb)
Output: 3 4 5 6