-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce multi targets and probability matrices (#88)
* rename `Targets` to `AsTargets` and introduce `AsTargetsMut` for mutable borrowing and `FromTargetArray` for counted labels construction * default to multi-target datasets in `pub type Dataset..` * re-name `observations` to `nsamples` and add `ntargets` * rename `frequencies_with_mask` to `label_frequencies_with_mask` * add `sample_iter`, `target_iter`, `feature_iter` iterators * rename `axis_chunks_iter` to `sample_chunks` * rename `bootstrap` to `bootstrap_samples` and add `bootstrap` (simultaneously sample features and samples) and `bootstrap_features` * add a `try_single_target -> Result<..>` which may return an `Error::MultipleTargets` for use in ROC/SVM/etc. * add `FromTarget` in order to accept `Array1` in `Dataset::new` and use `Targets == Array2<()>` for empty targets * add `PredictRef` which is used by a "proxy" trait `Predict` to derive all possible input/output combinations * add tests to `linfa-datasets` * add error types with `thiserror` where possible
- Loading branch information
Showing
55 changed files
with
2,133 additions
and
1,429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
use std::fmt; | ||
|
||
use ndarray_stats::errors::MinMaxError; | ||
use thiserror::Error; | ||
|
||
pub type Result<T> = std::result::Result<T, BayesError>; | ||
|
||
#[derive(Debug)] | ||
#[derive(Error, Debug)] | ||
pub enum BayesError { | ||
/// Error when performing Max operation on data | ||
Stats(MinMaxError), | ||
} | ||
|
||
impl fmt::Display for BayesError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Self::Stats(error) => write!(f, "Ndarray Stats Error: {}", error), | ||
} | ||
} | ||
#[error("invalid statistical operation {0}")] | ||
Stats(#[from] MinMaxError), | ||
#[error(transparent)] | ||
BaseCrate(#[from] linfa::Error), | ||
} | ||
|
||
impl From<MinMaxError> for BayesError { | ||
fn from(error: MinMaxError) -> Self { | ||
Self::Stats(error) | ||
} | ||
} | ||
|
||
impl std::error::Error for BayesError {} |
Oops, something went wrong.