Update installation_features.md

pull/507/head
Ankit Mahato 2024-05-24 21:12:54 +05:30 zatwierdzone przez GitHub
rodzic bcf4df6d7d
commit e6a7ceee0c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 66 dodań i 23 usunięć

Wyświetl plik

@ -1,13 +1,25 @@
## Installation of Scipy ## Installation of Scipy
### Install using the command:
#### C:\Users\Your Name>pip install scipy You can install scipy using the command:
You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder.
```
$ pip install scipy
```
You can also use a Python distribution that already has Scipy installed like Anaconda, or Spyder.
### Importing SciPy ### Importing SciPy
#### from scipy import constants
```python
from scipy import constants
```
## Key Features of SciPy ## Key Features of SciPy
### 1. Numerical Integration ### 1. Numerical Integration
#### It helps in computing definite or indefinite integrals of functions
``` It helps in computing definite or indefinite integrals of functions
```python
from scipy import integrate from scipy import integrate
#Define the function to integrate #Define the function to integrate
@ -18,13 +30,18 @@ def f(x):
result, error = integrate.quad(f, 0, 1) result, error = integrate.quad(f, 0, 1)
print(result) print(result)
``` ```
#### Output #### Output
``` ```
0.33333333333333337 0.33333333333333337
``` ```
### 2. Optimization ### 2. Optimization
#### It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation
``` It can be used to minimize or maximize functions, here is an example of minimizing roots of an equation
```python
from scipy.optimize import minimize from scipy.optimize import minimize
# Define an objective function to minimize # Define an objective function to minimize
@ -35,13 +52,18 @@ def objective(x):
result = minimize(objective, x0=0) result = minimize(objective, x0=0)
print(result.x) print(result.x)
``` ```
#### Output #### Output
``` ```
array([-1.30644012]) array([-1.30644012])
``` ```
### 3. Linear Algebra ### 3. Linear Algebra
#### Solving Linear computations
``` Solving Linear computations
```python
from scipy import linalg from scipy import linalg
import numpy as np import numpy as np
@ -55,13 +77,18 @@ b = np.array([5, 6])
x = linalg.solve(A, b) x = linalg.solve(A, b)
print(x) print(x)
``` ```
#### Output #### Output
``` ```
array([-4. , 4.5]) array([-4. , 4.5])
``` ```
### 4. Statistics ### 4. Statistics
#### Performing statistics functions, like here we'll be distributing the data
``` Performing statistics functions, like here we'll be distributing the data
```python
from scipy import stats from scipy import stats
import numpy as np import numpy as np
@ -71,9 +98,12 @@ data = stats.norm.rvs(loc=0, scale=1, size=1000)
# Fit a normal distribution to the data # Fit a normal distribution to the data
mean, std = stats.norm.fit(data) mean, std = stats.norm.fit(data)
``` ```
### 5. Signal Processing ### 5. Signal Processing
#### To process spectral signals, like EEG or MEG
``` To process spectral signals, like EEG or MEG
```python
from scipy import signal from scipy import signal
import numpy as np import numpy as np
@ -85,14 +115,21 @@ signal = np.sin(2 * np.pi * 5 * t) + 0.5 * np.random.randn(1000)
b, a = signal.butter(4, 0.1, 'low') b, a = signal.butter(4, 0.1, 'low')
filtered_signal = signal.filtfilt(b, a, signal) filtered_signal = signal.filtfilt(b, a, signal)
``` ```
The various filters applied that are applied here, are a part of signal analysis at a deeper level. The various filters applied that are applied here, are a part of signal analysis at a deeper level.
### 6. Sparse Matrix ### 6. Sparse Matrix
#### The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created
#### There are two types of Sparse Matrices: The word ' sparse 'means less, i.e., the data is mostly unused during some operation or analysis. So, to handle this data, a Sparse Matrix is created
##### 1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing
##### 2. CSR: Compressed Sparse Row, it is used for fast row slicing There are two types of Sparse Matrices:
1. CSC: Compressed Sparse Column, it is used for efficient math functions and for column slicing
2. CSR: Compressed Sparse Row, it is used for fast row slicing
#### In CSC format #### In CSC format
```
```python
from scipy import sparse from scipy import sparse
import numpy as np import numpy as np
@ -104,17 +141,22 @@ values = np.array([1, 2, 1])
sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices))) sparse_matrix_csc = sparse.csc_matrix((values, (row_indices, col_indices)))
``` ```
#### In CSR format #### In CSR format
```
```python
from scipy import sparse from scipy import sparse
import numpy as np import numpy as np
data = np.array([[0, 0], [0, 1], [2, 0]]) data = np.array([[0, 0], [0, 1], [2, 0]])
sparse_matrix = sparse.csr_matrix(data) sparse_matrix = sparse.csr_matrix(data)
``` ```
### 7. Image Processing ### 7. Image Processing
#### It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used.
``` It is used to process the images, like changing dimensions or properties. For example, when you're doing a project on medical imaging, this library is mainly used.
```python
from scipy import ndimage from scipy import ndimage
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
@ -127,4 +169,5 @@ blurred_image = ndimage.gaussian_filter(image, sigma=1)
plt.imshow(blurred_image) plt.imshow(blurred_image)
plt.show() plt.show()
``` ```
#### The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image.
The gaussian blur is one of the properties of the ' ndimage ' package in SciPy libraries, it used for better understanding of the image.