经常在论文中见到validation的图,那么这种图应该怎么做呢?
用python容易就能实现了,让我们来讲解一下代码
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats
from matplotlib import rcParams
from statistics import mean
from sklearn.metrics import explained_variance_score,r2_score,median_absolute_error,mean_squared_error,mean_absolute_error
# 加载数据(PS:原始数据太多,采样10000)
# 默认是读取csv/xlsx的列成DataFrame
data = pd.read_excel('D:/acad3_211001/gc.xlsx')
data_ = data[(data['Gc1'] < 0.02) & (data['Gc'] < 0.02)]
data_ = data_.sample(10000)
config = {
"font.family":'Times New Roman',"font.size": 16,"mathtext.fontset":'stix'}
# 用于计算指标
x = data_['Gc']; y = data_['Gc1'