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

Function regularize

Regression/regression.py:103–124  ·  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

101
102
103def regularize(xMat, yMat):
104 """
105 函数说明:数据标准化
106 Parameters:
107 xMat - x数据集
108 yMat - y数据集
109 Returns:
110 inxMat - 标准化后的x数据集
111 inyMat - 标准化后的y数据集
112 Website:
113 http://www.cuijiahua.com/
114 Modify:
115 2017-12-03
116 """
117 inxMat = xMat.copy() #数据拷贝
118 inyMat = yMat.copy()
119 yMean = np.mean(yMat, 0) #行与行操作,求均值
120 inyMat = yMat - yMean #数据减去均值
121 inMeans = np.mean(inxMat, 0) #行与行操作,求均值
122 inVar = np.var(inxMat, 0) #行与行操作,求方差
123 inxMat = (inxMat - inMeans) / inVar #数据减去均值除以方差实现标准化
124 return inxMat, inyMat
125
126def rssError(yArr,yHatArr):
127 """

Callers 1

stageWiseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected