**5. Performance metrics**

*Color Detection*

incubation.

reagent (2.0 mL) to NO2

tilled water. The solutions of PO4

−

observed. The second solution is the phosphate (**PO4**

which is reduced by ascorbic acid. A stock solution of 50ppm **PO4**

−3

Peroxide quantification with colorimetric tests was investigated in [28] and hydrogen peroxide (H2O2) solutions were prepared for the peroxide test strips (Quantofix Peroxide 100). First, a stock solution with 500 ppm concentration of H2O2 (Sigma-Aldrich) was prepared in distilled water. The stock solution was later diluted to prepare the initial concentrations such as 1, 3, 10, 30, and 100 ppm. The peroxide test strips were dipped into these solutions for 1 s, and images were taken

Bisphenol-A (BPA) detection with smartphone spectrometer was demonstrated in [29]. The BPA concentration was determined with absorbance measurements using an immersion probe. The phenolic compound was put into reaction with 4-Aminoantipyrine (4-AAP) (Sigma-Aldrich, >98%) and potassium ferricyanide (Carlo Erba) for colorimetric quantification. Around 200 ppm of BPA stock solution was prepared in ethanol and then test solutions ranging from 0.1 to 10.0 ppm were prepared by serial dilution from the stock solution. The pH of all solutions was set to 8.0 using 0.25 M sodium bicarbonate (NaHCO3) (Sigma-Aldrich, ≤99.7%) and distilled water. To finalize the solutions, 1.5 mL of 20.8 mM 4-AAP and 1.5 mL of 83.4 mM potassium ferricyanide solutions were mixed into 12 mL of BPA solutions. The solutions were ready for the absorbance measurement after 10 min of

Single-image-referenced colorimetric water quality detection in [45] was performed using four different analyte solutions. The first solution is nitrite (NO2

*N*-(1-naphthyl) ethylene diamine dihydrochloride (NED) to produce an azo dye. A stock solution (821 ppm) was prepared by dissolving 1.232 g sodium nitrite in 1 L of distilled water. The buffer stock (164 ppm) and standard (1.64 ppm) solutions were prepared to obtain solutions in concentrations of 0, 0.05, 0.10, 0.20, 0.40, and 0.50 ppm by dilution. The pH of solutions was adjusted with 1 N HCl or NH4OH to give a pH between 5.0 and 9.0. For the color reagent, 10 g of sulfanilamide was dissolved in a mixture of 100 mL of 85% phosphoric acid and 800 mL of distilled water. Then, 1 g of NED was added and diluted to 1 L. After addition of this

ammonium molybdate and antimony potassium tartrate in an acidic medium with solutions containing phosphorus to form an antimony-phosphomolybdate complex

by dissolving 219.5 mg of anhydrous potassium dihydrogenphosphate in 1 L of dis-

0.40, 1.00, and 3.00 ppm were prepared by serial dilution. A composite reagent containing (15 mL, 0.032 M), (5 mL, 0.008 M), and (30 mL, 0.100 M) in 50 mL of 5 N sulfuric acid was provided after each reagent addition. The pH of solution was controlled by 1 drop of phenolphthalein addition into the 50 mL of sample solution. If a red color develops, a strong acid is dropped till the color disappears. Then, 8 mL of the composite reagent was added to the sample solutions and they are allowed to stand for at least 10 min to measure the stable blue color. Hexavalent chromium (Cr(VI)) detection is performed by the formation of a colored complex resulting from the reaction of Cr(VI) with diphenylcarbazide in an acidic medium. A stock solution of 500 ppm Cr(VI) was prepared by dissolving 141.4 mg of dried potassium dichromate in distilled water and diluted to 100 mL. To prepare a standard solution of 5.00 ppm Cr(VI), 1.00 mL of the stock solution was diluted to 100 mL. The solutions of Cr(VI) standards in concentrations of 0, 0.05, 0.10, 0.20, 0.40, 0.50, and 1.00 ppm were prepared by serial dilution. The pH of the standards was adjusted to 2.0 ± 0.5 with 0.25 mL of nitric acid and 0.2 N sulfuric acid. Around 2.0 mL of complexation reagent, freshly prepared by dissolving 250 mg


standards in concentrations of 0, 0.25, 0.50, 0.75,

) determined by the reaction of

**−3** *<sup>−</sup>* **<sup>P</sup>** was prepared

**−3**

it reacts with sulfanilamide to form diazonium ion which was coupled with

− );

by smartphone after they were dried on tissue paper for 5 s.

**76**

Quantitative performance evaluations of smartphone-based spectrometer and colorimeter are an important factor in the development of new algorithms and designs. Standard metrics for regression and classification problems can be used to assess smartphone-based system performance. The importance of metrics varies for each sensing scheme.

In a spectrometer, the absorbance spectrum needs to be calculated using multicolored images. RGB images are mostly converted to HSV images and value (V of HSV) is used to calculate the absorbance (A) using the Beer-Lambert law [56],

$$A = \log\_{10} \frac{I\_0}{I} \tag{1}$$

where *I0* is the transmitted light intensity of reference solution (mostly distilled water), and *I* is the transmitted light intensity of the other solutions. After the absorbance graph is plotted with respect to wavelength, the reference wavelength point which gives the maximum absorbance of the reference solution is selected. Then, the calibration curve, which is basically the linear regression line, is plotted with respect to the reference wavelength point to calculate *R*<sup>2</sup> (the coefficient of determination). *R*<sup>2</sup> is the first metric to evaluate to assess the performance of the model. *R*<sup>2</sup> values greater than 0.9 are acceptable values, although a larger coefficient is accepted as a more successful result. Next, evaluation term is the limit of detection (LOD) defined as the lowest quantity or concentration of an analyte that can be reliably detected with a given analytical method. It is calculated as three standard deviations above the reference solution. The slope of the calibration curve is the sensitivity of the spectrometer.

In classification-based colorimetry, the following metrics are available: classification accuracy, sensitivity (recall), specificity, precision, and f1-score. These metrics are the same in traditional machine learning classification tasks and can be extracted from the confusion matrix. Classification accuracy is detection accuracy in the case of analytical detection. For binary classification problems with only two classes, the receiver operation characteristic (ROC) curve and area under curve (AUC) are additional metrics. In a confusion matrix, rows represent the instances in an actual (true) class while columns represent the instances in a predicted class. To calculate the detection accuracy, diagonal elements of the confusion matrix are summed and

divided by the total number of data points. Precision is calculated by the ratio of true positive events to the sum of true and false positive events as given below:

$$\text{active events to the sum of true and false positive events as given below:}$$

$$\text{Precision} = \frac{True \text{ Positive}}{True \text{ Positive} \text{ \* False Positive}}\tag{2}$$

The sensitivity (recall) is the ratio of true positive to the sum of true positive and false negative:

Be negative:

$$\text{Sensitivity} = \frac{True \, Positive}{True \, Positive + False \, Negative} \tag{3}$$

Lastly, f1 score is the harmonic average of precision and the recall and is equal to 1 for perfect precision and recall:

## 1\
percent\
Precision\
аш

F1 = 2 \times \frac{Precision \times Recall}{Precision + Recall}\tag{4}

Regression and classification metrics should be chosen based on the colorimetric detection scheme. Spectrometric detection requires the use of regression metrics while the detection of discrete color change should be assessed with classification metrics.
