SlideShare a Scribd company logo
1 of 26
Download to read offline
 
Building an Optical pH Sensor for PET Probes
using Machine Learning Models
Megha Srivastava
 
	
  
Abstract
Positron Emission Tomography (PET), a powerful technique for imaging molecular processes to diagnose
diseases in the human body, requires injection of probes with a radioactive isotope that emits positron. Due to
the short half-life of the isotope, the various radiochemistry synthesis and analysis steps in preparing a probe
and testing its quality and safety are done in specialized laboratories located close to hospitals. A miniature
microfluidics-based instrument to automate the radiochemistry steps on-site at the hospital is currently under
development, and would lower the cost of PET probe production.
One important quality control step is ensuring that the pH of the synthesized probe is in a safe range for
injection into humans. This project created a novel optical pH sensor that works with the tiny volumes of
probe sample available in the microfluidics system while meeting the accuracy requirements. Current
methods, such as pH meters based on electrochemical sensors, and pH patches that are spectrally analyzed,
require large volumes of liquid. The developed sensor relies on mixing in a Universal Indicator (a chemical
that produces a range of colors depending on the solution’s pH), and using a spectrophotometer to measure
the solution’s absorbance vs. wavelength characteristic embedded in which is color information.
Sophisticated machine learning algorithms are used to learn statistical models from training data
of absorbance vs. wavelength measurements for probes with known pH. Finally, the models are used to
classify as safe or unsafe probes with unknown pH, or to predict the actual value of their pH. With a decision
tree model, which was the best among several candidates, the sensor upon testing with a different set of test
samples, gave accuracy, average recall, and average precision of 100% in predicting pH safety, and 0.29
mean and 1.0 maximum absolute error in estimating pH value.
  1	
  
	
  
Research Report
I. Introduction
Positron Emission Tomography [1], or PET, is a type of non-invasive imaging technique used for medical
diagnosis of various diseases by creating a three-dimensional picture of molecular processes inside the body.
It involves injecting into a subject’s blood stream a probe with a radioactive isotope that emits positrons,
such as 18
F. The probe labels the molecules of interest inside the body, and the photons resulting from
positron-electron annihilations are detected to construct an image of the distribution of the molecules. PET
probe development starts with the production of the radioactive isotope in a cyclotron, followed by a series of
chemical reaction and analysis steps to create the probe and test its safety for human injection, and then
transportation to the hospital for injections. Short half-lives of the isotopes necessitate that the PET
production be located close to the hospital, thus making PET probes expensive.
One way to solve this problem is to create a small and efficient instrument which can perform with minimal
human intervention all the necessary radiochemistry steps for production and safety testing of the probe, and
which the hospitals can use on site. To engineer such an instrument, researchers are exploring [2] the use of
the emerging microfluidics technologies [3, 4], which enable small volumes of fluids to be precisely
manipulated at very small scales. A microfluidics-based instrument would robotically perform on small
volumes of radioactive fluids the various chemical synthesis and analysis steps involved in manufacturing a
PET probe. Of particular importance in a microfluidics-based instrument for PET probes are the steps which
determine the quality and safety of the probes prior to human injection, and which one can envision as being
performed inside the “Quality Control (QC) Box” subsystem of the overall instrument. To ensure the quality
and safety of the probe, the QC Box would measure chemical properties such as concentration, clarity, and
pH.
The goal of this research project is to create a sensing method which could assess for a small volume of
liquid whether the pH is in a safe range (4 to 8), i.e. compatible with human body, and which can be realized
at a size small enough to be incorporated in the microfluidic instrument.
The current way of measuring the pH of PET probes is by using a pH meter, similar in its operating principle
to the pH testers used for water in swimming pools and aquariums. Invented nearly sixty years ago by Prof.
Beckman at CalTech, a pH meter [5] consists of a glass rod (called the pH probe) with integrated current
electrodes and amplifier, and an electronics module with circuitry for measuring the current and converting it
into a pH value to display. Unfortunately, a pH meter is not suited for use in the QC Box for PET probe
  2	
  
testing, as it needs a volume of the fluid that is far above the microfluidics ranges. Recently, commercial
systems have emerged that perform optical pH sensing by using a fiber optic probe connected to a
spectrometer to observe changes in the color of pH indicator dyes. Conceptually this is similar to the
centuries old litmus paper [6] approach to measuring pH, except that a better pH indicator is used and the
color change is observed by a spectrometer instead of the human eye. The dyes are encapsulated inside
special sol-gel materials and coated either on transmissive patches [7] affixed inside the optical probes that
are dipped into the fluid or on reflective patches [8] affixed inside fluid containers with the optical probe in
contact with the patch. Like the pH meters, these systems also do not work with the small volumes of fluids.
While researchers are developing methods which could work with small volumes of fluid, such as pH-
sensing chips with ion-sensitive transistors [9] and microfluidics platforms with integrated electronics and
optical sensors [10], those technologies are still in research phase or too costly.
II. Materials & Methods
II.A. Overview of Approach
None of the currently practical methods for determining pH described above simultaneously satisfy all the
requirements presented by the microfluidics based QC Box for PET probes: low cost, small in size, capable
of working with small volumes of fluid, and accurate. Therefore, based on the suggestion of my project
mentor, I explored a miniaturized optical sensing approach to pH testing of PET probe. The QC Box being
prototyped in my mentor’s laboratory contains a small spectrophotometer1
for ultraviolet and visible light to
which fiber optic capillary (FOCap) waveguides [11] can be connected. FOCaps are optical fibers with an air
hole core, which can be filled with the fluid on which optical analysis can be performed for diverse chemical
sensing needs [12]. With this setup, the high level pH sensing approach is as follows:
1. Identify a suitable pH indicator2
which when mixed with the PET probe would result in sufficiently
sensitive change in color in the pH range of interest (3 to 8) so to make the testing of PET probe easy
and accurate.
2. The microfluidics components in the QC Box pump a tiny volume of the PET probe fluid mixed
with the selected pH indicator into the core of the FOCap. With a properly chosen indicator, the fluid
sample mixture would have a color that can be detected to determine whether the pH is in the safe
range or not.
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
1
An instrument that combines a spectrometer with a photometer to measure light intensity vs. wavelength.
2
A chemical that changes color with pH, and is added in small amounts to a solution to visually determine
pH.
  3	
  
3. The color of a solution corresponds to a unique absorbance vs. wavelength signature. The
spectrophotometer in the QC Box would measure the light absorbance of the fluid sample by passing
through it monochromatic light of different wavelengths, and measuring the output light intensity to
compute the absorbance of the fluid as a function of the wavelength.
4. A computation analysis module would take as input the spectrophotometer measurements, and
algorithmically determine whether the pH is safe or not.
Figure	
  1:	
  Color	
  variation	
  with	
  pH	
  for	
  the	
  selected	
  
universal	
  indicator	
  
Figure	
  2:	
  Lab-­‐bench	
  recreation	
  of	
  the	
  
microfluidic	
  setup	
  for	
  testing	
  
With the necessary microfluidic and optical infrastructure for the QC Box already in place (my experiments
used the lab-bench re-creation of the relevant component of the QC Box, as shown in Figure 1), the focus of
my project was on the first and the last steps, namely identifying a suitable pH indicator, and devising the
computation analysis module. These two steps are mutually dependent as a good choice of an indicator can
make the computational module work better. My goal was to come up with a solution that would give high
quality results and be immune to uncertainty in measured absorbance caused by changes in the optical path
due to chemical and instrumentation tolerances, mechanical offsets, calibration problems, and other errors.
Within the scope of the optical pH sensing approach outlined above, I explored two specific alternatives.
II.B. Initial Method: Single pH Indicator with Closed Form Analysis
The first method [13] that I tried is based on using a single pH indicator [14], similar to the approach in
existing macro-scale pH sensing systems [7, 8]. The pH indicator has an acid form HInd and a conjugate
basic form Ind!
, with the two forms having different colors. An example of an indicator is Bromocresol
Green (BCG) [14], which changes color from yellow through green to blue over the narrow range of pH from
3.5 to 6. The concentration of the two forms in a solution are governed by the reaction 𝐻𝐼𝑛𝑑   + 𝐻! 𝑂 ↔
𝐻! 𝑂!
+ 𝐼𝑛!
for which the equilibrium equation is 𝐾! = [𝐻! 𝑂!
][𝐼𝑛!
]/[𝐻𝐼𝑛] where K! is the acid
  4	
  
disassociation constant [15] of the indicator. From this, the 𝑝𝐻 is derived via the Henderson–Hasselbalch
equation [16] 𝑝𝐻 = 𝑝𝐾! + 𝑙𝑜𝑔!"([𝐼𝑛!
]/[𝐻𝐼𝑛]) where 𝑝𝐾! = −𝑙𝑜𝑔!"(𝐾!). The 𝑝𝐻 of the solution can be
determined if an indicator of known 𝑝𝐾!is used, and [𝐼𝑛!
]/[𝐻𝐼𝑛] is measured. The latter can be computed
by measuring absorbance of the solution using the spectrophotometer and making use of two observations.
First, according to Beer-Lambert Law [17] absorbance 𝐴 of a solution at a specific wavelength 𝜆 is the
product of the molar absorptivity 𝜀!  at that wavelength, the molar concentration 𝑐 of the absorbing particles,
and the distance 𝑙 that the light travels through the material (which in my system is the width of the fiber
optic capillary tube). Second, the total absorbance of the probe and indicator mixture solution at any given
wavelength is the sum of the absorbance due to the two individual forms of the indicator (the probe itself is
colorless). Based on these observations, [𝐼𝑛!
] and [𝐻𝐼𝑛] (and thus [𝐼𝑛!
]/[𝐻𝐼𝑛]) can be determined via a
two-step process. In an initial calibration step the wavelengths of maximum absorbance for the two forms of
the indicator are experimentally determined, and the molar absorptivity for each of the two forms of the
indicator at each of the two identified wavelengths measured. Next, the total absorbance of the solution under
test is measured at the same two wavelengths, and the following pair of simultaneous equations is solved to
obtain [𝐼𝑛!
] and [𝐻𝐼𝑛] : 𝐴!!
= 𝜀!"#,!!
∗ 𝑙 ∗ [𝐻𝐼𝑛] + 𝜀!"!,!!
∗ 𝑙 ∗ [𝐼𝑛!
] , and 𝐴!!
= 𝜀!"#,!!
∗ 𝑙 ∗ [𝐻𝐼𝑛] +
𝜀!"!,!!
∗ 𝑙 ∗ [𝐼𝑛!
]. Once the ratio [𝐼𝑛!
]/[𝐻𝐼𝑛] has been calculated, the pH of the sample can be determined.
II.C. New Method: Universal pH Indicator with Machine Learning Based Analysis
Evaluation results of the initial method (see Section III.A) indicated severe limitations in our application.
Therefore, I devised a second method for optical analysis of pH that overcomes these limitations by using a
Universal Indicator [18] together with advanced machine learning algorithms to infer whether the pH of the
PET probe is in a safe range. A Universal Indicator is a mixture of several different indicators selected so that
the overall mixture exhibits several smooth color changes over a wider range of pH values as shown by the
example in Figure 1. There are many universal pH indicators available, and I selected one which suited the
requirements of PET probe testing, namely being able to determine with an error of less than 1 the values of
pH in the range of 4 to 8 which is considered safe for human use.
Since a universal indicator is composed of multiple indicators, a solution with the universal indicator mixed
in would have the acid and base forms of each of those indicators present with the concentrations depending
on the pH. With so many forms present, the analysis approaches used with the single indicator method are
not applicable. Computing pH from the closed form model based on the Beer-Lambert Law does not
generalize to the case with multiple indicators. One must look for a more sophisticated way of conducting
the analysis that would determine the pH, and a key contribution of my work is developing such a method. I
drew inspiration from the way a Universal Indicator is conventionally used: it is impregnated into a test strip
  5	
  
made of absorbent paper or added directly to the solution under test. The test strip or the solution under test
changes color, and a user matches the color against a reference chart to determine the pH.
In our application the UV/Vis spectrophotometer in the QC Box measures absorbance as a function of the
wavelength, and this data has all the information about the color that human eyes would see. Human brains
interpret colors by combining the output signals of “cone” photoreceptors in the eye’s retina. The cones
come in three types, each type with a different but overlapping absorption vs. wavelength response function.
The cones are informally referred to as red, green, and blue types corresponding to wavelengths where the
peaks of the three types of response functions lie. The signal sent by a cone to the brain is the convolution
integral of the incident light and the response function, and using it the brain interprets color [19, 20]. In
contrast, a spectrophotometer’s output has much more information about the incident light’s spectrum than is
present in the information sent by the cones in the eye retinas to the human brain. In fact, a
spectrophotometer provides as output the entire absorbance vs. wavelength function at a very high
wavelength resolution. As another comparison, the image sensors in digital cameras capture light intensity in
only three narrow regions of wavelength, corresponding to the red, green, and blue pixels. While sufficient to
recreate perception of natural colors by humans seeing the captured image, these image sensors also capture
far less information about the absorbance vs. wavelength function than a spectrophotometer does.
The preceding observations suggest the possibility of algorithms that would take as input the
spectrophotometer measurements, and produce as output an estimate of the pH or a decision as to whether
the pH is in the safe range or not. The additional information present in the spectrophotometer output than
just the human-perceivable colors might even make it possible for the algorithm to be simple and more
accurate than pH measurement via color charts.
Machine Learning Based pH Analysis Approach
One way to develop such an algorithm is by employing tools and techniques from Machine Learning (ML)
[21, 22], an area at the intersection of Artificial Intelligence, Signal Processing, and Statistics which
specializes in the construction of computational systems that learn models from training data samples and
subsequently use the models for classification and regression tasks over new data samples. Classification
involves computing over the data a function whose output value is a class or category label, while regression
involves computing a numerical function.
Formulating the ML Problem: In ML terms, the PET probe pH testing tasks can be posed as one of the
following: (i) A two-category classification task: safe (i.e. pH is in the range 4 to 8) vs. unsafe (i.e. pH is
below 4 or more than 8), (ii) A three-category classification task: safe (i.e. pH is in the range 4 to 8) vs. high
(i.e. pH is more than 8) vs. low (i.e. pH is less than 4), and (iii) A regression task where the actual numerical
  6	
  
