bob.machine.KMeansMachine¶
-
class
bob.machine.KMeansMachine((object)self) → None¶ Bases:
bob.machine._machine.MachineDoubleBaseThis class implements a k-means classifier. See Section 9.1 of Bishop, “Pattern recognition and machine learning”, 2006
__init__( (object)self, (int)n_means, (int)n_inputs) -> None
__init__( (object)arg1, (KMeansMachine)self) -> None
__init__( (object)self, (HDF5File)config) -> None
-
__init__((object)self) → None¶ __init__( (object)self, (int)n_means, (int)n_inputs) -> None
__init__( (object)arg1, (KMeansMachine)self) -> None
__init__( (object)self, (HDF5File)config) -> None
Methods
__init__((object)self)__init__( (object)self, (int)n_means, (int)n_inputs) -> None forward((MachineDoubleBase)self, (object)input)Executes the machine on the given 1D numpy array of float64, and returns the output. forward_((MachineDoubleBase)self, (object)input)Executes the machine on the given 1D numpy array of float64, and returns the output. get_closest_mean((KMeansMachine)self, (object)x)Calculate the index of the mean that is closest (in terms of square Euclidean distance) to the data sample, x get_distance_from_mean((KMeansMachine)self, …)Return the power of two of the square Euclidean distance of the sample, x, to the i’th mean get_mean((KMeansMachine)self, (int)i)Get the i’th mean get_min_distance((KMeansMachine)self, …)Output the minimum square Euclidean distance between the input and one of the means get_variances_and_weights_for_each_cluster(…)For each mean, find the subset of the samples that is closest to that mean, and calculate 1) the variance of that subset (the cluster variance) 2) the proportion of the samples represented by that subset (the cluster weight) is_similar_to((KMeansMachine)self, …)Compares this KMeansMachine with the ‘other’ one to be approximately the same. load((KMeansMachine)self, (HDF5File)config)Load from a Configuration resize((KMeansMachine)self, (int)n_means, …)Resize the number of means and inputs save((KMeansMachine)self, (HDF5File)config)Save to a Configuration set_mean((KMeansMachine)self, (int)i, …)Set the i’th mean Attributes
dim_cNumber of means (k) dim_dNumber of inputs meansThe mean vectors -
__call__((MachineDoubleBase)self, (object)input) → float :¶ Executes the machine on the given 1D numpy array of float64, and returns the output. NO CHECK is performed.
-
dim_c¶ Number of means (k)
-
dim_d¶ Number of inputs
-
forward((MachineDoubleBase)self, (object)input) → float :¶ Executes the machine on the given 1D numpy array of float64, and returns the output.
-
forward_((MachineDoubleBase)self, (object)input) → float :¶ Executes the machine on the given 1D numpy array of float64, and returns the output. NO CHECK is performed.
-
get_closest_mean((KMeansMachine)self, (object)x) → tuple :¶ Calculate the index of the mean that is closest (in terms of square Euclidean distance) to the data sample, x
-
get_distance_from_mean((KMeansMachine)self, (object)x, (int)i) → float :¶ Return the power of two of the square Euclidean distance of the sample, x, to the i’th mean
-
get_mean((KMeansMachine)self, (int)i) → object :¶ Get the i’th mean
-
get_min_distance((KMeansMachine)self, (object)input) → float :¶ Output the minimum square Euclidean distance between the input and one of the means
-
get_variances_and_weights_for_each_cluster((KMeansMachine)self, (object)data) → tuple :¶ For each mean, find the subset of the samples that is closest to that mean, and calculate 1) the variance of that subset (the cluster variance) 2) the proportion of the samples represented by that subset (the cluster weight)
-
is_similar_to((KMeansMachine)self, (KMeansMachine)other[, (float)r_epsilon=1e-05[, (float)a_epsilon=1e-08]]) → bool :¶ Compares this KMeansMachine with the ‘other’ one to be approximately the same.
-
load((KMeansMachine)self, (HDF5File)config) → None :¶ Load from a Configuration
-
means¶ The mean vectors
-
resize((KMeansMachine)self, (int)n_means, (int)n_inputs) → None :¶ Resize the number of means and inputs
-
save((KMeansMachine)self, (HDF5File)config) → None :¶ Save to a Configuration
-
set_mean((KMeansMachine)self, (int)i, (object)mean) → None :¶ Set the i’th mean
-