pub struct RangeFilter { /* private fields */ }Expand description
Thread-safe range filter for location-based species filtering
Implementations§
Source§impl RangeFilter
impl RangeFilter
Sourcepub const fn builder() -> RangeFilterBuilder
pub const fn builder() -> RangeFilterBuilder
Create a new range filter builder
Sourcepub fn predict(
&self,
latitude: f32,
longitude: f32,
month: u32,
day: u32,
) -> Result<Vec<LocationScore>>
pub fn predict( &self, latitude: f32, longitude: f32, month: u32, day: u32, ) -> Result<Vec<LocationScore>>
Get species probability scores for given location and date
§Arguments
latitude- Latitude in degrees (-90 to 90)longitude- Longitude in degrees (-180 to 180)month- Month number (1-12)day- Day of month (1-31)
§Returns
Vector of LocationScore sorted by score (descending)
§Errors
Returns error if:
- Coordinates are invalid (latitude not in [-90, 90] or longitude not in [-180, 180])
- Date parameters are invalid (month not in [1, 12] or day not in [1, 31])
- Session lock is poisoned
- ONNX inference fails
Sourcepub fn filter_predictions(
&self,
predictions: &[Prediction],
location_scores: &[LocationScore],
rerank: bool,
) -> Vec<Prediction>
pub fn filter_predictions( &self, predictions: &[Prediction], location_scores: &[LocationScore], rerank: bool, ) -> Vec<Prediction>
Filter predictions based on location scores from meta model
§Arguments
predictions- Original predictions from audio analysislocation_scores- Location-based species scores (frompredict)rerank- Whether to rerank by multiplying confidence by location score
§Returns
Filtered predictions, optionally reranked by location score
§Example
// Get location scores for a specific place and time
let location_scores = filter.predict(45.0, -122.0, 6, 15)?;
// Filter predictions to only include species likely at this location
let filtered = filter.filter_predictions(&predictions, &location_scores, false);Sourcepub fn filter_batch_predictions(
&self,
predictions_batch: Vec<Vec<Prediction>>,
location_scores: &[LocationScore],
rerank: bool,
) -> Vec<Vec<Prediction>>
pub fn filter_batch_predictions( &self, predictions_batch: Vec<Vec<Prediction>>, location_scores: &[LocationScore], rerank: bool, ) -> Vec<Vec<Prediction>>
Filter multiple prediction sets using location scores.
This is a convenience method for batch processing multiple audio files from the same location. Predict location scores once, then apply to multiple prediction sets.
§Arguments
predictions_batch- Vector of prediction vectors to filterlocation_scores- Location scores frompredict()rerank- Whether to rerank each prediction set
§Returns
Vector of filtered prediction vectors
§Example
ⓘ
let location_scores = range_filter.predict(lat, lon, month, day)?;
let mut predictions_batch = Vec::new();
for segment in audio_segments {
let result = classifier.predict(&segment)?;
predictions_batch.push(result.predictions);
}
let filtered_batch = range_filter.filter_batch_predictions(
predictions_batch,
&location_scores,
rerank,
);Trait Implementations§
Source§impl Clone for RangeFilter
impl Clone for RangeFilter
Source§fn clone(&self) -> RangeFilter
fn clone(&self) -> RangeFilter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RangeFilter
impl RefUnwindSafe for RangeFilter
impl Send for RangeFilter
impl Sync for RangeFilter
impl Unpin for RangeFilter
impl UnwindSafe for RangeFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more