Errata

Rust for Machine Learning

Errata for Rust for Machine Learning

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
ePub Page Chapter 1, The First Neuron
Building the Classifier

The PerceptronClassifier defined in Chapter 1 fails to correctly classify data for the logical if and only if connector, iff. When both inputs are false, iff is true. However, the test, shown below, fails on the the following assertion:
assert_eq!(classifier.classify(vec![-1.0, -1.0]), 1.0);
Here is the error report:
assertion `left == right` failed
left: -1.0
right: 1.0
Here is the test:
#[test]
fn it_classifies_iff_inputs() {
let csv_data = String::from(
"1,1,1\n\
1,-1,-1\n\
-1,1,-1\n\
-1,-1,1\n",
);

let data = load_data_from_csv(csv_data);
let (input, labels) = split_columns(data);

let mut classifier = PerceptronClassifier::new(100);
classifier.train(input, labels);

assert_eq!(classifier.classify(vec![-1.0, -1.0]), 1.0);
assert_eq!(classifier.classify(vec![1.0, -1.0]), -1.0);
assert_eq!(classifier.classify(vec![-1.0, 1.0]), -1.0);
assert_eq!(classifier.classify(vec![1.0, 1.0]), 1.0);
}

I'm trying to understand the author's Perceptron code. Any explanation as to why this failure occurs (along with possible fixes) would be appreciated.

Glenn   Aug 05, 2026