机器学习的时空复杂度
The train time complexity of machine learning model — The amount of time taken to train the model
机器学习模型的训练时间复杂度 -训练模型花费的时间
The test time complexity of the machine learning model — Time took to predict output for a given input query point.
机器学习模型的测试时间复杂度-预测给定输入查询点的输出所花费的时间。
Time complexity is an essential aspect to know when anyone wants their model with low latency. Let’s dive deep into details of how much time and space required by the wide variety of models to predict the output.
时间复杂度是了解何时有人想要低延迟的模型的重要方面。 让我们深入研究各种模型预测输出需要多少时间和空间。
“Assuming training data has n points with d dimensions “
“假设训练数据有n个维度为d的点”
1)K最近邻居: (1) K-Nearest Neighbors:)
Given query point (xq), K-NN follows these steps to predict output (yq). For each xi in the training set, Compute distance for xi and xq.
给定查询点(xq),K-NN遵循以下步骤来预测输出(yq)。 对于训练集中的每个xi,计算xi和xq的距离。
Computing distance for one point takes o(d) time, as we are computing for each xi in training it takes o(nd)
计算一个点的距离需要o(d)的时间,因为我们在训练中针对每个xi进行计算都需要o(nd)
Then store the smallest k distances in a list and the Majority vote to K points, which took o(1). As we need whole train data during run time, Space complexity will be o(nd) finally for KNN
然后将最小的k个距离存储在列表中,并且将多数票投给K点,这花费了o(1)。 由于我们在运行时需要整个火车数据,因此对于KNN,空间复杂度最终将是未知的
Run Time complexity = O(nd)
运行时间复杂度= O(nd)
Space complexity = O(nd)
空间复杂度= O(nd)
There is no train time complexi