feat: adds serialization/deserialization methods

This commit is contained in:
Volodymyr Orlov
2020-04-03 11:12:15 -07:00
parent 5766364311
commit eb0c36223f
16 changed files with 555 additions and 159 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct LinearRegression<T: FloatExt, M: Matrix<T>> {
impl<T: FloatExt, M: Matrix<T>> PartialEq for LinearRegression<T, M> {
fn eq(&self, other: &Self) -> bool {
self.coefficients == other.coefficients &&
self.intercept == other.intercept
(self.intercept - other.intercept).abs() <= T::epsilon()
}
}
+13 -4
View File
@@ -42,10 +42,19 @@ struct BinaryObjectiveFunction<'a, T: FloatExt, M: Matrix<T>> {
impl<T: FloatExt, M: Matrix<T>> PartialEq for LogisticRegression<T, M> {
fn eq(&self, other: &Self) -> bool {
self.num_classes == other.num_classes &&
self.classes == other.classes &&
self.num_attributes == other.num_attributes &&
self.weights == other.weights
if self.num_classes != other.num_classes ||
self.num_attributes != other.num_attributes ||
self.classes.len() != other.classes.len() {
return false
} else {
for i in 0..self.classes.len() {
if (self.classes[i] - other.classes[i]).abs() > T::epsilon(){
return false
}
}
return self.weights == other.weights
}
}
}