SNV Python实现
时间: 2023-11-19 21:56:08 浏览: 189
基于python开发的高光谱数据预处理方法+源码+文档+代码解析(高分优秀项目)
5星 · 资源好评率100%
SNV(Standard Normal Variate)是一种常用的光谱预处理方法,可以消除光谱中的系统误差。下面是SNV Python实现的步骤:
```python
# 引入库
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
# 读入数据、预处理以及展示
data = pd.read_csv('data.csv')
data = data.drop(['Sample'], axis=1)
data = (data - data.mean()) / data.std()
data.plot()
plt.show()
# SNV实现
def snv(data):
data_mean = np.mean(data, axis=1)
data_std = np.std(data, axis=1, ddof=1)
data_snv = (data - data_mean[:, np.newaxis]) / data_std[:, np.newaxis]
return data_snv
data_snv = snv(data)
data_snv.plot()
plt.show()
```
阅读全文