MCPcopy Create free account
hub / github.com/Jack-Cherish/Machine-Learning / regularize

Function regularize

Regression/lego.py:105–129  ·  view source on GitHub ↗

函数说明:数据标准化 Parameters: xMat - x数据集 yMat - y数据集 Returns: inxMat - 标准化后的x数据集 inyMat - 标准化后的y数据集 Website: http://www.cuijiahua.com/ Modify: 2017-12-03

(xMat, yMat)

Source from the content-addressed store, hash-verified

103 scrapePage(retX, retY, './lego/lego10196.html', 2009, 3263, 249.99) #2009年的乐高10196,部件数目3263,原价249.99
104
105def regularize(xMat, yMat):
106 """
107 函数说明:数据标准化
108 Parameters:
109 xMat - x数据集
110 yMat - y数据集
111 Returns:
112 inxMat - 标准化后的x数据集
113 inyMat - 标准化后的y数据集
114 Website:
115 http://www.cuijiahua.com/
116 Modify:
117 2017-12-03
118 """
119 inxMat = xMat.copy() #数据拷贝
120 inyMat = yMat.copy()
121 yMean = np.mean(yMat, 0) #行与行操作,求均值
122 inyMat = yMat - yMean #数据减去均值
123 inMeans = np.mean(inxMat, 0) #行与行操作,求均值
124 inVar = np.var(inxMat, 0) #行与行操作,求方差
125 # print(inxMat)
126 print(inMeans)
127 # print(inVar)
128 inxMat = (inxMat - inMeans) / inVar #数据减去均值除以方差实现标准化
129 return inxMat, inyMat
130
131def rssError(yArr,yHatArr):
132 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected