官术网_书友最值得收藏!

Before we build our first model

When we talk about models, you can think of them as simplified theoretical approximations of complex reality. As such, there is always some inferiority involved, also called the approximation error. This error will guide us in choosing the right model among the many choices we have. We will calculate this error as the squared distance of the model's prediction to the real data; for example, for a learned model function, f, the error is calculated as follows:

def error(f, x, y):
return np.sum((f(x)-y)**2)

The vectors x and y contain the web stats data that we extracted earlier. It is the beauty of NumPy's vectorized functions, which we exploit here with f(x). The trained model is assumed to take a vector and return the results again as a vector of the same size so that we can use it to calculate the difference to y.

主站蜘蛛池模板: 夹江县| 金山区| 湟源县| 白城市| 乡宁县| 长沙县| 江陵县| 兴国县| 栖霞市| 修武县| 廉江市| 林周县| 行唐县| 沁源县| 玛纳斯县| 新野县| 晋宁县| 潞城市| 牟定县| 承德市| 宾阳县| 黑龙江省| 公主岭市| 新闻| 海原县| 青浦区| 革吉县| 敦煌市| 常山县| 宣威市| 锡林郭勒盟| 峨边| 乐平市| 金塔县| 外汇| 肥东县| 山东省| 博白县| 昭苏县| 门源| 平果县|