-
-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Target naming #256
Target naming #256
Changes from all commits
b96d84f
a5b344a
81dfd57
9ef33d5
c0d0c4b
e3234e6
b4ed2a3
3d07413
5842ecb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,7 @@ impl Deref for Pr { | |
/// * `targets`: a two-/one-dimension matrix with dimensionality (nsamples, ntargets) | ||
/// * `weights`: optional weights for each sample with dimensionality (nsamples) | ||
/// * `feature_names`: optional descriptive feature names with dimensionality (nfeatures) | ||
/// * `target_names`: optional descriptive target names with dimensionality (ntargets) | ||
/// | ||
/// # Trait bounds | ||
/// | ||
|
@@ -180,6 +181,7 @@ where | |
|
||
pub weights: Array1<f32>, | ||
feature_names: Vec<String>, | ||
target_names: Vec<String>, | ||
} | ||
|
||
/// Targets with precomputed, counted labels | ||
|
@@ -343,6 +345,19 @@ mod tests { | |
assert!(dataset.into_single_target().targets.shape() == [10]); | ||
} | ||
|
||
#[test] | ||
fn set_target_name() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add target name verification to one or two tests with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed lines 551-556 now test this. |
||
let dataset = Dataset::new(array![[1., 2.], [1., 2.]], array![0., 1.]) | ||
.with_target_names(vec!["test"]); | ||
assert_eq!(dataset.target_names, vec!["test"]); | ||
} | ||
|
||
#[test] | ||
fn empty_target_name() { | ||
let dataset = Dataset::new(array![[1., 2.], [1., 2.]], array![[0., 1.], [2., 3.]]); | ||
assert_eq!(dataset.target_names, Vec::<String>::new()); | ||
} | ||
|
||
#[test] | ||
fn dataset_implements_required_methods() { | ||
let mut rng = SmallRng::seed_from_u64(42); | ||
|
@@ -540,7 +555,7 @@ mod tests { | |
let dataset = Dataset::new( | ||
array![[1., 2., 3., 4.], [5., 6., 7., 8.], [9., 10., 11., 12.]], | ||
array![[1, 2], [3, 4], [5, 6]], | ||
); | ||
).with_target_names(vec!["a", "b"]); | ||
|
||
let res = dataset | ||
.target_iter() | ||
|
@@ -549,6 +564,13 @@ mod tests { | |
|
||
assert_eq!(res, &[array![1, 3, 5], array![2, 4, 6]]); | ||
|
||
let mut iter = dataset.target_iter(); | ||
let first = iter.next(); | ||
let second = iter.next(); | ||
|
||
assert_eq!(vec!["a"], first.unwrap().target_names()); | ||
assert_eq!(vec!["b"], second.unwrap().target_names()); | ||
|
||
let res = dataset | ||
.feature_iter() | ||
.map(|x| x.records) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should check the length of the input vector so that it's equal to number of targets. The input should be Vec so that it can be assigned directly. You can also try implementing this change for
feature_names
, but that might require more work to change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the input for the function is already Vec(I) where I implements Into(String). Unless I am mistaken you want something like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah pretty much. I don't mind panicking here, so you can just
assert
the condition.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha