RUFAS.routines.animal.clustering_pen_grouping module#

RUFAS.routines.animal.clustering_pen_grouping.norm(x: List[int | float]) ndarray[tuple[int, ...], dtype[float64 | int64]]#

Normalizes a list of numerical values and returns the normalized list.

This function takes a list of integers or floats, converts it to a NumPy array, and normalizes the values to a range between 0 and 1.

Parameters#

xList[int | float]

A list of numerical values to be normalized.

Returns#

npt.NDArray[np.float64 | np.int64]

A NumPy array of normalized values if the input has varying values, otherwise the original array.

RUFAS.routines.animal.clustering_pen_grouping.percentile_list(original_list: List[int | float]) List[int | float]#

Calculates a list of percentiles corresponding to the matching value in the original list.

This function takes a list of integers or floats and calculates the percentile rank of each element within the list. The percentile rank is then normalized by dividing by 100, resulting in values between 0 and 1.

Parameters#

original_listList[int | float]

A list of numerical values for which the percentiles are to be calculated.

Returns#

List[int | float]

A list of normalized percentiles, each value representing the percentile of the corresponding element in the original list, divided by 100.

RUFAS.routines.animal.clustering_pen_grouping.grouping(cow_list, pens, stocking_density)#

Grouping algorithm that utilizes k-means clustering and takes an input that is a list of objects of class cow (see cow.py) and a list of pen objects (from pen.py), and then groups the lactating cows into the available pens based on their nutritional requirements relative to the rest of the cows.

Args:

cow_list: a list of lactating cows pens: a list of pens allocated for lactating stocking_density: The required stocking density to group all cows