Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use std::path::{Path, PathBuf};
const N_FEATURES: usize = 15;

/// Activity classes we recognise.
pub const CLASSES: &[&str] = &["absent", "present_still", "present_moving", "active"];
const N_CLASSES: usize = 4;
pub const CLASSES: &[&str] = &["absent", "present_still", "present_moving", "active", "2p_still", "2p_moving", "2p_active"];
const N_CLASSES: usize = 7;
Comment on lines +24 to +25
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding 2-person classes changes N_CLASSES/CLASSES, but existing saved adaptive models (e.g., data/adaptive_model.json) may still contain weights/stats for 4 classes. With the current classify() implementation, the extra class logits default to 0 and can dominate the softmax, causing an old 4-class model to incorrectly predict a 2p_* label. Add compatibility handling: validate class count on load (reject/ignore mismatched models) or pad missing logits with a large negative value so new classes can't be selected unless trained.

Suggested change
pub const CLASSES: &[&str] = &["absent", "present_still", "present_moving", "active", "2p_still", "2p_moving", "2p_active"];
const N_CLASSES: usize = 7;
pub const CLASSES: &[&str] = &[
"absent",
"present_still",
"present_moving",
"active",
"2p_still",
"2p_moving",
"2p_active",
];
pub const N_CLASSES: usize = CLASSES.len();

Copilot uses AI. Check for mistakes.

/// Extract extended feature vector from a JSONL frame (features + raw amplitudes).
pub fn features_from_frame(frame: &serde_json::Value) -> [f64; N_FEATURES] {
Expand Down Expand Up @@ -231,7 +231,10 @@ fn load_recording(path: &Path, class_idx: usize) -> Vec<Sample> {
/// Map a recording filename to a class index.
fn classify_recording_name(name: &str) -> Option<usize> {
let lower = name.to_lowercase();
if lower.contains("empty") || lower.contains("absent") { Some(0) }
if lower.contains("2p_still") || lower.contains("2p_sitting") { Some(4) }
else if lower.contains("2p_moving") || lower.contains("2p_walking") { Some(5) }
else if lower.contains("2p_active") || lower.contains("2p_exercise") { Some(6) }
else if lower.contains("empty") || lower.contains("absent") { Some(0) }
else if lower.contains("still") || lower.contains("sitting") || lower.contains("standing") { Some(1) }
else if lower.contains("walking") || lower.contains("moving") { Some(2) }
else if lower.contains("active") || lower.contains("exercise") || lower.contains("running") { Some(3) }
Expand Down
Loading
Loading