value of pH is estimated. While for testing purposes the two-category classification is sufficient and one
would expect the algorithms to be simplest and perform the best, the three-category classification and the
regression-based of pH value provide additional valuable information. Therefore I explored algorithms for all
three cases.
Model Learning Method: Furthermore, ML researchers have developed a variety of different types of
learning models and there are many tools freely available for one to use. I decided to focus on three
approaches: (i) Decision Tree [23] (comes as two variants: Classification Tree and Regression Tree) where
the model is structured as a tree of decisions over the inputs leading to prediction of the class or numerical
estimate of a variable, (ii) Support Vector Machine or SVM [24] (and its variant Support Vector Regression)
where the space of input values is divided into clusters by high-dimensional hyperplanes, and (iii)
Multivariate Linear Regression [25], which is a multidimensional generalization of the common best-fit line
method.
Choice of Input Features: In order to use ML methods, one must also identify the data to use as inputs.
These are called “features”. Using the entire absorbance vs. wavelength from the spectrophotometer would
be too much data to process simply, so I decided to sample the absorbance vs. wavelength function at five
uniformly spaced wavelength values (300nm, 400nm, 500nm, 600nm, and 700nm) that cover the entire
visible spectrum. In other words, the input feature is a five-dimensional vector
[𝐴!""!", 𝐴!""!", 𝐴!""!", 𝐴!""!", 𝐴!""!"]. While a feature vector with more sample points might be
better, I decided to start with a manageable number to keep the ML complexity low. Fortuitously, as the
results later show, the choice of five turned out to be adequate. However, for ML algorithms to work well, it
is generally considered good to scale the features so that they all lie in the same range of values typically
chosen to be [0,1]. So I scaled the raw absorption measurements using the formula 𝐴!"#$%& = (𝐴!"#$%&"' −
𝐴!"#)/(𝐴!"# − 𝐴!"#) and selected 𝐴!"# = 0.2 and 𝐴!"# = −0.2  as convenient and conservative values
that worked for the absorbance measurements I observed. Scaling also has the advantage that negative
absorbance values that can arise from optical shifts can be used as well.
Transforming Input Features: However, intuitively, even the scaled absorption values have the
disadvantage that the model is dependent on not just the shape of the spectrum but also the absolute values.
In other words, this choice of features incorporates both the color and intensity. Since the latter can be
affected by factors such as clarity and concentration, it would be desirable to transform the input features
such that they capture information about the shape of the spectrum but not its magnitude. I decided to explore
two heuristics for this. The first involves normalizing the elements of the feature vector such that the largest
one has a value of 1. In other words, all the values of a feature vector are divided by its highest one.
  7	
  
Intuitively, the feature vector now represents absorbance as ratios relative to the peak, and thus captures the
shape of the spectrum. The second heuristic is based on the observation that color corresponds to the
“direction” of the feature vector. From linear algebra, the direction information of a feature vector can be
captured by the elements of a unit vector parallel to the feature vector. To accomplish this, one can simply
scale the elements of the feature vector by the magnitude of the feature vector to obtain a feature vector of
unit magnitude. Furthermore, only four of the elements of the unit feature vector need to be used for model
learning since the fifth one can be determined from the other four. I refer to the first heuristic as the
normalize_maximum approach and the second one as the normalized_magnitude approach.
As the preceding discussion shows, there is a rich space of ML based methods for me to explore: (i) Three
possible model learning objectives: classification into two-categories, classification into three-categories, and
regression-based estimation of pH value, (ii) Three candidate learning methods: decision tree for
classification and regression, SVM for classification and regression, and multivariate linear regression, and
(iii) Three candidate choices of feature vectors: scaled, scaled with normalized_maximum, and scaled with
normalized_magnitude.
I collected a training data set on one day and a test data set on a different day. In each case, I collected
spectrophotometer measurements for a variety of test solutions at different pH values, and also captured the
actual pH value using a high quality pH meter. The training data set including the actual values was then
used to learn ML models for the various cases identified in the preceding paragraph. Next, I evaluated the
models thus created on the test data set, and compared the predictions of the pH value made by the models
against the real pH value as measured by the pH meter. Finally, I used the various error metrics obtained
from the comparisons to identify the best model for each of the three learning objectives.
III. Results and Discussion
III.A. The Single Indicator Method with Conventional Analysis
Using the method described in Section II.B with Bromocresol Green (𝑝𝐾! = 4.7) and Bromocresol Purple
(𝑝𝐾! = 6.3) as indicators, I collected and analyzed data according to the steps below. The absorbance and
wavelengths were measured using a USB-pluggable miniature fiber-optic spectrometer [26] using sample
volumes similar to that available in the microfluidics instrument.
Step 1: Find peak absorbance and wavelength for indicator acid and base forms. Initially, the
spectrometer gave an absorption spectra graph for each of the four indicator forms in Table 1. I determined at
what wavelength value was the graph’s maximum absorption value, and measured the absorption at that
  8	
  
value. Although the two indicators are different, in very acidic and very basic forms their colors are similar,
which explains their similar peak wavelengths.
Indicator Form Peak Absorption Corresponding Wavelength (nm)
Bromocresol Green Acid 0.075971 481.372
Bromocresol Green Base 0.059826 526.482
Bromocresol Purple Acid 0.043468 481.168
Bromocresol Purple Base 0.097371 526.281
Table	
  1:	
  Measurements	
  for	
  Step	
  1	
  
Step 2: Find acid form’s absorbance at base form’s peak wavelength, and vice versa. Once I determined
what wavelength had the peak absorbance value for the acid form, I measured the absorbance at the same
value for the base form. I then measured the absorbance value of the base form at the peak wavelength of the
acid form. I did this for both indicators, and as expected, the absorbance values were much lower than the
values at their respective peak wavelengths, as shown in Table 2.
Indicator Form
Step 2 Step 3
Wavelength
(nm)
Absorption
Molar Absorption
at Acid Form’s
Peak Wavelength
Molar Absorption at
Base Form’s Peak
Wavelength
Bromocresol
Green
Acid 526.482 0.018188 71606 at 481.372 nm 1714 at 526.482 nm
Bromocresol
Green
Base 481.372 0.020062 1891 at 481.372 nm 563887 at 526.482 nm
Bromocresol
Purple
Acid 526.281 0.004431 7010 at 481.168 nm 715 at 526.281 nm
Bromocresol
Purple
Base 481.168 0.033857 5460 at 481.168 nm 15703 at 526.281 nm
Table	
  2:	
  Measurements	
  for	
  Step	
  2	
  and	
  Step	
  3	
  
Step 3: Determine molar absorptivity of acid & base forms at the two peak wavelengths. Using Beer’s
Law and the known values of indicator concentration and microfluidic capillary path length, I used the
  9	
  
absorption values to calculate the molar absorptivity for each indicator form at each wavelength, as shown in
Table 2.
Step 4: Measure absorbance of unknown solution with indicator at the two peak wavelengths.
Performing five trials of a solution of the same unknown pH, I determined the absorption values of the
solutions mixed with indicator at the acid and base forms’ peak wavelengths, and averaged them. The
solution I used was 9 g NaCl / 1 L water, which is the standard saline solution used in PET probes. Data
obtained is shown in Table 3.
Indicator
Absorption at Acid
Form’s Peak Wavelength
Absorption at Base
Form’s Peak Wavelength
Bromocresol Green 0.03491 at 526.482 nm 0.077568 at 481.372 nm
Bromocresol Purple 0.015039 at 526.281 nm 0.042001 at 481.168 nm
Table	
  3:	
  Measurements	
  for	
  Step	
  4	
  
Step 5: Using data to solve aforementioned system of equations, determine pH. Finally, using the system
of equations as described in Section II.B, I calculated the pH value of the unknown solution. I also measured
the pH value using a pH meter, assumed that value to be accurate, and calculated the % error of the values
determined via the indicator method. As Table 4 shows, Bromocresol Purple was much more accurate than
Bromocresol Green. This might be because the effective range of Bromocresol Green indicator ends at
around pH = 5.5, which was close to the actual value of the unknown solution’s pH.
pH Measurement Method pH Value Error
pH Meter 5.45 None (Ground Truth)
Bromocresol Green 3.433 -37%
Bromocresol Purple 5.416 -0.62%
Table	
  4:	
  Analysis	
  results	
  from	
  Step	
  5	
  
Step 6: Collect Data of Change in pH vs. Indicator Concentration for Bromocresol Purple. When trying
to figure out additional reasons behind the huge % error for Bromocresol Green, I realized that adding too
much indicator also affects the pH of a solution. Since the point of the project is to determine the pH of the
solution, this is clearly something that should be avoided. However, the concentration of indicator also needs
to be high enough for the spectrometer to detect the color. Since we were using microfluidic capillaries, the
  10	
  
indicator concentration needs to be much higher than with other spectrometers in order for accurate detection
to occur. Thus, I collected data reported in Table 5 regarding the effect of Indicator Concentration on the
Change in pH of a saline solution for Bromocresol Purple, which according to Table 4 caused less error. As
the concentration of indicator increases, the change in pH does too. It is interesting to note that the trend line
(see Figure 3) suggests that the origin is not a point on the line, although adding no indicator should mean no
change. This might mean that at concentrations lower than .0001 M, the trend is not linear.
Indicator Concentration Change in pH of Solution
.00004252 .27
.00008117 .3
.00066142 .86
.00023150 .42
.00014882 .34
Table	
  5:	
  Measurements	
  for	
  Step	
  6.	
  
Figure	
  3:	
  Trend	
  line	
  for	
  data	
  from	
  Step	
  6	
  for	
  Bromocresol	
  Purple	
  
Step 7: Determining % Error of pH Determination Using Spectrometry vs. Indicator Concentration.
Given that at lower concentrations of indicator, it is harder for the spectrometer to detect the absorbance, I
wanted to find the value at which the % Error of using the indicator method would be a minimum. I created
more solutions mixed with Bromocresol Purple, measured their actual pH, and then used the Single Indicator
Method and determined the error the resulting pH had compared to the actual value. The resulting data is
y"="968.22x"+"0.2123"
R²"="0.99597"
0"
0.1"
0.2"
0.3"
0.4"
0.5"
0.6"
0.7"
0.8"
0.9"
1"
0" 0.0001" 0.0002" 0.0003" 0.0004" 0.0005" 0.0006" 0.0007"
change'in'pH'
concentra.on'(M)'
change'in'pH'vs.'concentra.on'
concentration (M)
0 0.0001 0.0002 0.0003 0.0004 0.0005 0.0006 0.0007
changeinpH
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
y = 968.22x + 0.2123
R2
= 0.99597
  11	
  
shown in Table 6, and it is clear from the regression curve in Figure 4 that at around .0008 M the % error
approaches 0, while results from Step 6 show that at concentrations as low as .0001 M adding indicator
changes the pH. Since an optimum value for indicator concentration was not found, and moreover, the range
that Method 1 can work for is small due to the nature of a single indicator, a new method was devised using
the Universal Indicator. This method, described in the next subsection, ended up being more successful, and
effective for a much bigger range of pH values.
Indicator Concentration % Error of Spectrometer Analysis
0.000826778 -0.624980954
0.000661423 3.467153285
0.000312522 11.91058394
0.000178584 19.90875912
Table	
  6:	
  Measurements	
  for	
  Step	
  7.	
  
Figure	
  4:	
  Best	
  fit	
  curve	
  for	
  Step	
  6	
  measurements.	
  
III.B. The Universal Indicator Method with Machine Learning Based Analysis
Following the method described earlier in Section II.C with a Universal Indicator from Sigma-Aldrich [27]
for pH range 4-10, I performed the following data collection, model learning, and analysis steps.
Step 1: Collect Training and Test Data
!5#
0#
5#
10#
15#
20#
25#
0# 0.0001# 0.0002# 0.0003# 0.0004# 0.0005# 0.0006# 0.0007# 0.0008# 0.0009#
%"error"using"spectroscopy"
indicator"concentra1on"(M)"
%"error"vs."indicator"concentra1on"
indicator concentration (M)
%errorusingspectroscopy
25
20
15
10
5
0
-5
0 0.0001 0.0002 0.0003 0.00050.0004 0.0006 0.0007 0.0008 0.0009
R2
= 0.99565
  12	
  
In order to learn a statistical model using machine learning methods for later assessment of the pH of PET
probes, I made absorbance vs. wavelength measurements for several sample solutions with known “ground
truth” pH (as measured by a pH meter) spanning a wide range of pH values. Specifically, 34 measurements
were made across 19 different pH values in the range 3.1 to 11.3 (several of the samples were measured
twice). The absorbances at the various wavelengths were measured using a NanoDrop UV-Vis microvolume
spectrophotometer [28]. Additionally, on a different day, I collected measurements from 9 other samples,
also with known pH (as measured by a pH meter), with this second set being meant as the testing set to
determine how well the model learnt over the training set does on new data. As described in Section II.C, for
each case the absorbance was measured at five wavelengths (λ   =  300 nm, 400 nm, 500 nm, 600 nm, and 700
nm), and these values then scaled using the formula 𝐴!"#$%& = 2.5 ∗ 𝐴!"#$%&"' + 0.5. Table 7 presents the
measured and scaled absorbance value 𝐴! and 𝑆! and the ground truth pH, for a subset of training and testing
data.
Step 2: Compute Feature Vectors with Heuristic Transformations
The 5-dimensional vector of scaled absorbance values were then transformed using the two heuristics
introduced in Section II.C, normalized_maximum and normalized_magnitude. The elements of the
transformed feature vectors are 𝑅! and 𝑈! in Table 8. As noted in Section II.C, for normalize_magnitude
case, values at only 4 out of 5 wavelengths are independent, and so I use the first four entries of 𝑈! features.
Step 3: Learn and Evaluate the Various ML Models
For learning the models and using them for classification and regression, I used two different tools: the
BigML [29] cloud-based service for decision tree modeling for classification and regression, and the popular
R software environment [29] for statistical computing together with e1071 [31], and caret [32] packages for
support vector machine and multivariate linear models. I wrote a custom analysis program in the “R”
language to train the models, run them on test data to make predictions, and compute various error statistics
to evaluate the performance. The program also incorporates decision tree models learnt in BigML using the
latter’s capability to export executable R code.
For the two classification tasks I computed the following performance metrics for the predictions made by
each of two types of classifiers with each of the three types of feature vectors: accuracy, average precision,
average recall, average F measure, and average Phi Coefficient [33, 34]. As Table 9 shows, the best
performing classifier in both the classification tasks was a decision tree classifier using scaled absorbance
vectors with normalized magnitude. The corresponding cells in the table are highlighted with yellow
background. In fact, for both the tasks decision tree classifiers yielded 100% accuracy, 100% average
  13	
  
precision, and 100% average recall, and value of 1 for both average F measure, and average Phi Coefficient.
This is theoretically the best possible performance.
Table	
  7:	
  Absorbance	
  data	
  collected	
  in	
  Step	
  1	
  for	
  training	
  and	
  testing,	
  and	
  its	
  scaled	
  version	
  
For the regression task of estimating pH, we had three choices of three types of regression models, and I
computed the following performance metrics: mean absolute error, mean squared error, maximum absolute
error, and coefficient of determination R2
[35] (as computed by R2 function in the caret package [32] with
  14	
  
“corr” formula”). As Table 10 shows via the cells highlighted in yellow, for pH estimation as well the
decision tree approach (regression tree) was the best, giving excellent mean absolute error of 0.29 and
maximum absolute error of 1, which is acceptable for PET probe application.
Table	
  8:	
  Absorbance	
  with	
  normalized	
  maximum	
  value	
  and	
  with	
  normalized	
  
magnitude	
  computed	
  in	
  Step	
  3	
  
  15	
  
Table	
  9:	
  Performance	
  of	
  various	
  classifiers	
  and	
  feature	
  vector	
  choice	
  on	
  
the	
  two	
  classification	
  version	
  of	
  the	
  pH	
  sensing	
  task	
  
Table	
  10:	
  	
  Performance	
  of	
  various	
  regression	
  models	
  and	
  feature	
  vector	
  choice	
  on	
  the	
  pH	
  value	
  
estimation.	
  
  16	
  
IV. Conclusions and Future Work
My research demonstrates the significant advantage of using machine learning (ML) to create models for
sensors. My work showed two methods of building an optical pH platform that can be used with
microfluidics. However, the first method (Single Indicator Method) had severe limitations. I could not find
an indicator concentration that was high enough for spectrometric detection, but low enough to not alter the
pH of the sample. More importantly, even if an optimum indicator concentration were determined, that
method would have only worked for a small range of pH values due to Bromocresol Purple’s color change
range of 5.2 → 6.8, which is insufficient for the intended application of my sensor in testing PET probes.
The second method involving a Universal Indicator and an ML approach was both novel and much more
effective than the previous method. This method works for a large pH range, and is especially accurate when
classifying whether a solution is safe or unsafe for human injection. Moreover, this method did not rely on
any physics model, while the first method relied on Beer’s Law. The beauty of machine learning is that
through a statistical approach a model was created for my data, without any knowledge of chemical or
physical laws. I also generated software code in R statistical programming language embodying the models
that I trained using ML tools. Eventually, this code can be embedded in the control processor of the
microfluidic instrument containing the pH sensor.
Due to time constraints, I was only able to collect a limited amount of data. Although the results of my
second method are fairly accurate, they could definitely be improved if more data was collected, since a
better model would be created. Additionally, although I created a successful method for developing a sensor,
I never had the chance to implement it into the actual instrument that will be sent to hospitals for use.
Building the actual sensor might raise some issues with this method: for example, other features of the
instrument might disrupt the pH sensing functionality. Since my method is based on analyzing color and light
properties, changes in lighting conditions could affect my method as well. If given more time, I would collect
a lot more data samples, and for each sample also collect absorbance at more than just 5 wavelengths. There
is no fundamental limit to the number of features one can use for ML, and feature vectors with absorbance
values at a large number of wavelengths will capture the shape of the absorbance vs. wavelength function
with higher fidelity. However, this would also increase the computational time for model training.
Finally, ML is becoming more and more useful in many different fields for creating models based on data.
While there is much literature out there about ML and its applications, my method is novel in applying an
ML approach to devise a pH sensor. There is no reason why my method of analyzing results is limited to pH
sensing: it is possible that more robust sensors for detecting properties such as pollution or temperature can
be built by using ML to train a model unique to the properties of the data being measured without requiring a
  17	
  
closed form physics model of the phenomenon. The applications of ML are great in number and varied, and
my research shows that an ML approach is quite beneficial in building a high quality optical-based pH sensor.
V. Appendix: Software Implementation
As mentioned earlier, I used the BigML [29] cloud-based service for learning the decision tree model for
classification and regression, and used the popular R software environment [29] for statistical computing
together with e1071 [31], and caret [32] packages for learning the support vector machine and multivariate
linear models. My results had indicated that decision tree based models worked the best for each of three
versions of the problem: the two-category classification task; the three-category classification task, and the
regression task where the actual numerical value of pH is estimated. In each case the decision tree takes as
input features a vector of the absorbance values at the five wavelengths after they have been scaled and then
the entire vector normalized to have unit magnitude (which corresponds to another multiplicative scaling by
the inverse of the magnitude). I implemented the three decision threes as functions in the Python
programming language, as shown in the code listing below. This complexity of this code is low, and thus it
can run on an embedded computer (e.g. Raspberry PI) with Python interpreter under Linux OS. This
computer can be attached to the spectrophotometer hooked up to the microfluidics-based instrument for PET
probe preparation, and process in real-time the absorbance measurements to check whether the pH is safe.
# y1, y2, y3, y4, and y5 are the scaled and normalized absorbance values
# at wavelengths of 300 nm, 400 nm, 500 nm, 600 nm, and 700 nm respectively
#
def predict_cat2(y1=None, y2=None, y3=None, y4=None, y5=None):
""" Predictor from BigML model/523539b9035d0772e6004372
Returns 'N' is the pH is not okay, and returns 'Y' if it is
"""
if (y4 is None): return u'N'
if (y4 > 0.2265):
if (y3 is None): return u'N'
if (y3 <= 0.40872): return u'Y'
if (y3 > 0.40872): return u'N'
if (y4 <= 0.2265):
if (y2 is None): return u'Y'
if (y2 <= 0.52273):
if (y5 is None): return u'N'
if (y5 > 0.06984): return u'Y'
if (y5 <= 0.06984): return u'N'
if (y2 > 0.52273): return u'Y'
def predict_cat3(y1=None, y2=None, y3=None, y4=None, y5=None):
""" Predictor from BigML model/52353d69035d0772e500425c
Returns 'OK', 'LO', or 'HI' depending on whether pH
is okay, too low, or too hight
"""
if (y4 is None): return u'HI'
if (y4 > 0.2265):
if (y3 is None): return u'HI'
if (y3 <= 0.40872): return u'OK'
if (y3 > 0.40872): return u'HI'
if (y4 <= 0.2265):
if (y2 is None): return u'OK'
if (y2 <= 0.52273):
if (y5 is None): return u'LO'
  18	
  
if (y5 > 0.06984): return u'OK'
if (y5 <= 0.06984): return u'LO'
if (y2 > 0.52273): return u'OK'
def predict_ph(y1=None, y2=None, y3=None, y4=None, y5=None):
""" Predictor for pH from BigML model/52354117035d0772e70057a0
Returns estimated pH value
"""
if (y4 is None): return 7.82471
if (y4 > 0.2265):
if (y3 is None): return 9.67158
if (y3 <= 0.59149):
if (y5 is None): return 8.80545
if (y5 > 0.10748):
if (y5 <= 0.18737): return 8.11
if (y5 > 0.18737): return 6.84
if (y5 <= 0.10748):
if (y3 <= 0.51374):
if (y4 > 0.29383):
if (y5 <= 0.08854):
if (y5 > 0.05973): return 9.1
if (y5 <= 0.05973): return 9.08
if (y5 > 0.08854): return 8.92
if (y4 <= 0.29383):
if (y5 <= 0.04749): return 8.92
if (y5 > 0.04749): return 8.11
if (y3 > 0.51374):
if (y3 > 0.54783):
if (y5 <= 0.0471): return 9.75
if (y5 > 0.0471): return 9.58
if (y3 <= 0.54783): return 9.35
if (y3 > 0.59149):
if (y2 is None): return 10.8625
if (y2 > 0.63997):
if (y3 <= 0.67721):
if (y2 > 0.66202): return 10.16
if (y2 <= 0.66202): return 10.7
if (y3 > 0.67721): return 11.28
if (y2 <= 0.63997):
if (y1 is None): return 11.15
if (y1 <= 0.74167):
if (y5 is None): return 11.3
if (y5 > 0.07083): return 11.28
if (y5 <= 0.07083): return 11.31
if (y1 > 0.74167): return 10.7
if (y4 <= 0.2265):
if (y3 is None): return 5.48533
if (y3 <= 0.69987):
if (y3 > 0.44591): return 6.09
if (y3 <= 0.44591):
if (y5 is None): return 7.115
if (y5 <= 0.08164):
if (y4 > 0.1734):
if (y4 <= 0.19837): return 6.84
if (y4 > 0.19837): return 7.09
if (y4 <= 0.1734): return 7.79
if (y5 > 0.08164): return 6.09
if (y3 > 0.69987):
if (y4 > 0.19742): return 5.39
if (y4 <= 0.19742):
if (y2 is None): return 3.78667
if (y2 <= 0.37496): return 3.17
if (y2 > 0.37496):
if (y4 > 0.15476): return 4.32
if (y4 <= 0.15476): return 3.87
Below is an outline of the code in the R statistical programming language that I wrote to evaluate the
performance of various machine learning models. For the case of support vector machine and multivariate
  19	
  
regression, I use the implementations provided by the e1071 package in R, whereas for the decision tree I
used an implementation in R of the decisions trees exported from BigML. This code takes as input a file in
the .csv format, with columns labeled AN300nm, AN400nm … AN700nm giving the scaled absorbance
vector normalized to be unit magnitude, and columns labeled RN300nm, RN400nm … RN700nm giving the
scaled absorbance vector normalized so that the highest entry in each vector is 1. Furthermore, the .csv file
has columns labeled pH, CAT2, and CAT3 giving the ground truth for the three cases that I explored (the
value of pH, whether the pH is okay or not, and whether the pH is okay or too hight or too low).
	
  
library(e1071)
library(caret)
phdata <- read.csv("phdata.csv")
n = dim(phdata)[1]
n_train = 34
n_test = n-n_train
phdata_train = phdata[1:n_train,]
phdata_test = phdata[(n_train+1):n,]
ph_test_actual = phdata[(n_train+1):n,"pH"]
cat2_test_actual = phdata[(n_train+1):n,"CAT2"]
cat3_test_actual = phdata[(n_train+1):n,"CAT3"]
print_error_stats <- function(label,predicted,actual) {
# this function prints various error statistics which I used to populate Table 9 and 10
# Due to space limitation the detailed code has been removed
…
}
# Regression: Prediction of value of pH
model_svm_ph_AN <- svm(pH~AN300nm+AN400nm+AN500nm+AN600nm,type="eps-regression",
kernel="polynomial",degree=3,data=phdata_train)
model_svm_ph_RN <- svm(pH~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,type="eps-regression",
kernel="polynomial",degree=3,data=phdata_train)
model_lm_ph_AN <- lm(pH~AN300nm+AN400nm+AN500nm+AN600nm,data=phdata_train)
model_lm_ph_RN <- lm(pH~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,data=phdata_train)
ph_test_predicted_svm_AN <- predict(model_svm_ph_AN,phdata_test)
ph_test_predicted_svm_RN <- predict(model_svm_ph_RN,phdata_test)
ph_test_predicted_lm_AN <- predict(model_lm_ph_AN,phdata_test)
ph_test_predicted_lm_RN <- predict(model_lm_ph_RN,phdata_test)
print_error_stats("ph svm_AN",ph_test_predicted_svm_AN,ph_test_actual)
print_error_stats("ph svm_RN",ph_test_predicted_svm_RN,ph_test_actual)
print_error_stats("ph lm_AN",ph_test_predicted_lm_AN,ph_test_actual)
print_error_stats("ph lm_RN",ph_test_predicted_lm_RN,ph_test_actual)
# Two-category classification: Prediction of whether pH is ok or not
model_svm_cat2_AN <- svm(CAT2~AN300nm+AN400nm+AN500nm+AN600nm,data=phdata_train)
model_svm_cat2_RN <- svm(CAT2~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,data=phdata_train)
cat2_test_predicted_svm_AN <- predict(model_svm_cat2_AN,phdata_test)
cat2_test_predicted_svm_RN <- predict(model_svm_cat2_RN,phdata_test)
cat2_cm_svm_AN = as.matrix(confusionMatrix(cat2_test_predicted_svm_AN,cat2_test_actual))
cat2_cm_svm_RN = as.matrix(confusionMatrix(cat2_test_predicted_svm_RN,cat2_test_actual))
print_error_stats("cat2 svm_AN",cat2_test_predicted_svm_AN,cat2_test_actual)
print_error_stats("cat2 svm_RN",cat2_test_predicted_svm_RN,cat2_test_actual)
# Three-category classification: Prediction of whether pH is ok or not
model_svm_cat3_AN <- svm(CAT3~AN300nm+AN400nm+AN500nm+AN600nm,data=phdata_train)
model_svm_cat3_RN <- svm(CAT3~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,data=phdata_train)
cat3_test_predicted_svm_AN <- predict(model_svm_cat3_AN,phdata_test)
cat3_test_predicted_svm_RN <- predict(model_svm_cat3_RN,phdata_test)
cat3_cm_svm_AN = as.matrix(confusionMatrix(cat3_test_predicted_svm_AN,cat3_test_actual))
cat3_cm_svm_RN = as.matrix(confusionMatrix(cat3_test_predicted_svm_RN,cat3_test_actual))
  20	
  
print_error_stats("cat3 svm_AN",cat3_test_predicted_svm_AN,cat3_test_actual)
print_error_stats("cat3 svm_RN",cat3_test_predicted_svm_RN,cat3_test_actual)
# Evaluation of decision tree models from BigML (the .R file exported from BigML)
sourcescript_bigml_pH.R")
source("script_bigml_cat2.R")
source("script_bigml_cat3.R")
sum_errabs = 0
sum_errsq = 0
max_errabs = 0
ph_test_predicted_rt_AN = rep(NA,n_test)
ph_test_predicted_rt_RN = rep(NA,n_test)
for (i in 1:n_test) {
ph_test_predicted_rt_AN[i] = predict_ph_AN(phdata_test[i,]$AN300nm,phdata_test[i,]$AN400nm,
phdata_test[i,]$AN500nm,phdata_test[i,]$AN600nm)
ph_test_predicted_rt_RN[i] = predict_ph_RN(phdata_test[i,]$RN300nm,phdata_test[i,]$RN400nm,
phdata_test[i,]$RN500nm,phdata_test[i,]$RN600nm,phdata_test[i,]$RN700nm)
}
print_error_stats("ph rt_AN",ph_test_predicted_rt_AN,ph_test_actual)
print_error_stats("ph rt_RN",ph_test_predicted_rt_RN,ph_test_actual)
cat2_test_predicted_rt_AN = rep(NA,n_test)
cat2_test_predicted_rt_RN = rep(NA,n_test)
for (i in 1:n_test) {
cat2_test_predicted_rt_AN[i] = predict_cat2_AN(phdata_test[i,]$AN300nm,phdata_test[i,]$AN400nm,
phdata_test[i,]$AN500nm,phdata_test[i,]$AN600nm)
cat2_test_predicted_rt_RN[i] = predict_cat2_RN(phdata_test[i,]$RN300nm,phdata_test[i,]$RN400nm,
phdata_test[i,]$RN500nm,phdata_test[i,]$RN600nm,phdata_test[i,]$RN700nm)
}
cat2_test_predicted_rt_AN = factor(cat2_test_predicted_rt_AN,c("N","Y"))
cat2_test_predicted_rt_RN = factor(cat2_test_predicted_rt_RN,c("N","Y"))
print(paste("cat2 [actual]",paste(cat2_test_actual,collapse=" ")))
print_error_stats("cat2 AN",cat2_test_predicted_rt_AN,cat2_test_actual)
print_error_stats("cat2 RN",cat2_test_predicted_rt_RN,cat2_test_actual)
cat3_test_predicted_rt_AN = rep(NA,n_test)
cat3_test_predicted_rt_RN = rep(NA,n_test)
for (i in 1:n_test) {
cat3_test_predicted_rt_AN[i] = predict_cat3_AN(phdata_test[i,]$AN300nm,phdata_test[i,]$AN400nm,
phdata_test[i,]$AN500nm,phdata_test[i,]$AN600nm)
cat3_test_predicted_rt_RN[i] = predict_cat3_RN(phdata_test[i,]$RN300nm,phdata_test[i,]$RN400nm,
phdata_test[i,]$RN500nm,phdata_test[i,]$RN600nm,phdata_test[i,]$RN700nm)
}
cat3_test_predicted_rt_AN = factor(cat3_test_predicted_rt_AN,c("HI","LO","OK"))
cat3_test_predicted_rt_RN = factor(cat3_test_predicted_rt_RN,c("HI","LO","OK"))
print(paste("cat3 [actual]",paste(cat3_test_actual,collapse=" ")))
print_error_stats("cat3 AN",cat3_test_predicted_rt_AN,cat3_test_actual)
print_error_stats("cat3 RN",cat3_test_predicted_rt_RN,cat3_test_actual)
  1	
  
References
1. Ollinger, John M., and Jeffrey A. Fessler. "Positron-emission tomography." Signal Processing
Magazine, IEEE 14, no. 1 (1997): 43-55.
2. Keng, Pei Yuin, Supin Chen, Huijiang Ding, Saman Sadeghi, Gaurav J. Shah, Alex Dooraghi,
Michael E. Phelps, Nagichettiar Satyamurthy, Arion F. Chatziioannou, and R. Michael van Dam.
"Micro-chemical synthesis of molecular probes on an electronic microfluidic device." Proceedings
of the National Academy of Sciences 109, no. 3 (2012): 690-695.
3. Choi, Kihwan, Alphonsus HC Ng, Ryan Fobel, and Aaron R. Wheeler. "Digital microfluidics."
Annual Review of Analytical Chemistry 5 (2012): 413-440.
4. Whitesides, George M. "The origins and the future of microfluidics." Nature 442, no. 7101 (2006):
368-373.
5. American Chemical Society National Historic Chemical Landmarks, “Development of the Beckman
pH Meter”.
http://portal.acs.org/portal/PublicWebSite/education/whatischemistry/landmarks/beckman/index.htm
(accessed September 25, 2013).
6. Wikipedia, “Litmus”.
http://en.wikipedia.org/wiki/Litmus
(accessed September 25, 2013).
7. Ocean Optics, Inc., “In Situ Transmissive pH Sensors”.
http://www.oceanopticssensors.com/products/phsensor.htm
(accessed September 25, 2013).
8. Ocean Optics, Inc., “Non-Intrusive Reflective pH Sensors”.
http://www.oceanopticssensors.com/products/phbcg.htm
(accessed September 25, 2013).
9. Hammond, Paul A., Danish Ali, and David RS Cumming. "A system-on-chip digital pH meter for
use in a wireless diagnostic capsule." Biomedical Engineering, IEEE Transactions on 52, no. 4
(2005): 687-694.
  2	
  
10. Kuswandi, Bambang, Jurriaan Huskens, and Willem Verboom. "Optical sensing systems for
microfluidic devices: a review." Analytica chimica acta 601, no. 2 (2007): 141-155.
11. Romaniuk, R. "Capillary optical fiber–design, fabrication, characterization and application." Bulletin
of the Polish Academy of Sciences 56, no. 2 (2008).
12. Borecki, Michał, Michael L. Korwin-Pawlowski, Maria Beblowska, Jan Szmidt, and Andrzej
Jakubowski. "Optoelectronic capillary sensors in microfluidic and point-of-care instrumentation."
Sensors 10, no. 4 (2010): 3771-3797.
13. Skoog, Douglas A., Donald M. West, James F. Holler, and Stanley R. Crouch. "Fundamentals of
Analytical Chemistry,." Cengage Learning (2013): 1072.
14. Mr. Kent’s Chemistry Page, “Acid Based Indicators,”
http://www.kentchemistry.com/links/AcidsBases/Indicators.htm
(accessed September 25, 2013).
15. Wikipedia, “Acid disassociation constant.”
http://en.wikipedia.org/wiki/Acid_dissociation_constant
(accessed September 25, 2013).
16. Wikipedia, “Henderson–Hasselbalch equation.”
http://en.wikipedia.org/wiki/Henderson-Hasselbalch_equation
(accessed September 25, 2013).
17. Wikipedia, “Beer–Lambert law.”
http://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law
(accessed September 25, 2013).
18. Wikipedia, “Universal indicator.”
http://en.wikipedia.org/wiki/Universal_indicator
(accessed September 25, 2013).
19. Wikipedia, “Color vision.”
http://en.wikipedia.org/wiki/Color_vision
(accessed September 25, 2013).
20. Wyszecki, Günter, and Walter Stanley Stiles. Color science. New York: Wiley, 1982.
  3	
  
21. Bishop, Christopher M., and Nasser M. Nasrabadi. Pattern recognition and machine learning. Vol. 1.
New York: springer, 2006.
22. Wikipedia, “Machine learning.”
http://en.wikipedia.org/wiki/Machine_learning
(accessed September 25, 2013).
23. Rokach, Lior. Data mining with decision trees: theory and applications. Vol. 69. World Scientific,
2007.
24. Steinwart, Ingo, and Andreas Christmann. Support vector machines. Springer, 2008.
25. Aiken, Leona S., Stephen G. West, and Steven C. Pitts. "Multiple linear regression." Handbook of
psychology (2003).
26. Ocean Optics, “USB4000 Miniature Fiber Optic Spectrometer.”
http://www.oceanoptics.com/products/usb4000.asp
(accessed September 25, 2013).
27. Sigma-Akdrich, “36828 FLUKA Universal indicator solution with color chart and directions for use,
pH 4-10.”
http://www.sigmaaldrich.com/catalog/product/fluka/36828?lang=en&region=US
(accessed September 25, 2013).
28. Thermo Scientific, “NanoDrop 2000 UV-Vis Spectrometer.”
http://www.nanodrop.com/Productnd2000overview.aspx
(accessed September 25, 2013).
29. BigML Inc.
https://bigml.com
(accessed September 25, 2013).
30. Crawley, Michael J. The R book. John Wiley & Sons, 2012.
31. Dimitriadou, Evgenia, Kurt Hornik, Friedrich Leisch, David Meyer, Andreas Weingessel, and
Maintainer Friedrich Leisch. "Package ‘e1071’." R Software package, avaliable at http://cran.
rproject. org/web/packages/e1071/index. html (2009).
  4	
  
32. Kuhn, Max. "Building predictive models in R using the caret package." Journal of Statistical
Software 28, no. 5 (2008): 1-26.
33. Jos Verwoerd, BigML Inc., “Predicting with My Model: Is It Safe?.”
http://blog.bigml.com/2012/12/03/predicting-with-my-model-is-it-safe/
(accessed September 25, 2013).
34. Parker, Charles. "An analysis of performance measures for binary classifiers." In Data Mining
(ICDM), 2011 IEEE 11th International Conference on, pp. 517-526. IEEE, 2011.
35. Kvålseth, Tarald O. "Cautionary note about R 2." The American Statistician 39, no. 4 (1985): 279-
285.

More Related Content

Similar to Report-v1b

Novel pH sensor based on fiber optic coated bromophenol blue and cresol red
Novel pH sensor based on fiber optic coated bromophenol blue and cresol redNovel pH sensor based on fiber optic coated bromophenol blue and cresol red
Novel pH sensor based on fiber optic coated bromophenol blue and cresol redTELKOMNIKA JOURNAL
 
ADVANCED BIOANALYTICAL TECHNIQUES.pptx
ADVANCED BIOANALYTICAL TECHNIQUES.pptxADVANCED BIOANALYTICAL TECHNIQUES.pptx
ADVANCED BIOANALYTICAL TECHNIQUES.pptxPratikKapse8
 
biosensor and its utilization in environment
biosensor and its utilization in environmentbiosensor and its utilization in environment
biosensor and its utilization in environmenthome
 
A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...
A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...
A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...TELKOMNIKA JOURNAL
 
Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...
Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...
Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...CrimsonPublishers-SBB
 
Mesuring ph with FOS (Fibre Optic Sensors)
Mesuring ph with FOS (Fibre Optic Sensors)Mesuring ph with FOS (Fibre Optic Sensors)
Mesuring ph with FOS (Fibre Optic Sensors)Subhrajit Sadhukhan
 
Ruchika zalpouri, ae 163-d
Ruchika zalpouri, ae 163-dRuchika zalpouri, ae 163-d
Ruchika zalpouri, ae 163-dRuchikaZalpouri
 
Biosensors: General Principles and Applications
Biosensors: General Principles and ApplicationsBiosensors: General Principles and Applications
Biosensors: General Principles and ApplicationsBhatt Eshfaq
 
E+H - Making accurate PH measurements
E+H - Making accurate PH measurementsE+H - Making accurate PH measurements
E+H - Making accurate PH measurementsCarotek
 
PHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptx
PHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptxPHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptx
PHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptxBhamareKunal
 
Micro Electronic Pill Seminar Report
Micro Electronic Pill Seminar ReportMicro Electronic Pill Seminar Report
Micro Electronic Pill Seminar ReportSajan CK
 
207 progress with the calibration of a 3 fr near infrared catheter
207 progress with the calibration of a 3 fr near infrared catheter207 progress with the calibration of a 3 fr near infrared catheter
207 progress with the calibration of a 3 fr near infrared catheterSHAPE Society
 
Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...
Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...
Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...Healthcare and Medical Sciences
 

Similar to Report-v1b (20)

Novel pH sensor based on fiber optic coated bromophenol blue and cresol red
Novel pH sensor based on fiber optic coated bromophenol blue and cresol redNovel pH sensor based on fiber optic coated bromophenol blue and cresol red
Novel pH sensor based on fiber optic coated bromophenol blue and cresol red
 
ADVANCED BIOANALYTICAL TECHNIQUES.pptx
ADVANCED BIOANALYTICAL TECHNIQUES.pptxADVANCED BIOANALYTICAL TECHNIQUES.pptx
ADVANCED BIOANALYTICAL TECHNIQUES.pptx
 
Poster-Final
Poster-FinalPoster-Final
Poster-Final
 
biosensor and its utilization in environment
biosensor and its utilization in environmentbiosensor and its utilization in environment
biosensor and its utilization in environment
 
A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...
A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...
A Simple, Rapid Analysis, Portable, Low-cost, and Arduino-based Spectrophotom...
 
Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...
Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...
Crimson Publishers -A Sensor Multiplatform for Non Invasive Diagnosis of Pros...
 
Biosensors
BiosensorsBiosensors
Biosensors
 
Mesuring ph with FOS (Fibre Optic Sensors)
Mesuring ph with FOS (Fibre Optic Sensors)Mesuring ph with FOS (Fibre Optic Sensors)
Mesuring ph with FOS (Fibre Optic Sensors)
 
Ruchika zalpouri, ae 163-d
Ruchika zalpouri, ae 163-dRuchika zalpouri, ae 163-d
Ruchika zalpouri, ae 163-d
 
Biosensors: General Principles and Applications
Biosensors: General Principles and ApplicationsBiosensors: General Principles and Applications
Biosensors: General Principles and Applications
 
E+H - Making accurate PH measurements
E+H - Making accurate PH measurementsE+H - Making accurate PH measurements
E+H - Making accurate PH measurements
 
PHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptx
PHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptxPHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptx
PHARMACEUTICAL ANALYSIS ---KUNAL BHAMARE.pptx
 
Micro Electronic Pill Seminar Report
Micro Electronic Pill Seminar ReportMicro Electronic Pill Seminar Report
Micro Electronic Pill Seminar Report
 
report
reportreport
report
 
207 progress with the calibration of a 3 fr near infrared catheter
207 progress with the calibration of a 3 fr near infrared catheter207 progress with the calibration of a 3 fr near infrared catheter
207 progress with the calibration of a 3 fr near infrared catheter
 
Progress with the a 3 fr nir fiber optic catheter
Progress with the a 3 fr nir fiber optic catheterProgress with the a 3 fr nir fiber optic catheter
Progress with the a 3 fr nir fiber optic catheter
 
207 progress with the calibration of a 3 fr near infrared catheter
207 progress with the calibration of a 3 fr near infrared catheter207 progress with the calibration of a 3 fr near infrared catheter
207 progress with the calibration of a 3 fr near infrared catheter
 
Nir catheter final
Nir catheter finalNir catheter final
Nir catheter final
 
36421
3642136421
36421
 
Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...
Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...
Design and Implement of a Novel Tool Software for Studying on Urine Dry-Chemi...
 

Report-v1b

  • 1.   Building an Optical pH Sensor for PET Probes using Machine Learning Models Megha Srivastava
  • 2.     Abstract Positron Emission Tomography (PET), a powerful technique for imaging molecular processes to diagnose diseases in the human body, requires injection of probes with a radioactive isotope that emits positron. Due to the short half-life of the isotope, the various radiochemistry synthesis and analysis steps in preparing a probe and testing its quality and safety are done in specialized laboratories located close to hospitals. A miniature microfluidics-based instrument to automate the radiochemistry steps on-site at the hospital is currently under development, and would lower the cost of PET probe production. One important quality control step is ensuring that the pH of the synthesized probe is in a safe range for injection into humans. This project created a novel optical pH sensor that works with the tiny volumes of probe sample available in the microfluidics system while meeting the accuracy requirements. Current methods, such as pH meters based on electrochemical sensors, and pH patches that are spectrally analyzed, require large volumes of liquid. The developed sensor relies on mixing in a Universal Indicator (a chemical that produces a range of colors depending on the solution’s pH), and using a spectrophotometer to measure the solution’s absorbance vs. wavelength characteristic embedded in which is color information. Sophisticated machine learning algorithms are used to learn statistical models from training data of absorbance vs. wavelength measurements for probes with known pH. Finally, the models are used to classify as safe or unsafe probes with unknown pH, or to predict the actual value of their pH. With a decision tree model, which was the best among several candidates, the sensor upon testing with a different set of test samples, gave accuracy, average recall, and average precision of 100% in predicting pH safety, and 0.29 mean and 1.0 maximum absolute error in estimating pH value.
  • 3.   1     Research Report I. Introduction Positron Emission Tomography [1], or PET, is a type of non-invasive imaging technique used for medical diagnosis of various diseases by creating a three-dimensional picture of molecular processes inside the body. It involves injecting into a subject’s blood stream a probe with a radioactive isotope that emits positrons, such as 18 F. The probe labels the molecules of interest inside the body, and the photons resulting from positron-electron annihilations are detected to construct an image of the distribution of the molecules. PET probe development starts with the production of the radioactive isotope in a cyclotron, followed by a series of chemical reaction and analysis steps to create the probe and test its safety for human injection, and then transportation to the hospital for injections. Short half-lives of the isotopes necessitate that the PET production be located close to the hospital, thus making PET probes expensive. One way to solve this problem is to create a small and efficient instrument which can perform with minimal human intervention all the necessary radiochemistry steps for production and safety testing of the probe, and which the hospitals can use on site. To engineer such an instrument, researchers are exploring [2] the use of the emerging microfluidics technologies [3, 4], which enable small volumes of fluids to be precisely manipulated at very small scales. A microfluidics-based instrument would robotically perform on small volumes of radioactive fluids the various chemical synthesis and analysis steps involved in manufacturing a PET probe. Of particular importance in a microfluidics-based instrument for PET probes are the steps which determine the quality and safety of the probes prior to human injection, and which one can envision as being performed inside the “Quality Control (QC) Box” subsystem of the overall instrument. To ensure the quality and safety of the probe, the QC Box would measure chemical properties such as concentration, clarity, and pH. The goal of this research project is to create a sensing method which could assess for a small volume of liquid whether the pH is in a safe range (4 to 8), i.e. compatible with human body, and which can be realized at a size small enough to be incorporated in the microfluidic instrument. The current way of measuring the pH of PET probes is by using a pH meter, similar in its operating principle to the pH testers used for water in swimming pools and aquariums. Invented nearly sixty years ago by Prof. Beckman at CalTech, a pH meter [5] consists of a glass rod (called the pH probe) with integrated current electrodes and amplifier, and an electronics module with circuitry for measuring the current and converting it into a pH value to display. Unfortunately, a pH meter is not suited for use in the QC Box for PET probe
  • 4.   2   testing, as it needs a volume of the fluid that is far above the microfluidics ranges. Recently, commercial systems have emerged that perform optical pH sensing by using a fiber optic probe connected to a spectrometer to observe changes in the color of pH indicator dyes. Conceptually this is similar to the centuries old litmus paper [6] approach to measuring pH, except that a better pH indicator is used and the color change is observed by a spectrometer instead of the human eye. The dyes are encapsulated inside special sol-gel materials and coated either on transmissive patches [7] affixed inside the optical probes that are dipped into the fluid or on reflective patches [8] affixed inside fluid containers with the optical probe in contact with the patch. Like the pH meters, these systems also do not work with the small volumes of fluids. While researchers are developing methods which could work with small volumes of fluid, such as pH- sensing chips with ion-sensitive transistors [9] and microfluidics platforms with integrated electronics and optical sensors [10], those technologies are still in research phase or too costly. II. Materials & Methods II.A. Overview of Approach None of the currently practical methods for determining pH described above simultaneously satisfy all the requirements presented by the microfluidics based QC Box for PET probes: low cost, small in size, capable of working with small volumes of fluid, and accurate. Therefore, based on the suggestion of my project mentor, I explored a miniaturized optical sensing approach to pH testing of PET probe. The QC Box being prototyped in my mentor’s laboratory contains a small spectrophotometer1 for ultraviolet and visible light to which fiber optic capillary (FOCap) waveguides [11] can be connected. FOCaps are optical fibers with an air hole core, which can be filled with the fluid on which optical analysis can be performed for diverse chemical sensing needs [12]. With this setup, the high level pH sensing approach is as follows: 1. Identify a suitable pH indicator2 which when mixed with the PET probe would result in sufficiently sensitive change in color in the pH range of interest (3 to 8) so to make the testing of PET probe easy and accurate. 2. The microfluidics components in the QC Box pump a tiny volume of the PET probe fluid mixed with the selected pH indicator into the core of the FOCap. With a properly chosen indicator, the fluid sample mixture would have a color that can be detected to determine whether the pH is in the safe range or not.                                                                                                                 1 An instrument that combines a spectrometer with a photometer to measure light intensity vs. wavelength. 2 A chemical that changes color with pH, and is added in small amounts to a solution to visually determine pH.
  • 5.   3   3. The color of a solution corresponds to a unique absorbance vs. wavelength signature. The spectrophotometer in the QC Box would measure the light absorbance of the fluid sample by passing through it monochromatic light of different wavelengths, and measuring the output light intensity to compute the absorbance of the fluid as a function of the wavelength. 4. A computation analysis module would take as input the spectrophotometer measurements, and algorithmically determine whether the pH is safe or not. Figure  1:  Color  variation  with  pH  for  the  selected   universal  indicator   Figure  2:  Lab-­‐bench  recreation  of  the   microfluidic  setup  for  testing   With the necessary microfluidic and optical infrastructure for the QC Box already in place (my experiments used the lab-bench re-creation of the relevant component of the QC Box, as shown in Figure 1), the focus of my project was on the first and the last steps, namely identifying a suitable pH indicator, and devising the computation analysis module. These two steps are mutually dependent as a good choice of an indicator can make the computational module work better. My goal was to come up with a solution that would give high quality results and be immune to uncertainty in measured absorbance caused by changes in the optical path due to chemical and instrumentation tolerances, mechanical offsets, calibration problems, and other errors. Within the scope of the optical pH sensing approach outlined above, I explored two specific alternatives. II.B. Initial Method: Single pH Indicator with Closed Form Analysis The first method [13] that I tried is based on using a single pH indicator [14], similar to the approach in existing macro-scale pH sensing systems [7, 8]. The pH indicator has an acid form HInd and a conjugate basic form Ind! , with the two forms having different colors. An example of an indicator is Bromocresol Green (BCG) [14], which changes color from yellow through green to blue over the narrow range of pH from 3.5 to 6. The concentration of the two forms in a solution are governed by the reaction 𝐻𝐼𝑛𝑑   + 𝐻! 𝑂 ↔ 𝐻! 𝑂! + 𝐼𝑛! for which the equilibrium equation is 𝐾! = [𝐻! 𝑂! ][𝐼𝑛! ]/[𝐻𝐼𝑛] where K! is the acid
  • 6.   4   disassociation constant [15] of the indicator. From this, the 𝑝𝐻 is derived via the Henderson–Hasselbalch equation [16] 𝑝𝐻 = 𝑝𝐾! + 𝑙𝑜𝑔!"([𝐼𝑛! ]/[𝐻𝐼𝑛]) where 𝑝𝐾! = −𝑙𝑜𝑔!"(𝐾!). The 𝑝𝐻 of the solution can be determined if an indicator of known 𝑝𝐾!is used, and [𝐼𝑛! ]/[𝐻𝐼𝑛] is measured. The latter can be computed by measuring absorbance of the solution using the spectrophotometer and making use of two observations. First, according to Beer-Lambert Law [17] absorbance 𝐴 of a solution at a specific wavelength 𝜆 is the product of the molar absorptivity 𝜀!  at that wavelength, the molar concentration 𝑐 of the absorbing particles, and the distance 𝑙 that the light travels through the material (which in my system is the width of the fiber optic capillary tube). Second, the total absorbance of the probe and indicator mixture solution at any given wavelength is the sum of the absorbance due to the two individual forms of the indicator (the probe itself is colorless). Based on these observations, [𝐼𝑛! ] and [𝐻𝐼𝑛] (and thus [𝐼𝑛! ]/[𝐻𝐼𝑛]) can be determined via a two-step process. In an initial calibration step the wavelengths of maximum absorbance for the two forms of the indicator are experimentally determined, and the molar absorptivity for each of the two forms of the indicator at each of the two identified wavelengths measured. Next, the total absorbance of the solution under test is measured at the same two wavelengths, and the following pair of simultaneous equations is solved to obtain [𝐼𝑛! ] and [𝐻𝐼𝑛] : 𝐴!! = 𝜀!"#,!! ∗ 𝑙 ∗ [𝐻𝐼𝑛] + 𝜀!"!,!! ∗ 𝑙 ∗ [𝐼𝑛! ] , and 𝐴!! = 𝜀!"#,!! ∗ 𝑙 ∗ [𝐻𝐼𝑛] + 𝜀!"!,!! ∗ 𝑙 ∗ [𝐼𝑛! ]. Once the ratio [𝐼𝑛! ]/[𝐻𝐼𝑛] has been calculated, the pH of the sample can be determined. II.C. New Method: Universal pH Indicator with Machine Learning Based Analysis Evaluation results of the initial method (see Section III.A) indicated severe limitations in our application. Therefore, I devised a second method for optical analysis of pH that overcomes these limitations by using a Universal Indicator [18] together with advanced machine learning algorithms to infer whether the pH of the PET probe is in a safe range. A Universal Indicator is a mixture of several different indicators selected so that the overall mixture exhibits several smooth color changes over a wider range of pH values as shown by the example in Figure 1. There are many universal pH indicators available, and I selected one which suited the requirements of PET probe testing, namely being able to determine with an error of less than 1 the values of pH in the range of 4 to 8 which is considered safe for human use. Since a universal indicator is composed of multiple indicators, a solution with the universal indicator mixed in would have the acid and base forms of each of those indicators present with the concentrations depending on the pH. With so many forms present, the analysis approaches used with the single indicator method are not applicable. Computing pH from the closed form model based on the Beer-Lambert Law does not generalize to the case with multiple indicators. One must look for a more sophisticated way of conducting the analysis that would determine the pH, and a key contribution of my work is developing such a method. I drew inspiration from the way a Universal Indicator is conventionally used: it is impregnated into a test strip
  • 7.   5   made of absorbent paper or added directly to the solution under test. The test strip or the solution under test changes color, and a user matches the color against a reference chart to determine the pH. In our application the UV/Vis spectrophotometer in the QC Box measures absorbance as a function of the wavelength, and this data has all the information about the color that human eyes would see. Human brains interpret colors by combining the output signals of “cone” photoreceptors in the eye’s retina. The cones come in three types, each type with a different but overlapping absorption vs. wavelength response function. The cones are informally referred to as red, green, and blue types corresponding to wavelengths where the peaks of the three types of response functions lie. The signal sent by a cone to the brain is the convolution integral of the incident light and the response function, and using it the brain interprets color [19, 20]. In contrast, a spectrophotometer’s output has much more information about the incident light’s spectrum than is present in the information sent by the cones in the eye retinas to the human brain. In fact, a spectrophotometer provides as output the entire absorbance vs. wavelength function at a very high wavelength resolution. As another comparison, the image sensors in digital cameras capture light intensity in only three narrow regions of wavelength, corresponding to the red, green, and blue pixels. While sufficient to recreate perception of natural colors by humans seeing the captured image, these image sensors also capture far less information about the absorbance vs. wavelength function than a spectrophotometer does. The preceding observations suggest the possibility of algorithms that would take as input the spectrophotometer measurements, and produce as output an estimate of the pH or a decision as to whether the pH is in the safe range or not. The additional information present in the spectrophotometer output than just the human-perceivable colors might even make it possible for the algorithm to be simple and more accurate than pH measurement via color charts. Machine Learning Based pH Analysis Approach One way to develop such an algorithm is by employing tools and techniques from Machine Learning (ML) [21, 22], an area at the intersection of Artificial Intelligence, Signal Processing, and Statistics which specializes in the construction of computational systems that learn models from training data samples and subsequently use the models for classification and regression tasks over new data samples. Classification involves computing over the data a function whose output value is a class or category label, while regression involves computing a numerical function. Formulating the ML Problem: In ML terms, the PET probe pH testing tasks can be posed as one of the following: (i) A two-category classification task: safe (i.e. pH is in the range 4 to 8) vs. unsafe (i.e. pH is below 4 or more than 8), (ii) A three-category classification task: safe (i.e. pH is in the range 4 to 8) vs. high (i.e. pH is more than 8) vs. low (i.e. pH is less than 4), and (iii) A regression task where the actual numerical
  • 8.   6   value of pH is estimated. While for testing purposes the two-category classification is sufficient and one would expect the algorithms to be simplest and perform the best, the three-category classification and the regression-based of pH value provide additional valuable information. Therefore I explored algorithms for all three cases. Model Learning Method: Furthermore, ML researchers have developed a variety of different types of learning models and there are many tools freely available for one to use. I decided to focus on three approaches: (i) Decision Tree [23] (comes as two variants: Classification Tree and Regression Tree) where the model is structured as a tree of decisions over the inputs leading to prediction of the class or numerical estimate of a variable, (ii) Support Vector Machine or SVM [24] (and its variant Support Vector Regression) where the space of input values is divided into clusters by high-dimensional hyperplanes, and (iii) Multivariate Linear Regression [25], which is a multidimensional generalization of the common best-fit line method. Choice of Input Features: In order to use ML methods, one must also identify the data to use as inputs. These are called “features”. Using the entire absorbance vs. wavelength from the spectrophotometer would be too much data to process simply, so I decided to sample the absorbance vs. wavelength function at five uniformly spaced wavelength values (300nm, 400nm, 500nm, 600nm, and 700nm) that cover the entire visible spectrum. In other words, the input feature is a five-dimensional vector [𝐴!""!", 𝐴!""!", 𝐴!""!", 𝐴!""!", 𝐴!""!"]. While a feature vector with more sample points might be better, I decided to start with a manageable number to keep the ML complexity low. Fortuitously, as the results later show, the choice of five turned out to be adequate. However, for ML algorithms to work well, it is generally considered good to scale the features so that they all lie in the same range of values typically chosen to be [0,1]. So I scaled the raw absorption measurements using the formula 𝐴!"#$%& = (𝐴!"#$%&"' − 𝐴!"#)/(𝐴!"# − 𝐴!"#) and selected 𝐴!"# = 0.2 and 𝐴!"# = −0.2  as convenient and conservative values that worked for the absorbance measurements I observed. Scaling also has the advantage that negative absorbance values that can arise from optical shifts can be used as well. Transforming Input Features: However, intuitively, even the scaled absorption values have the disadvantage that the model is dependent on not just the shape of the spectrum but also the absolute values. In other words, this choice of features incorporates both the color and intensity. Since the latter can be affected by factors such as clarity and concentration, it would be desirable to transform the input features such that they capture information about the shape of the spectrum but not its magnitude. I decided to explore two heuristics for this. The first involves normalizing the elements of the feature vector such that the largest one has a value of 1. In other words, all the values of a feature vector are divided by its highest one.
  • 9.   7   Intuitively, the feature vector now represents absorbance as ratios relative to the peak, and thus captures the shape of the spectrum. The second heuristic is based on the observation that color corresponds to the “direction” of the feature vector. From linear algebra, the direction information of a feature vector can be captured by the elements of a unit vector parallel to the feature vector. To accomplish this, one can simply scale the elements of the feature vector by the magnitude of the feature vector to obtain a feature vector of unit magnitude. Furthermore, only four of the elements of the unit feature vector need to be used for model learning since the fifth one can be determined from the other four. I refer to the first heuristic as the normalize_maximum approach and the second one as the normalized_magnitude approach. As the preceding discussion shows, there is a rich space of ML based methods for me to explore: (i) Three possible model learning objectives: classification into two-categories, classification into three-categories, and regression-based estimation of pH value, (ii) Three candidate learning methods: decision tree for classification and regression, SVM for classification and regression, and multivariate linear regression, and (iii) Three candidate choices of feature vectors: scaled, scaled with normalized_maximum, and scaled with normalized_magnitude. I collected a training data set on one day and a test data set on a different day. In each case, I collected spectrophotometer measurements for a variety of test solutions at different pH values, and also captured the actual pH value using a high quality pH meter. The training data set including the actual values was then used to learn ML models for the various cases identified in the preceding paragraph. Next, I evaluated the models thus created on the test data set, and compared the predictions of the pH value made by the models against the real pH value as measured by the pH meter. Finally, I used the various error metrics obtained from the comparisons to identify the best model for each of the three learning objectives. III. Results and Discussion III.A. The Single Indicator Method with Conventional Analysis Using the method described in Section II.B with Bromocresol Green (𝑝𝐾! = 4.7) and Bromocresol Purple (𝑝𝐾! = 6.3) as indicators, I collected and analyzed data according to the steps below. The absorbance and wavelengths were measured using a USB-pluggable miniature fiber-optic spectrometer [26] using sample volumes similar to that available in the microfluidics instrument. Step 1: Find peak absorbance and wavelength for indicator acid and base forms. Initially, the spectrometer gave an absorption spectra graph for each of the four indicator forms in Table 1. I determined at what wavelength value was the graph’s maximum absorption value, and measured the absorption at that
  • 10.   8   value. Although the two indicators are different, in very acidic and very basic forms their colors are similar, which explains their similar peak wavelengths. Indicator Form Peak Absorption Corresponding Wavelength (nm) Bromocresol Green Acid 0.075971 481.372 Bromocresol Green Base 0.059826 526.482 Bromocresol Purple Acid 0.043468 481.168 Bromocresol Purple Base 0.097371 526.281 Table  1:  Measurements  for  Step  1   Step 2: Find acid form’s absorbance at base form’s peak wavelength, and vice versa. Once I determined what wavelength had the peak absorbance value for the acid form, I measured the absorbance at the same value for the base form. I then measured the absorbance value of the base form at the peak wavelength of the acid form. I did this for both indicators, and as expected, the absorbance values were much lower than the values at their respective peak wavelengths, as shown in Table 2. Indicator Form Step 2 Step 3 Wavelength (nm) Absorption Molar Absorption at Acid Form’s Peak Wavelength Molar Absorption at Base Form’s Peak Wavelength Bromocresol Green Acid 526.482 0.018188 71606 at 481.372 nm 1714 at 526.482 nm Bromocresol Green Base 481.372 0.020062 1891 at 481.372 nm 563887 at 526.482 nm Bromocresol Purple Acid 526.281 0.004431 7010 at 481.168 nm 715 at 526.281 nm Bromocresol Purple Base 481.168 0.033857 5460 at 481.168 nm 15703 at 526.281 nm Table  2:  Measurements  for  Step  2  and  Step  3   Step 3: Determine molar absorptivity of acid & base forms at the two peak wavelengths. Using Beer’s Law and the known values of indicator concentration and microfluidic capillary path length, I used the
  • 11.   9   absorption values to calculate the molar absorptivity for each indicator form at each wavelength, as shown in Table 2. Step 4: Measure absorbance of unknown solution with indicator at the two peak wavelengths. Performing five trials of a solution of the same unknown pH, I determined the absorption values of the solutions mixed with indicator at the acid and base forms’ peak wavelengths, and averaged them. The solution I used was 9 g NaCl / 1 L water, which is the standard saline solution used in PET probes. Data obtained is shown in Table 3. Indicator Absorption at Acid Form’s Peak Wavelength Absorption at Base Form’s Peak Wavelength Bromocresol Green 0.03491 at 526.482 nm 0.077568 at 481.372 nm Bromocresol Purple 0.015039 at 526.281 nm 0.042001 at 481.168 nm Table  3:  Measurements  for  Step  4   Step 5: Using data to solve aforementioned system of equations, determine pH. Finally, using the system of equations as described in Section II.B, I calculated the pH value of the unknown solution. I also measured the pH value using a pH meter, assumed that value to be accurate, and calculated the % error of the values determined via the indicator method. As Table 4 shows, Bromocresol Purple was much more accurate than Bromocresol Green. This might be because the effective range of Bromocresol Green indicator ends at around pH = 5.5, which was close to the actual value of the unknown solution’s pH. pH Measurement Method pH Value Error pH Meter 5.45 None (Ground Truth) Bromocresol Green 3.433 -37% Bromocresol Purple 5.416 -0.62% Table  4:  Analysis  results  from  Step  5   Step 6: Collect Data of Change in pH vs. Indicator Concentration for Bromocresol Purple. When trying to figure out additional reasons behind the huge % error for Bromocresol Green, I realized that adding too much indicator also affects the pH of a solution. Since the point of the project is to determine the pH of the solution, this is clearly something that should be avoided. However, the concentration of indicator also needs to be high enough for the spectrometer to detect the color. Since we were using microfluidic capillaries, the
  • 12.   10   indicator concentration needs to be much higher than with other spectrometers in order for accurate detection to occur. Thus, I collected data reported in Table 5 regarding the effect of Indicator Concentration on the Change in pH of a saline solution for Bromocresol Purple, which according to Table 4 caused less error. As the concentration of indicator increases, the change in pH does too. It is interesting to note that the trend line (see Figure 3) suggests that the origin is not a point on the line, although adding no indicator should mean no change. This might mean that at concentrations lower than .0001 M, the trend is not linear. Indicator Concentration Change in pH of Solution .00004252 .27 .00008117 .3 .00066142 .86 .00023150 .42 .00014882 .34 Table  5:  Measurements  for  Step  6.   Figure  3:  Trend  line  for  data  from  Step  6  for  Bromocresol  Purple   Step 7: Determining % Error of pH Determination Using Spectrometry vs. Indicator Concentration. Given that at lower concentrations of indicator, it is harder for the spectrometer to detect the absorbance, I wanted to find the value at which the % Error of using the indicator method would be a minimum. I created more solutions mixed with Bromocresol Purple, measured their actual pH, and then used the Single Indicator Method and determined the error the resulting pH had compared to the actual value. The resulting data is y"="968.22x"+"0.2123" R²"="0.99597" 0" 0.1" 0.2" 0.3" 0.4" 0.5" 0.6" 0.7" 0.8" 0.9" 1" 0" 0.0001" 0.0002" 0.0003" 0.0004" 0.0005" 0.0006" 0.0007" change'in'pH' concentra.on'(M)' change'in'pH'vs.'concentra.on' concentration (M) 0 0.0001 0.0002 0.0003 0.0004 0.0005 0.0006 0.0007 changeinpH 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 y = 968.22x + 0.2123 R2 = 0.99597
  • 13.   11   shown in Table 6, and it is clear from the regression curve in Figure 4 that at around .0008 M the % error approaches 0, while results from Step 6 show that at concentrations as low as .0001 M adding indicator changes the pH. Since an optimum value for indicator concentration was not found, and moreover, the range that Method 1 can work for is small due to the nature of a single indicator, a new method was devised using the Universal Indicator. This method, described in the next subsection, ended up being more successful, and effective for a much bigger range of pH values. Indicator Concentration % Error of Spectrometer Analysis 0.000826778 -0.624980954 0.000661423 3.467153285 0.000312522 11.91058394 0.000178584 19.90875912 Table  6:  Measurements  for  Step  7.   Figure  4:  Best  fit  curve  for  Step  6  measurements.   III.B. The Universal Indicator Method with Machine Learning Based Analysis Following the method described earlier in Section II.C with a Universal Indicator from Sigma-Aldrich [27] for pH range 4-10, I performed the following data collection, model learning, and analysis steps. Step 1: Collect Training and Test Data !5# 0# 5# 10# 15# 20# 25# 0# 0.0001# 0.0002# 0.0003# 0.0004# 0.0005# 0.0006# 0.0007# 0.0008# 0.0009# %"error"using"spectroscopy" indicator"concentra1on"(M)" %"error"vs."indicator"concentra1on" indicator concentration (M) %errorusingspectroscopy 25 20 15 10 5 0 -5 0 0.0001 0.0002 0.0003 0.00050.0004 0.0006 0.0007 0.0008 0.0009 R2 = 0.99565
  • 14.   12   In order to learn a statistical model using machine learning methods for later assessment of the pH of PET probes, I made absorbance vs. wavelength measurements for several sample solutions with known “ground truth” pH (as measured by a pH meter) spanning a wide range of pH values. Specifically, 34 measurements were made across 19 different pH values in the range 3.1 to 11.3 (several of the samples were measured twice). The absorbances at the various wavelengths were measured using a NanoDrop UV-Vis microvolume spectrophotometer [28]. Additionally, on a different day, I collected measurements from 9 other samples, also with known pH (as measured by a pH meter), with this second set being meant as the testing set to determine how well the model learnt over the training set does on new data. As described in Section II.C, for each case the absorbance was measured at five wavelengths (λ   =  300 nm, 400 nm, 500 nm, 600 nm, and 700 nm), and these values then scaled using the formula 𝐴!"#$%& = 2.5 ∗ 𝐴!"#$%&"' + 0.5. Table 7 presents the measured and scaled absorbance value 𝐴! and 𝑆! and the ground truth pH, for a subset of training and testing data. Step 2: Compute Feature Vectors with Heuristic Transformations The 5-dimensional vector of scaled absorbance values were then transformed using the two heuristics introduced in Section II.C, normalized_maximum and normalized_magnitude. The elements of the transformed feature vectors are 𝑅! and 𝑈! in Table 8. As noted in Section II.C, for normalize_magnitude case, values at only 4 out of 5 wavelengths are independent, and so I use the first four entries of 𝑈! features. Step 3: Learn and Evaluate the Various ML Models For learning the models and using them for classification and regression, I used two different tools: the BigML [29] cloud-based service for decision tree modeling for classification and regression, and the popular R software environment [29] for statistical computing together with e1071 [31], and caret [32] packages for support vector machine and multivariate linear models. I wrote a custom analysis program in the “R” language to train the models, run them on test data to make predictions, and compute various error statistics to evaluate the performance. The program also incorporates decision tree models learnt in BigML using the latter’s capability to export executable R code. For the two classification tasks I computed the following performance metrics for the predictions made by each of two types of classifiers with each of the three types of feature vectors: accuracy, average precision, average recall, average F measure, and average Phi Coefficient [33, 34]. As Table 9 shows, the best performing classifier in both the classification tasks was a decision tree classifier using scaled absorbance vectors with normalized magnitude. The corresponding cells in the table are highlighted with yellow background. In fact, for both the tasks decision tree classifiers yielded 100% accuracy, 100% average
  • 15.   13   precision, and 100% average recall, and value of 1 for both average F measure, and average Phi Coefficient. This is theoretically the best possible performance. Table  7:  Absorbance  data  collected  in  Step  1  for  training  and  testing,  and  its  scaled  version   For the regression task of estimating pH, we had three choices of three types of regression models, and I computed the following performance metrics: mean absolute error, mean squared error, maximum absolute error, and coefficient of determination R2 [35] (as computed by R2 function in the caret package [32] with
  • 16.   14   “corr” formula”). As Table 10 shows via the cells highlighted in yellow, for pH estimation as well the decision tree approach (regression tree) was the best, giving excellent mean absolute error of 0.29 and maximum absolute error of 1, which is acceptable for PET probe application. Table  8:  Absorbance  with  normalized  maximum  value  and  with  normalized   magnitude  computed  in  Step  3  
  • 17.   15   Table  9:  Performance  of  various  classifiers  and  feature  vector  choice  on   the  two  classification  version  of  the  pH  sensing  task   Table  10:    Performance  of  various  regression  models  and  feature  vector  choice  on  the  pH  value   estimation.  
  • 18.   16   IV. Conclusions and Future Work My research demonstrates the significant advantage of using machine learning (ML) to create models for sensors. My work showed two methods of building an optical pH platform that can be used with microfluidics. However, the first method (Single Indicator Method) had severe limitations. I could not find an indicator concentration that was high enough for spectrometric detection, but low enough to not alter the pH of the sample. More importantly, even if an optimum indicator concentration were determined, that method would have only worked for a small range of pH values due to Bromocresol Purple’s color change range of 5.2 → 6.8, which is insufficient for the intended application of my sensor in testing PET probes. The second method involving a Universal Indicator and an ML approach was both novel and much more effective than the previous method. This method works for a large pH range, and is especially accurate when classifying whether a solution is safe or unsafe for human injection. Moreover, this method did not rely on any physics model, while the first method relied on Beer’s Law. The beauty of machine learning is that through a statistical approach a model was created for my data, without any knowledge of chemical or physical laws. I also generated software code in R statistical programming language embodying the models that I trained using ML tools. Eventually, this code can be embedded in the control processor of the microfluidic instrument containing the pH sensor. Due to time constraints, I was only able to collect a limited amount of data. Although the results of my second method are fairly accurate, they could definitely be improved if more data was collected, since a better model would be created. Additionally, although I created a successful method for developing a sensor, I never had the chance to implement it into the actual instrument that will be sent to hospitals for use. Building the actual sensor might raise some issues with this method: for example, other features of the instrument might disrupt the pH sensing functionality. Since my method is based on analyzing color and light properties, changes in lighting conditions could affect my method as well. If given more time, I would collect a lot more data samples, and for each sample also collect absorbance at more than just 5 wavelengths. There is no fundamental limit to the number of features one can use for ML, and feature vectors with absorbance values at a large number of wavelengths will capture the shape of the absorbance vs. wavelength function with higher fidelity. However, this would also increase the computational time for model training. Finally, ML is becoming more and more useful in many different fields for creating models based on data. While there is much literature out there about ML and its applications, my method is novel in applying an ML approach to devise a pH sensor. There is no reason why my method of analyzing results is limited to pH sensing: it is possible that more robust sensors for detecting properties such as pollution or temperature can be built by using ML to train a model unique to the properties of the data being measured without requiring a
  • 19.   17   closed form physics model of the phenomenon. The applications of ML are great in number and varied, and my research shows that an ML approach is quite beneficial in building a high quality optical-based pH sensor. V. Appendix: Software Implementation As mentioned earlier, I used the BigML [29] cloud-based service for learning the decision tree model for classification and regression, and used the popular R software environment [29] for statistical computing together with e1071 [31], and caret [32] packages for learning the support vector machine and multivariate linear models. My results had indicated that decision tree based models worked the best for each of three versions of the problem: the two-category classification task; the three-category classification task, and the regression task where the actual numerical value of pH is estimated. In each case the decision tree takes as input features a vector of the absorbance values at the five wavelengths after they have been scaled and then the entire vector normalized to have unit magnitude (which corresponds to another multiplicative scaling by the inverse of the magnitude). I implemented the three decision threes as functions in the Python programming language, as shown in the code listing below. This complexity of this code is low, and thus it can run on an embedded computer (e.g. Raspberry PI) with Python interpreter under Linux OS. This computer can be attached to the spectrophotometer hooked up to the microfluidics-based instrument for PET probe preparation, and process in real-time the absorbance measurements to check whether the pH is safe. # y1, y2, y3, y4, and y5 are the scaled and normalized absorbance values # at wavelengths of 300 nm, 400 nm, 500 nm, 600 nm, and 700 nm respectively # def predict_cat2(y1=None, y2=None, y3=None, y4=None, y5=None): """ Predictor from BigML model/523539b9035d0772e6004372 Returns 'N' is the pH is not okay, and returns 'Y' if it is """ if (y4 is None): return u'N' if (y4 > 0.2265): if (y3 is None): return u'N' if (y3 <= 0.40872): return u'Y' if (y3 > 0.40872): return u'N' if (y4 <= 0.2265): if (y2 is None): return u'Y' if (y2 <= 0.52273): if (y5 is None): return u'N' if (y5 > 0.06984): return u'Y' if (y5 <= 0.06984): return u'N' if (y2 > 0.52273): return u'Y' def predict_cat3(y1=None, y2=None, y3=None, y4=None, y5=None): """ Predictor from BigML model/52353d69035d0772e500425c Returns 'OK', 'LO', or 'HI' depending on whether pH is okay, too low, or too hight """ if (y4 is None): return u'HI' if (y4 > 0.2265): if (y3 is None): return u'HI' if (y3 <= 0.40872): return u'OK' if (y3 > 0.40872): return u'HI' if (y4 <= 0.2265): if (y2 is None): return u'OK' if (y2 <= 0.52273): if (y5 is None): return u'LO'
  • 20.   18   if (y5 > 0.06984): return u'OK' if (y5 <= 0.06984): return u'LO' if (y2 > 0.52273): return u'OK' def predict_ph(y1=None, y2=None, y3=None, y4=None, y5=None): """ Predictor for pH from BigML model/52354117035d0772e70057a0 Returns estimated pH value """ if (y4 is None): return 7.82471 if (y4 > 0.2265): if (y3 is None): return 9.67158 if (y3 <= 0.59149): if (y5 is None): return 8.80545 if (y5 > 0.10748): if (y5 <= 0.18737): return 8.11 if (y5 > 0.18737): return 6.84 if (y5 <= 0.10748): if (y3 <= 0.51374): if (y4 > 0.29383): if (y5 <= 0.08854): if (y5 > 0.05973): return 9.1 if (y5 <= 0.05973): return 9.08 if (y5 > 0.08854): return 8.92 if (y4 <= 0.29383): if (y5 <= 0.04749): return 8.92 if (y5 > 0.04749): return 8.11 if (y3 > 0.51374): if (y3 > 0.54783): if (y5 <= 0.0471): return 9.75 if (y5 > 0.0471): return 9.58 if (y3 <= 0.54783): return 9.35 if (y3 > 0.59149): if (y2 is None): return 10.8625 if (y2 > 0.63997): if (y3 <= 0.67721): if (y2 > 0.66202): return 10.16 if (y2 <= 0.66202): return 10.7 if (y3 > 0.67721): return 11.28 if (y2 <= 0.63997): if (y1 is None): return 11.15 if (y1 <= 0.74167): if (y5 is None): return 11.3 if (y5 > 0.07083): return 11.28 if (y5 <= 0.07083): return 11.31 if (y1 > 0.74167): return 10.7 if (y4 <= 0.2265): if (y3 is None): return 5.48533 if (y3 <= 0.69987): if (y3 > 0.44591): return 6.09 if (y3 <= 0.44591): if (y5 is None): return 7.115 if (y5 <= 0.08164): if (y4 > 0.1734): if (y4 <= 0.19837): return 6.84 if (y4 > 0.19837): return 7.09 if (y4 <= 0.1734): return 7.79 if (y5 > 0.08164): return 6.09 if (y3 > 0.69987): if (y4 > 0.19742): return 5.39 if (y4 <= 0.19742): if (y2 is None): return 3.78667 if (y2 <= 0.37496): return 3.17 if (y2 > 0.37496): if (y4 > 0.15476): return 4.32 if (y4 <= 0.15476): return 3.87 Below is an outline of the code in the R statistical programming language that I wrote to evaluate the performance of various machine learning models. For the case of support vector machine and multivariate
  • 21.   19   regression, I use the implementations provided by the e1071 package in R, whereas for the decision tree I used an implementation in R of the decisions trees exported from BigML. This code takes as input a file in the .csv format, with columns labeled AN300nm, AN400nm … AN700nm giving the scaled absorbance vector normalized to be unit magnitude, and columns labeled RN300nm, RN400nm … RN700nm giving the scaled absorbance vector normalized so that the highest entry in each vector is 1. Furthermore, the .csv file has columns labeled pH, CAT2, and CAT3 giving the ground truth for the three cases that I explored (the value of pH, whether the pH is okay or not, and whether the pH is okay or too hight or too low).   library(e1071) library(caret) phdata <- read.csv("phdata.csv") n = dim(phdata)[1] n_train = 34 n_test = n-n_train phdata_train = phdata[1:n_train,] phdata_test = phdata[(n_train+1):n,] ph_test_actual = phdata[(n_train+1):n,"pH"] cat2_test_actual = phdata[(n_train+1):n,"CAT2"] cat3_test_actual = phdata[(n_train+1):n,"CAT3"] print_error_stats <- function(label,predicted,actual) { # this function prints various error statistics which I used to populate Table 9 and 10 # Due to space limitation the detailed code has been removed … } # Regression: Prediction of value of pH model_svm_ph_AN <- svm(pH~AN300nm+AN400nm+AN500nm+AN600nm,type="eps-regression", kernel="polynomial",degree=3,data=phdata_train) model_svm_ph_RN <- svm(pH~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,type="eps-regression", kernel="polynomial",degree=3,data=phdata_train) model_lm_ph_AN <- lm(pH~AN300nm+AN400nm+AN500nm+AN600nm,data=phdata_train) model_lm_ph_RN <- lm(pH~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,data=phdata_train) ph_test_predicted_svm_AN <- predict(model_svm_ph_AN,phdata_test) ph_test_predicted_svm_RN <- predict(model_svm_ph_RN,phdata_test) ph_test_predicted_lm_AN <- predict(model_lm_ph_AN,phdata_test) ph_test_predicted_lm_RN <- predict(model_lm_ph_RN,phdata_test) print_error_stats("ph svm_AN",ph_test_predicted_svm_AN,ph_test_actual) print_error_stats("ph svm_RN",ph_test_predicted_svm_RN,ph_test_actual) print_error_stats("ph lm_AN",ph_test_predicted_lm_AN,ph_test_actual) print_error_stats("ph lm_RN",ph_test_predicted_lm_RN,ph_test_actual) # Two-category classification: Prediction of whether pH is ok or not model_svm_cat2_AN <- svm(CAT2~AN300nm+AN400nm+AN500nm+AN600nm,data=phdata_train) model_svm_cat2_RN <- svm(CAT2~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,data=phdata_train) cat2_test_predicted_svm_AN <- predict(model_svm_cat2_AN,phdata_test) cat2_test_predicted_svm_RN <- predict(model_svm_cat2_RN,phdata_test) cat2_cm_svm_AN = as.matrix(confusionMatrix(cat2_test_predicted_svm_AN,cat2_test_actual)) cat2_cm_svm_RN = as.matrix(confusionMatrix(cat2_test_predicted_svm_RN,cat2_test_actual)) print_error_stats("cat2 svm_AN",cat2_test_predicted_svm_AN,cat2_test_actual) print_error_stats("cat2 svm_RN",cat2_test_predicted_svm_RN,cat2_test_actual) # Three-category classification: Prediction of whether pH is ok or not model_svm_cat3_AN <- svm(CAT3~AN300nm+AN400nm+AN500nm+AN600nm,data=phdata_train) model_svm_cat3_RN <- svm(CAT3~RN300nm+RN400nm+RN500nm+RN600nm+RN700nm,data=phdata_train) cat3_test_predicted_svm_AN <- predict(model_svm_cat3_AN,phdata_test) cat3_test_predicted_svm_RN <- predict(model_svm_cat3_RN,phdata_test) cat3_cm_svm_AN = as.matrix(confusionMatrix(cat3_test_predicted_svm_AN,cat3_test_actual)) cat3_cm_svm_RN = as.matrix(confusionMatrix(cat3_test_predicted_svm_RN,cat3_test_actual))
  • 22.   20   print_error_stats("cat3 svm_AN",cat3_test_predicted_svm_AN,cat3_test_actual) print_error_stats("cat3 svm_RN",cat3_test_predicted_svm_RN,cat3_test_actual) # Evaluation of decision tree models from BigML (the .R file exported from BigML) sourcescript_bigml_pH.R") source("script_bigml_cat2.R") source("script_bigml_cat3.R") sum_errabs = 0 sum_errsq = 0 max_errabs = 0 ph_test_predicted_rt_AN = rep(NA,n_test) ph_test_predicted_rt_RN = rep(NA,n_test) for (i in 1:n_test) { ph_test_predicted_rt_AN[i] = predict_ph_AN(phdata_test[i,]$AN300nm,phdata_test[i,]$AN400nm, phdata_test[i,]$AN500nm,phdata_test[i,]$AN600nm) ph_test_predicted_rt_RN[i] = predict_ph_RN(phdata_test[i,]$RN300nm,phdata_test[i,]$RN400nm, phdata_test[i,]$RN500nm,phdata_test[i,]$RN600nm,phdata_test[i,]$RN700nm) } print_error_stats("ph rt_AN",ph_test_predicted_rt_AN,ph_test_actual) print_error_stats("ph rt_RN",ph_test_predicted_rt_RN,ph_test_actual) cat2_test_predicted_rt_AN = rep(NA,n_test) cat2_test_predicted_rt_RN = rep(NA,n_test) for (i in 1:n_test) { cat2_test_predicted_rt_AN[i] = predict_cat2_AN(phdata_test[i,]$AN300nm,phdata_test[i,]$AN400nm, phdata_test[i,]$AN500nm,phdata_test[i,]$AN600nm) cat2_test_predicted_rt_RN[i] = predict_cat2_RN(phdata_test[i,]$RN300nm,phdata_test[i,]$RN400nm, phdata_test[i,]$RN500nm,phdata_test[i,]$RN600nm,phdata_test[i,]$RN700nm) } cat2_test_predicted_rt_AN = factor(cat2_test_predicted_rt_AN,c("N","Y")) cat2_test_predicted_rt_RN = factor(cat2_test_predicted_rt_RN,c("N","Y")) print(paste("cat2 [actual]",paste(cat2_test_actual,collapse=" "))) print_error_stats("cat2 AN",cat2_test_predicted_rt_AN,cat2_test_actual) print_error_stats("cat2 RN",cat2_test_predicted_rt_RN,cat2_test_actual) cat3_test_predicted_rt_AN = rep(NA,n_test) cat3_test_predicted_rt_RN = rep(NA,n_test) for (i in 1:n_test) { cat3_test_predicted_rt_AN[i] = predict_cat3_AN(phdata_test[i,]$AN300nm,phdata_test[i,]$AN400nm, phdata_test[i,]$AN500nm,phdata_test[i,]$AN600nm) cat3_test_predicted_rt_RN[i] = predict_cat3_RN(phdata_test[i,]$RN300nm,phdata_test[i,]$RN400nm, phdata_test[i,]$RN500nm,phdata_test[i,]$RN600nm,phdata_test[i,]$RN700nm) } cat3_test_predicted_rt_AN = factor(cat3_test_predicted_rt_AN,c("HI","LO","OK")) cat3_test_predicted_rt_RN = factor(cat3_test_predicted_rt_RN,c("HI","LO","OK")) print(paste("cat3 [actual]",paste(cat3_test_actual,collapse=" "))) print_error_stats("cat3 AN",cat3_test_predicted_rt_AN,cat3_test_actual) print_error_stats("cat3 RN",cat3_test_predicted_rt_RN,cat3_test_actual)
  • 23.   1   References 1. Ollinger, John M., and Jeffrey A. Fessler. "Positron-emission tomography." Signal Processing Magazine, IEEE 14, no. 1 (1997): 43-55. 2. Keng, Pei Yuin, Supin Chen, Huijiang Ding, Saman Sadeghi, Gaurav J. Shah, Alex Dooraghi, Michael E. Phelps, Nagichettiar Satyamurthy, Arion F. Chatziioannou, and R. Michael van Dam. "Micro-chemical synthesis of molecular probes on an electronic microfluidic device." Proceedings of the National Academy of Sciences 109, no. 3 (2012): 690-695. 3. Choi, Kihwan, Alphonsus HC Ng, Ryan Fobel, and Aaron R. Wheeler. "Digital microfluidics." Annual Review of Analytical Chemistry 5 (2012): 413-440. 4. Whitesides, George M. "The origins and the future of microfluidics." Nature 442, no. 7101 (2006): 368-373. 5. American Chemical Society National Historic Chemical Landmarks, “Development of the Beckman pH Meter”. http://portal.acs.org/portal/PublicWebSite/education/whatischemistry/landmarks/beckman/index.htm (accessed September 25, 2013). 6. Wikipedia, “Litmus”. http://en.wikipedia.org/wiki/Litmus (accessed September 25, 2013). 7. Ocean Optics, Inc., “In Situ Transmissive pH Sensors”. http://www.oceanopticssensors.com/products/phsensor.htm (accessed September 25, 2013). 8. Ocean Optics, Inc., “Non-Intrusive Reflective pH Sensors”. http://www.oceanopticssensors.com/products/phbcg.htm (accessed September 25, 2013). 9. Hammond, Paul A., Danish Ali, and David RS Cumming. "A system-on-chip digital pH meter for use in a wireless diagnostic capsule." Biomedical Engineering, IEEE Transactions on 52, no. 4 (2005): 687-694.
  • 24.   2   10. Kuswandi, Bambang, Jurriaan Huskens, and Willem Verboom. "Optical sensing systems for microfluidic devices: a review." Analytica chimica acta 601, no. 2 (2007): 141-155. 11. Romaniuk, R. "Capillary optical fiber–design, fabrication, characterization and application." Bulletin of the Polish Academy of Sciences 56, no. 2 (2008). 12. Borecki, Michał, Michael L. Korwin-Pawlowski, Maria Beblowska, Jan Szmidt, and Andrzej Jakubowski. "Optoelectronic capillary sensors in microfluidic and point-of-care instrumentation." Sensors 10, no. 4 (2010): 3771-3797. 13. Skoog, Douglas A., Donald M. West, James F. Holler, and Stanley R. Crouch. "Fundamentals of Analytical Chemistry,." Cengage Learning (2013): 1072. 14. Mr. Kent’s Chemistry Page, “Acid Based Indicators,” http://www.kentchemistry.com/links/AcidsBases/Indicators.htm (accessed September 25, 2013). 15. Wikipedia, “Acid disassociation constant.” http://en.wikipedia.org/wiki/Acid_dissociation_constant (accessed September 25, 2013). 16. Wikipedia, “Henderson–Hasselbalch equation.” http://en.wikipedia.org/wiki/Henderson-Hasselbalch_equation (accessed September 25, 2013). 17. Wikipedia, “Beer–Lambert law.” http://en.wikipedia.org/wiki/Beer%E2%80%93Lambert_law (accessed September 25, 2013). 18. Wikipedia, “Universal indicator.” http://en.wikipedia.org/wiki/Universal_indicator (accessed September 25, 2013). 19. Wikipedia, “Color vision.” http://en.wikipedia.org/wiki/Color_vision (accessed September 25, 2013). 20. Wyszecki, Günter, and Walter Stanley Stiles. Color science. New York: Wiley, 1982.
  • 25.   3   21. Bishop, Christopher M., and Nasser M. Nasrabadi. Pattern recognition and machine learning. Vol. 1. New York: springer, 2006. 22. Wikipedia, “Machine learning.” http://en.wikipedia.org/wiki/Machine_learning (accessed September 25, 2013). 23. Rokach, Lior. Data mining with decision trees: theory and applications. Vol. 69. World Scientific, 2007. 24. Steinwart, Ingo, and Andreas Christmann. Support vector machines. Springer, 2008. 25. Aiken, Leona S., Stephen G. West, and Steven C. Pitts. "Multiple linear regression." Handbook of psychology (2003). 26. Ocean Optics, “USB4000 Miniature Fiber Optic Spectrometer.” http://www.oceanoptics.com/products/usb4000.asp (accessed September 25, 2013). 27. Sigma-Akdrich, “36828 FLUKA Universal indicator solution with color chart and directions for use, pH 4-10.” http://www.sigmaaldrich.com/catalog/product/fluka/36828?lang=en&region=US (accessed September 25, 2013). 28. Thermo Scientific, “NanoDrop 2000 UV-Vis Spectrometer.” http://www.nanodrop.com/Productnd2000overview.aspx (accessed September 25, 2013). 29. BigML Inc. https://bigml.com (accessed September 25, 2013). 30. Crawley, Michael J. The R book. John Wiley & Sons, 2012. 31. Dimitriadou, Evgenia, Kurt Hornik, Friedrich Leisch, David Meyer, Andreas Weingessel, and Maintainer Friedrich Leisch. "Package ‘e1071’." R Software package, avaliable at http://cran. rproject. org/web/packages/e1071/index. html (2009).
  • 26.   4   32. Kuhn, Max. "Building predictive models in R using the caret package." Journal of Statistical Software 28, no. 5 (2008): 1-26. 33. Jos Verwoerd, BigML Inc., “Predicting with My Model: Is It Safe?.” http://blog.bigml.com/2012/12/03/predicting-with-my-model-is-it-safe/ (accessed September 25, 2013). 34. Parker, Charles. "An analysis of performance measures for binary classifiers." In Data Mining (ICDM), 2011 IEEE 11th International Conference on, pp. 517-526. IEEE, 2011. 35. Kvålseth, Tarald O. "Cautionary note about R 2." The American Statistician 39, no. 4 (1985): 279- 285.