展示结果
代码
import pandas as pd
import numpy as np
from sklearn.impute import SimpleImputer
from sklearn.impute import KNNImputer
import matplotlib.pyplot as plt
data1 = pd.read_excel("C:\\Users\\hp\\Desktop\\心脏病数据.xlsx", header=None)
data2 = pd.read_excel("C:\\Users\\hp\\Desktop\\心脏病数据 - 有缺失.xlsx", header=None)
pd.set_option('expand_frame_repr', False)
pd.set_option('display.max_rows', None)
np.set_printoptions(threshold=float('inf'))
np.set_printoptions(suppress=True, precision=3, linewidth=500)
name = ['age', 'sex', 'cp', 'trestbps', 'chol', 'fbs', 'restecg', 'thalach',
'exang', 'oldpeak', 'slope', 'ca', 'thal', 'target']
data1.columns = name
data2.columns = name
剩下的代码自己写