MCPcopy Create free account
hub / github.com/Dod-o/Statistical-Learning-Method_Code / load_data

Function load_data

PCA/PCA.py:22–35  ·  view source on GitHub ↗

INPUT: file - (str) 数据文件的路径 OUTPUT: df - (dataframe) 读取的数据表格 X - (array) 特征数据数组

(file)

Source from the content-addressed store, hash-verified

20
21#定义加载数据的函数
22def load_data(file):
23 '''
24 INPUT:
25 file - (str) 数据文件的路径
26
27 OUTPUT:
28 df - (dataframe) 读取的数据表格
29 X - (array) 特征数据数组
30
31 '''
32 df = pd.read_csv(file) #读取csv文件
33 df.drop('Sports', axis=1, inplace=True) #去掉类别数据
34 X = np.asarray(df.values).T #将数据转换成数组
35 return df, X
36
37
38#定义规范化函数,对每一列特征进行规范化处理,使其成为期望为0方差为1的标准分布

Callers 1

PCA.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected