Run: cargo clippy --fix -Z unstable-options and cargo fmt

This commit is contained in:
Luis Moreno
2020-11-08 19:39:11 -04:00
parent 8281a1620e
commit 860056c3ba
48 changed files with 367 additions and 395 deletions
+3 -3
View File
@@ -42,9 +42,9 @@ impl AUC {
for i in 0..n {
if y_true.get(i) == T::zero() {
neg = neg + T::one();
neg += T::one();
} else if y_true.get(i) == T::one() {
pos = pos + T::one();
pos += T::one();
} else {
panic!(
"AUC is only for binary classification. Invalid label: {}",
@@ -79,7 +79,7 @@ impl AUC {
let mut auc = T::zero();
for i in 0..n {
if y_true.get(label_idx[i]) == T::one() {
auc = auc + rank[i];
auc += rank[i];
}
}
+3 -4
View File
@@ -37,7 +37,7 @@ pub fn entropy<T: RealNumber>(data: &Vec<T>) -> Option<T> {
for &c in bincounts.values() {
if c > 0 {
let pi = T::from_usize(c).unwrap();
entropy = entropy - (pi / sum) * (pi.ln() - sum.ln());
entropy -= (pi / sum) * (pi.ln() - sum.ln());
}
}
@@ -89,9 +89,8 @@ pub fn mutual_info_score<T: RealNumber>(contingency: &Vec<Vec<usize>>) -> T {
let mut result = T::zero();
for i in 0..log_outer.len() {
result = result
+ ((contingency_nm[i] * (log_contingency_nm[i] - contingency_sum_ln))
+ contingency_nm[i] * log_outer[i])
result += (contingency_nm[i] * (log_contingency_nm[i] - contingency_sum_ln))
+ contingency_nm[i] * log_outer[i]
}
result.max(T::zero())
+1 -1
View File
@@ -43,7 +43,7 @@ impl MeanAbsoluteError {
let n = y_true.len();
let mut ras = T::zero();
for i in 0..n {
ras = ras + (y_true.get(i) - y_pred.get(i)).abs();
ras += (y_true.get(i) - y_pred.get(i)).abs();
}
ras / T::from_usize(n).unwrap()
+1 -1
View File
@@ -43,7 +43,7 @@ impl MeanSquareError {
let n = y_true.len();
let mut rss = T::zero();
for i in 0..n {
rss = rss + (y_true.get(i) - y_pred.get(i)).square();
rss += (y_true.get(i) - y_pred.get(i)).square();
}
rss / T::from_usize(n).unwrap()
+1 -1
View File
@@ -101,7 +101,7 @@ impl ClassificationMetrics {
/// F1 score, also known as balanced F-score or F-measure, see [F1](f1/index.html).
pub fn f1<T: RealNumber>(beta: T) -> f1::F1<T> {
f1::F1 { beta: beta }
f1::F1 { beta }
}
/// Area Under the Receiver Operating Characteristic Curve (ROC AUC), see [AUC](auc/index.html).
+4 -4
View File
@@ -45,10 +45,10 @@ impl R2 {
let mut mean = T::zero();
for i in 0..n {
mean = mean + y_true.get(i);
mean += y_true.get(i);
}
mean = mean / T::from_usize(n).unwrap();
mean /= T::from_usize(n).unwrap();
let mut ss_tot = T::zero();
let mut ss_res = T::zero();
@@ -56,8 +56,8 @@ impl R2 {
for i in 0..n {
let y_i = y_true.get(i);
let f_i = y_pred.get(i);
ss_tot = ss_tot + (y_i - mean).square();
ss_res = ss_res + (y_i - f_i).square();
ss_tot += (y_i - mean).square();
ss_res += (y_i - f_i).square();
}
T::one() - (ss_res / ss_tot)