📜  变量估计 |设置 1

📅  最后修改于: 2022-05-13 01:55:24.115000             🧑  作者: Mango

变量估计 |设置 1

可变性:衡量数据变化的导入维度,即数据是分散的还是紧密聚集的。也称为分散在机器学习或数据科学中处理数据集时,它涉及许多步骤——方差测量、减少、区分随机可变性和真实可变性。识别实际可变性的来源,根据它做出关于预处理选择或模型选择的决策。

与变异性度量相关的术语:

-> Deviation 
-> Variance
-> Standard Deviation
-> Mean Absolute Deviation
-> Meadian Absolute Deviation
-> Order Statistics
-> Range
-> Percentile 
-> Inter-quartile Range
  • 偏差:我们也可以称之为错误或残差。它是衡量值与中心值/观察值之间的差异/分散程度的度量。
    例子 :
Sequence : [2, 3, 5, 6, 7, 9] 
Suppose, Central/Observed Value = 7

Deviation = [-5, -4, -2, -1, 0, 2]
  • 方差(s 2 ):这是估计方差的最知名的度量,因为它是平方偏差。可以将其称为均方误差,因为它是标准偏差的平均值。

例子 :

Sequence : [2, 3, 5, 6, 7, 9] 
Mean              = 5.33
Total Terms, n    = 6
Squared Deviation = (2 - 5.33)2 + (3 - 5.33)2 + (5 - 5.33)2
                    (6 - 5.33)2 + (7 - 5.33)2 + (9 - 5.33)2
Variance          = Squared Deviation / n

代码 -

Python3
# Variance
 
import numpy as np
 
Sequence = [2, 3, 5, 6, 7, 9]
 
var = np.var(Sequence)
 
print("Variance : ", var)


Python3
# Standard Deviation
 
import numpy as np
 
Sequence = [2, 3, 5, 6, 7, 9]
 
std = np.std(Sequence)
 
print("Standard Deviation : ", std)


Python3
# Mean Absolute Deviation
 
import numpy as np
 
def mad(data):
    return np.mean(np.absolute(
            data - np.mean(data)))
     
Sequence = [2, 4, 6, 8]
 
print ("Mean Absolute Deviation : ", mad(Sequence))


输出 :

Variance :  5.5555555555555545
  • 标准偏差:它是方差的平方根。也称为欧几里得范数

例子 :

Sequence : [2, 3, 5, 6, 7, 9] 
Mean              = 5.33
Total Terms, n    = 6
Squared Deviation = (2 - 5.33)2 + (3 - 5.33)2 + (5 - 5.33)2
                    (6 - 5.33)2 + (7 - 5.33)2 + (9 - 5.33)2

Variance             = Squared Deviation / n
Standard Deviation   = (Variance)1/2

代码 -

Python3

# Standard Deviation
 
import numpy as np
 
Sequence = [2, 3, 5, 6, 7, 9]
 
std = np.std(Sequence)
 
print("Standard Deviation : ", std)

输出 :

Standard Deviation :  2.357022603955158
  • 平均绝对偏差:可以估计这些偏差的典型估计值。如果我们平均这些值,负偏差将抵消正偏差。此外,与平均值的偏差总和始终为零。因此,采用平均偏差本身是一种简单的方法。

例子 :

Sequence : [2, 4, 6, 8] 
Mean     = 5
Deviation around mean = [-3, -1, 1, 3]

Mean Absolute Deviation = (3 + 1 + 1 + 3)/ 4

Python3

# Mean Absolute Deviation
 
import numpy as np
 
def mad(data):
    return np.mean(np.absolute(
            data - np.mean(data)))
     
Sequence = [2, 4, 6, 8]
 
print ("Mean Absolute Deviation : ", mad(Sequence))

输出 :

Mean Absolute Deviation :  2.0