Chapter 8
Beyond regression: classifiers and projections
An equation can do more than predict a number. This chapter uses the search methods of the previous chapters for two other tasks that matter in process engineering. A symbolic classifier separates two operating regimes by an explicit decision boundary; with a sign decision it reproduces the critical equations of process safety, with a logistic link it gives calibrated probabilities. A goal-oriented projection maps high-dimensional data to two explicit features chosen so that a map of the data shows what the analyst needs to see: classes that separate, a structure that is preserved, or a quality that becomes predictable by a linear soft sensor.
8.1 Problem and idea
Process safety has a long tradition of critical equations: explicit inequalities in the operating variables that separate safe operation from a dangerous regime. The Semenov criterion of thermal explosion compares the heat generated by an exothermic reaction with the heat removed by cooling and predicts runaway when their ratio exceeds a threshold. Such criteria are valued because they can be read, checked against physics, and evaluated by an operator. Kummer, Varga and Abonyi [2] turned the derivation of runaway criteria into a classification problem: simulated or measured operating points are labeled as runaway or not, and genetic programming searches for an expression whose sign separates the two classes (fig. 8.1, left). The boundary is the critical equation.
The second task is visualization. Principal component analysis projects high-dimensional data on the directions of largest variance, which need not be the directions that matter for the question at hand. Kulcsár et al. [4] used genetic programming to construct nonlinear mappings of infrared spectra for process monitoring, and Dörgő, Kulcsár and Abonyi [3] formulated goal-oriented projections: the mapping is a pair of explicit equations, and its cost function encodes the goal of the analysis, such as the separation of classes or the predictability of a quality variable (fig. 8.1, right). The equations show which variables a map uses and how.
8.2 Theory
8.2.1 Symbolic classification
For two classes , the symbolic classifier evolves a single expression . With the sign decision the classifier predicts the positive class where and is evaluated by the balanced error, the mean of the error rates of the two classes, which is insensitive to class imbalance; this is the formulation of Kummer et al. [2]. With the logistic decision the probability of the positive class is
|
| (8.1) |
where and are fitted by logistic regression for every candidate, the analogue of linear scaling for classification, and the loss is the cross-entropy. The parameters inside can be tuned together with and by L-BFGS on the cross-entropy, applied to the best offspring as in section 3.2.5. Problems with more classes are solved one class against the rest. The decision boundary is in both cases an equation, or .
8.2.2 Goal-oriented projections
A projection maps every sample to features , , usually for a map. SymbolicTransformer represents the features as the genes of a multi-gene individual (section 4.2.2) and evaluates the individual by a cost of the feature matrix :
- Sammon
-
the Sammon stress [86] between the distances of the standardized inputs and the distances of the features, after a common scaling of the features; the map preserves the structure of the data;
- Fisher
-
the inverse of Fisher’s criterion [87], the ratio of the within-class to the between-class scatter of the features; the map separates the classes;
- kNN
-
the leave-one-out error of a five-nearest-neighbor classifier in the feature space; the map separates the classes locally;
- target
-
one minus the of a linear regression of a target variable on the features; the features make a quality predictable by a linear soft sensor;
or any user-defined function of . A cost per distinct input variable (variable_penalty) adds pressure toward maps that use few variables, so the projection selects variables while it constructs features.
In a nutshell: Classifiers and projections
- A symbolic classifier evolves a decision function; the sign decision with balanced error gives critical equations, the logistic decision (8.1) with cross-entropy gives probabilities.
- A goal-oriented projection (algorithm 8.1) evolves explicit features that minimize a cost encoding the goal: Sammon stress, Fisher criterion, kNN error, or the error of a linear soft sensor.
- A variable penalty makes the projection select variables.
- Both return equations that can be read, checked and evaluated without the software that found them.
8.3 Using it in eqdisco
SymbolicClassifier(decision="logistic", class_weight=None, optimize="none", ...)
- decision
-
"logistic" (probability , cross-entropy) or "sign" (critical equation , balanced error).
- class_weight
-
"balanced" reweights the classes; optimize="lbfgs" tunes the parameters of the best offspring on the cross-entropy.
- Results
-
equation_ (the decision function), equations_ (one per class for multi-class problems), classes_, predict, predict_proba, decision_function.
- Related
-
SymbolicTransformer(n_components=2, goal="sammon", variable_penalty=0.0, ...) with equations_, transform, cost_; datasets.make_runaway.
8.4 Examples
A runaway criterion. 800 operating points of a cooled exothermic reactor, with coolant temperature , initial concentration and heat-transfer capacity , are labeled by the Semenov criterion; as in an Arrhenius plot, the temperature enters as . A critical equation and a logistic model are evolved on 500 points:
funcs = ("add", "sub", "mul", "div", "log") crit = eq.SymbolicClassifier(population_size=300, generations=30, decision="sign", functions=funcs, selection="double_tournament", random_state=0).fit(Xtr, ytr) prob = eq.SymbolicClassifier(population_size=300, generations=30, decision="logistic", functions=funcs, optimize="lbfgs", parsimony=0.002, random_state=0).fit(Xtr, ytr) print("critical equation:", eq.simplify.simplify(crit.equation_), "| test accuracy", crit.score(Xte, yte)) print("logistic model: ", eq.simplify.simplify(prob.equation_), "| test accuracy", prob.score(Xte, yte))
The critical equation classifies 94.0% of the 300 test points correctly, the logistic model 98.3%. Figure 8.2 shows the two boundaries in the plane of coolant temperature and heat-transfer capacity at mol/m: both bend in the direction of the Semenov criterion: a higher coolant temperature requires a larger cooling capacity. The evolved expressions are accurate but not the Semenov formula itself, because the function set lacks the exponential and many expressions describe the same boundary within the range of the data; constraining the search by the known dimensionless groups (chapter 9) is the remedy when the physical form is wanted. The parameter study flips a share of the training labels: with 0, 5, 10 and 20% label noise, the logistic model reaches 97.9%, 98.5%, 96.6% and 94.6% accuracy on the clean labels, so moderate noise is absorbed by the probabilistic loss.
Open in ColabExample plot_26_runaway_classifier.py in the gallery
A map of the wine data. The wine data [8] contain 13 chemical measurements of 178 wines from three cultivars. Two symbolic features are evolved with the Fisher goal and a small variable penalty:
st = eq.SymbolicTransformer(n_components=2, goal="fisher", population_size=250, generations=30, functions=("add", "sub", "mul", "div", "log"), variable_penalty=0.002, feature_names=names, random_state=0) Z = st.fit_transform(X, y) for k, e in enumerate(st.equations_): print(f"z{k} =", e)
The features are
and use five of the 13 variables. The three cultivars form three compact, well separated groups in the map, while the first two principal components of all 13 standardized variables show overlapping groups (fig. 8.3). The features name the chemistry that separates the cultivars: flavanoids, proline and color intensity. The parameter study compares three goals without the variable penalty: the Fisher and the kNN goal give different maps from the same eight variables, and the Sammon goal, which ignores the classes, gives a map from seven variables in which the classes are visible but less separated.
Open in ColabExample plot_27_goal_oriented_projection.py in the gallery
Features for a soft sensor. Twenty correlated absorbances imitate a spectral analyzer; the quality depends nonlinearly on three of them. Two features are evolved with the target goal on 300 samples:
st = eq.SymbolicTransformer(n_components=2, goal="target", population_size=250, generations=30, functions=("add", "sub", "mul", "div", "log"), variable_penalty=0.002, feature_names=names, random_state=0) Z = st.fit_transform(X[:300], quality[:300]) print([str(e) for e in st.equations_], "cost", round(st.cost_, 4)) from sklearn.linear_model import LinearRegression # noqa: E402 lin = LinearRegression().fit(Z, quality[:300]) print("test R2 of the linear soft sensor on the two features:", lin.score(st.transform(X[300:]), quality[300:]))
The features and use five absorbances, and a linear model of the two features predicts the quality of 100 test samples with (fig. 8.4). The variable penalty trades accuracy for parsimony: penalties of 0, 0.002, 0.01 and 0.05 lead to features with 5, 4, 3 and 3 variables and a test of 0.972, 0.942, 0.929 and 0.928.
Open in ColabExample plot_28_soft_sensor_projection.py in the gallery
8.5 Further reading
Kummer, Varga and Abonyi [2] derive thermal runaway criteria by genetic programming and compare them with the classical criteria of process safety. Kulcsár et al. [4] and Dörgő, Kulcsár and Abonyi [3] develop GP-based visualization and goal-oriented dimension reduction for process monitoring and soft sensor design. Sammon [86] introduced the stress function of nonlinear mapping, and Borg and Groenen [88] treat multidimensional scaling in depth. Fisher’s criterion goes back to his analysis of the iris data [87].