\section{Introduction}

Progress in advanced materials, from lightweight composites to biomedical technology, relies on understanding the relationship between the structure and properties of a material. In addition to the chemical composition and crystalline lattice, strain fields caused by defects also regulate material properties. Therefore, the detection and characterization of strain and its relation to the type and concentration of defects in the crystal at the nanoscale is an essential, albeit challenging task.

\begin{figure*}[t]
\includegraphics[width=1.\textwidth]{F1.pdf}
\caption{\label{fig:f1}Ptychographic topography acquisition scheme. Step 1) focused beam: sample alignment and diffraction peak detection from non-strained crystal region using microscope, focusing optics and 2D detector along the diffracted beam. Focusing optics includes Fresnel zone plate (FZP), central stop (CS) and order-sorting aperture (OSA). Step 2) parallel beam: ptychographic topography with parallel coherent beam.  A pinhole is scanned after the sample and far-field patterns are recorded with the detector along the forward direction. Note: the two steps are performed consecutively.}
\end{figure*}

Transmission electron microscopy (TEM) provides imaging of crystalline defects with atomic spatial resolution. However, due to the limited penetration depth of electrons, invasive sample preparation of thin sections is required, which can modify the strain fields to be analyzed \cite{1Hytch2014}. X-ray diffraction, on the other hand, is a non-invasive alternative which is sensitive to atomic displacements \cite{2Hrauda2011}. X-ray topography (XRT) \cite{3Ramachandran1944} has been routinely used for imaging the defect microstructure in the micrometer- to centimeter-sized crystals based on the diffraction contrast. In XRT, the image contrast comes from variations in the crystal lattice spacing and/or orientation, with the resolution limited by the detector pixel size.

To achieve higher spatial resolution with X-rays, X-ray focusing optics were introduced, as for example in Laue X-ray micro-diffraction \cite{4Ice2009}. Here, the diffraction patterns are obtained with a polychromatic X-ray beam and each diffraction spot comes from a different crystalline plane. The peak position depends on the average crystal orientation and unit cell parameters, while the width provides information on the strain gradient within the illuminated volume. Therefore, any change in peak positions and/or widths is the footprint of a specific strain field in the crystal caused by the presence of particular defects or lattice distortions. In such experiments, spatial resolution is achieved by focusing the beam and raster scanning the sample at different positions \cite{5Maas2009}. Monochromatic X-ray diffraction microscopy in full field \cite{6Simons2015} and scanning mode \cite{7Etzelstorfer2014}, \cite{8Chahine2014} have also been able to reveal the strain field in crystalline samples with the spatial resolution limited by the focusing lens.

With advancements in synchrotron brilliance and degree of spatial coherence, probing individual crystalline defects like dislocations became possible \cite{9Jacques2011}. Coherent X-ray diffraction microscopy has enabled nanometer spatial resolution beyond focusing optics limitations \cite{10Miao2015}, \cite{11Pfeiffer2018}. Bragg coherent diffraction imaging (BCDI) is based on measuring the far-field diffraction patterns of a fully illuminated crystal placed in the Bragg condition and subsequent application of a phase retrieval algorithm for image reconstruction. Thus, BCDI provides 3D maps of the atomic displacement field within a small, isolated nanocrystal with a spatial resolution of a few tens of nanometers \cite{12Pfeifer2006}. On the other hand, ptychographic methods, based on measuring a series of diffraction patterns at a set of overlapping areas \cite{13Rodenburg2007}, enable the application of coherent methods to larger crystalline specimens. Bragg ptychography is also capable of imaging strain; however, the strict requirements on the specimen translation and beam stability make the technique difficult to apply, especially in 3D \cite{14Godard2011a}. Bragg projection ptychography \cite{15Hruszkewycz2017} has more relaxed stability requirements but due to the divergence of the incoming beam the method is not working for crystals with lattice displacements within the scattering plane. In such cases, it is not always the same part of the convergent incoming beam that is diffracted, contradicting the hypothesis of a constant probe, as discussed in \cite{16Tsai2016}. This reduces the robustness of the image reconstruction in Bragg ptychography.

Taking advantage simultaneously of the high strain sensitivity, large field of view, and simplicity of X-ray topography, as well as the high spatial resolution of X-ray ptychography, we propose a new X-ray imaging technique, ptychographic topography, for robust and flexible strain field imaging in extended crystalline samples with high spatial resolution. This method exploits the high strain sensitivity provided by a parallel, monochromatic and coherent incident beam in combination with the concept of tele-ptychography \cite{16Tsai2016} to reconstruct the exit wave field a few millimeters downstream of the sample. Subsequent numerical backpropagation of the reconstructed wave field to the sample position provides the exit wave after parallel X-rays propagate through the crystal. This new approach offers straightforward reconstructions, even in the case of complicated strain fields, with the resolution not limited by lenses.

In this paper, we describe the application of this technique to strain mapping of InSb micro-pillars that were uniaxially compressed up to the plastic deformation regime. The strain field is visualized in two different configurations of ptychographic topography, in forward and diffraction directions. The advantages and limitations of both configurations are explained and the effect of dynamical diffraction on the observed results is discussed.

\begin{figure*}[t]
\includegraphics[width=1.\textwidth]{F2.pdf}
\caption{\label{fig:f2}Mechanical deformation of InSb micro-pillars. (a) SEM image of the pillar and its pedestal after uniaxial compression along the [2 1 3] crystallographic direction to reach the plastic deformation regime (applied force of 2.35 mN). Scale bar: 5 µm.  (b) Force-displacement curve of the compression test that confirms that the sample was plastically deformed.}
\end{figure*}

\section{Methods}

\subsection{The principle of ptychographic topography}

The concept of ptychographic topography consists of placing the crystal in diffraction condition for specific crystallographic planes and performing ptychographic scans in forward (or diffraction) direction with a pinhole scanned several millimeters after the sample to reconstruct the exit wave field at the pinhole position. The resulting image is then numerically back propagated to the crystal position and is sensitive to lattice imperfections.

As shown in Fig.~\ref{fig:f1}, first, the sample's region of interest is selected via an auxiliary visible light microscope. While setting up the experiment, we used a focused beam configuration to illuminate a region of the sample which has no crystalline defects, and to find and center the diffraction peak on the detector placed along the diffracted beam as shown in the step 1 in Fig.~\ref{fig:f1}.

To perform the ptychographic topography measurement, we switch to the parallel beam configuration (step~2 in Fig.~\ref{fig:f1}). A pinhole is placed a few millimeters after the sample and is scanned perpendicular to the beam, providing the sufficient overlap of the pinhole area at neighboring scan positions required for ptychographic reconstructions \cite{16Tsai2016}, \cite{17Verezhak2018}. The diffraction patterns are recorded with a 2D detector downstream of the pinhole along the forward (or diffraction) direction in the far field and are used for the reconstruction of the wavefront at the pinhole position using ptychographic phase retrieval. Numerical backpropagation to the sample plane then results in an image of the sample sensitive to the lattice displacements caused by defects.

By rotating the sample and performing measurements at different angular steps close to a diffraction condition, quantitative information about the amount of strain and lattice rotations can be obtained. To recover all components of the three-dimensional displacement field one would need to measure at several non-equivalent diffraction peaks.

\subsection{InSb micro-pillars upon uniaxial compression}

Focused ion beam (FIB) milled InSb single-crystalline cylindrical micro-pillars, 2 µm in diameter and 6 µm in height on cylindrical pedestals, were used to demonstrate the potential of the method. A scanning electron microscopy (SEM) image of such a pillar is shown in Fig.~\ref{fig:f2}(a). Two equivalent pillars (S1 and S2) were used for ptychographic topography in order to show reproducibility. The results from sample S1 are presented below while those from sample S2 are shown in the Supplemental Material.

The micro-pillars were uniaxially compressed with a dedicated micro-compression device \cite{35Kirchlechner2011} along the pillar vertical axis that corresponds to the [2 1 3] direction, favoring only one dislocation slip system \cite{18Thilly2012}. The pillars were compressed up to a force of 2.35 mN, corresponding to the plastic regime, which led to an irreversible reduction of the pillars height of about 300 nm (i.e. about 5\% of their initial height). This can be seen as a residual displacement after unloading at the force-displacement curve shown in Fig.~\ref{fig:f2}(b). In addition, slip traces (pointed to with red arrows in Fig.~\ref{fig:f2}(a)) are visible at the pillar surface. More information about sample preparation can be found in the Supplemental Material.

\section{Ptychographic topography in forward and diffraction geometry}

\begin{figure*}[t]
\includegraphics[width=1.\textwidth]{F3.pdf}
\caption{\label{fig:f3}Ptychographic topography of InSb micro-pillars in forward and diffraction directions. Schemes of ptychographic topography in (a) forward and (d) diffraction direction with sample orientation (sample not to scale). (b) Amplitude of the image reconstruction obtained in forward direction at the rocking angle of 0.03°. Red arrow shows strained region on the image. (c) Forward direction rocking curve around  the (2 0 2) diffraction peak measured with focused beam at the pedestal position.  (e) Amplitude of the image reconstruction in diffraction direction at the rocking angle of 0.002°. (f) Rocking curve in diffraction direction around the (2 0 2) diffraction peak measured with focused beam at the pedestal position.}
\end{figure*}

We demonstrate the implementation of ptychographic topography in both forward and diffraction direction at the cSAXS beamline at the Swiss Light Source (SLS). In both cases, we first used the focused beam configuration with an illumination spot size of $\sim$100 nm in diameter. InSb samples were then brought to the (2 0 2) diffraction condition (similar to the geometry in \cite{19Jacques2013}) as shown in Fig.~\ref{fig:f3}(a) and Fig.~\ref{fig:f3}(d).

The region well below the pillar, i.e. the pedestal, was chosen for the diffraction peak alignment as a region without crystalline defects. The rocking curves were recorded with detectors placed both along the forward and the diffraction direction. The rocking curves obtained at the pedestal position are shown in  Fig.~\ref{fig:f3}(c) and  Fig.~\ref{fig:f3}(f). More details about experimental alignment are presented in the Supplemental Material.

For forward ptychographic topography, the setup was then switched to the parallel-beam configuration by removing focusing optics and placing a pinhole of $\sim$3.5 µm diameter 4.5 mm downstream the sample. Samples were rocked around the (2 0 2) diffraction peak while, at each rocking angle, the pinhole was scanned after the sample perpendicular to the incoming beam. The schematic of the described experiment is shown in  Fig.~\ref{fig:f3}(a). For more details see the Supplemental Material.

The second experiment was performed in the diffraction geometry, see schematic in  Fig.~\ref{fig:f3}(d) and the Supplemental Material. In this case, the 2 µm pinhole was placed at 2.2 mm downstream the sample in the diffracted beam direction and used for scanning. Samples were rocked around  the (2 0 2) diffraction peak and a ptychographic scan was performed at each rocking angle.

Ptychographic reconstructions were performed using 300 iterations of the difference map algorithm \cite{37Thibault2009} followed by 1000 iterations of a maximum likelihood refinement \cite{38Thibault2012} using the PtychoShelves package \cite{39Wakonig2020}. The resulting ptychographic reconstructions with a pixel size of 21 nm (in forward geometry) and 30 nm (in diffraction geometry) were back-propagated to the sample position and followed by post-processing (phase offset and a linear phase wrap removal, vertical and horizontal spatial alignment) \cite{40Guizar-Sicairos2011}. We estimated the resulting spatial resolution using Fourier ring correlation \cite{25VanHeel2005} to be 29 nm in the forward direction (see Fig. S2 in the Supplemental Material).

\section{Strain and dynamical effects in InSb}

As mentioned above, the 2D ptychographic projections were taken at different angular positions in the vicinity of the InSb (2 0 2) diffraction peak. This reflection is in Laue diffraction geometry, in which the diffracted wave exits the crystal at the opposite surface to the incoming beam \cite{20Rodriguez-Fernandez2018}. The rocking curve was acquired with a focused beam in the forward direction at the pedestal position where we expect only negligible strain (Fig.~\ref{fig:f3}(c)). The curve shows increased intensity at angles just below the diffraction condition and exhibits an intensity drop at the diffraction angle. Such effect shows that dynamical scattering effects take place in this region of the crystal. This is expected as the pedestal is 10 µm thick and the extinction length of InSb at 6.2 keV and  (2 0 2) diffraction reflection is 4.98 µm, as estimated from \cite{21Authier2010}. Such effect is well-known as a dynamical diffraction effect \cite{22Zachariasen1968}, \cite{23Batterman1964} and it highlights the good crystallinity at the pedestal far away from the strained micro-pillar.

\begin{figure}[t]
\includegraphics[width=0.5\textwidth]{F4.pdf}
\caption{\label{fig:f4}Evolution of ptychographic topography of InSb micro-pillars in forward and diffraction geometry with the rocking angle around the (2 0 2) reflection. The rocking angle is shown in the top left corner of individual images. Left column: amplitudes of the image reconstruction obtained in forward direction. The image at the rocking angle of -3.5° is acquired far away from the diffraction condition and shows no strain features. Other images in vicinity of the diffraction condition show the strain feature. Right column: amplitudes of the image reconstruction obtained in diffraction direction, showing circular features and fringes of varying contrast.}
\end{figure}

Each projection of the ptychographic topography experiment in forward direction was reconstructed using single-probe mode \cite{24Thibault2013} in order to reconstruct the pinhole,  see Fig. S1(a). The amplitude (Fig.~\ref{fig:f3}(b)) of the ptychographic reconstruction clearly shows the pillar and pedestal shapes. At the bottom of the pillar and at the pillar/pedestal interface, a dark feature is visible, indicated by the red arrow in Fig.~\ref{fig:f3}(b). This feature is only visible in the vicinity of the diffraction peak angle (as shown in Fig.~\ref{fig:f4} for rocking angles 0.01-0.04°) and is not observed far away from the diffraction peak (as shown in Fig.~\ref{fig:f4} for a rocking angle of -3.5°). All projections can also be accessed in the Media S1. This feature corresponds to crystallinity imperfection or strain field present in the crystal that makes this part of the crystal diffract at slightly different angle. The resolution of the reconstructed amplitude image was estimated to be 29 nm by Fourier ring correlation \cite{25VanHeel2005}, as shown in Fig. S2.

It is also important to note that in ptychographic topography the amplitude provides higher contrast of crystalline imperfections compared to the phase reconstruction, as can be seen in Fig. S3 in the Supplemental Material. This can be understood as a result of the diffraction-based contrast, similar to the one in X-ray topography. Nevertheless, we note that the phase information is needed for the back propagation of the exit wave field from the pinhole to the sample position.

In the case of ptychographic topography in diffraction direction, the reconstruction improved taking into account a second incoherent mode, with an intensity distribution for the first and second modes of 77\% and 23\%, respectively (see in Fig. S1(b) and Fig. S1(c)). This is similar to what is observed with Bragg ptychography as the reconstructions are more difficult compared to conventional ptychography and sometimes require several incoherent modes. As the signal in the diffraction direction is often several orders of magnitude smaller than in the direct transmitted beam, there is less data available while the system might also have higher stability requirements, which affects the robustness of the reconstruction.

The resulting reconstruction along the diffraction direction (Fig.~\ref{fig:f3}(e)) contains no information at the top half of the images (black region in Fig.~\ref{fig:f3}(e)). This is due to the diffraction angle $\bm{2 \theta_B\sim52^{\circ}}$ at which those projections were recorded. At this angle, we see a projection of the whole pillar/pedestal assembly along the diffracted beam direction. In order to illustrate this effect, we calculated the projected thickness of the sample, including pillar and pedestal, along both forward and diffraction direction in our measurement geometry (see Fig. S4 in the Supplemental Material). The projected thickness of the sample, shown in Fig. S4(d) has a similar shape as observed in the image reconstructions along the diffraction direction and shows that the information of the whole pillar as well as the pedestal is encoded in the bottom half of the reconstructed image.

A very interesting feature can be seen in the ptychographic topography reconstructions obtained in diffraction geometry (see Fig.~\ref{fig:f3}(e)): two sets of circular fringes of varying contrast. These features strongly change with the rocking angle and more interferences appear as we go further away from the diffraction angle, as shown in Fig.~\ref{fig:f4}, right column. The projections at all rocking angles obtained by ptychographic topography in diffraction direction can be seen in Media S2.

The interpretation of these features is complicated as it can involve the simultaneous presence of different effects. First of all, the thickness variation of single-crystals can cause so-called Pendellösung fringes in the presence of dynamical scattering, i.e. if the crystal thickness is larger than the extinction length. This effect is widely observed in X-ray topography caused by thickness variations \cite{26Kato1959}. We believe that the thickness-based Pendellösung effect does not cause the observed fringes at the diffraction direction (Fig.~\ref{fig:f3}(e)) as the projected thickness variation in the diffraction direction does not show similar patterns or significant sudden thickness change at the base of the pillar. However, thickness-based Pendellösung effect can very well explain the appearance and the shape of the additional fringes in the region of the pedestal as we go further away from the diffraction peak, as shown in Fig.~\ref{fig:f4}, right column.

To confirm our hypothesis, we qualitatively simulated the absorption signal from the projected thicknesses using pencil-beam symmetrical Laue dynamical theory based on the Eq. 16 in Ref. \cite{27Punegov2016}. At some rocking angles, we were able to observe similarities between these fringes that appear further away from the diffraction condition with the simulated ones (reported in the Supplemental Material, Fig. S5). More detailed simulation, taking into account the non-symmetric Laue dynamical theory as well as non-pencil beam is required to further understand this phenomenon but is beyond the scope of this paper.

A second possible effect, which could not be properly taken into account in our simulations, is the possibility of additional destructive and constructive interferences that emerge due to the beam path differences caused by our large non-focused incident beam, so called Borrmann-Lehmann interference patterns \cite{28Mai1989}, \cite{29Lang1990}. This effect, which is also caused by dynamical scattering, could very well contribute to the observed fringes.

Finally, strain can also cause interference fringes. This effect is extensively studied with X-ray topography using different single crystalline specimens with different strain states \cite{30Bonse1969, 31Negishi2007, 32Chukhovskii1988, 33Novikov2010}. We believe that the fringes we observe with ptychographic topography in diffraction direction are mainly caused by the strain present in the crystal in combination with the interference effects caused by the shape, thickness and orientation of our sample. In addition, any interference fringes caused by sample size and shape are extremely sensitive to strain. The fringes symmetry, shape and number will change in the presence of characteristic strain or lattice imperfections \cite{29Lang1990}. This makes ptychographic topography in diffraction direction extremely sensitive to small crystalline imperfections and strain fields.

The stress-displacement curve in Fig.~\ref{fig:f2}(b) shows that there has been a 5\% irreversible deformation in the total height of the pillar, which is a sign of considerable plastic deformation in the pillar. This was confirmed by SEM images performed after the compression experiment, like that shown in Fig.~\ref{fig:f2}(a), which reveal the presence of slip traces, a typical signature of plastic deformation in this system \cite{18Thilly2012}. Furthermore, a large amount of strain most probably in the form of lattice rotations is produced in addition to the slip planes. This was confirmed by performing angular rocking scans around the (2 0 2) diffraction condition with the focused beam at different positions along the pillar and recording the intensity with the 2D detector along the diffraction direction, see Fig. S6. The rocking curve at the pedestal is narrow, as expected for a perfect crystal, and the curve becomes broader and significantly shifted as the beam impinges higher on the pillar. Additionally, scanning diffraction microscopy performed with the focused beam at a fixed angle close to the (2 0 2) diffraction condition also revealed strained areas within the pillar and at the pillar/pedestal interface, as shown in Fig. S7.

\section{Discussion}

In the ptychographic topography demonstration described here, we observe deviations from perfect crystallinity due to strain and lattice rotations especially at the bottom part of the pillar, both along the forward and the diffraction directions. With a parallel incident beam, it is clear that a certain degree of crystallinity within the sample is needed in order to observe deviations from that crystallinity, and this is the case at the bottom part of the pillar. On the other hand, on the top part of the pillar the strain affects most of the bulk of the sample, in such a way that only a small sample volume diffracts at a given angle. Hence, for heavily strained crystals, the diffraction signal is too weak to be reconstructed in the diffraction geometry, and the diffraction-based contrast is too low in the forward geometry. Nevertheless, the advantage of having a parallel beam is that the technique can potentially have a very high sensitivity to strain in a crystalline specimen. As the contrast is the same as in X-ray topography, we expect that the strain sensitivity could be as good as $\bm{\Delta d/d=1e^{-7}}$, where $\bm{d}$ is the lattice spacing of the crystal and $\bm{\Delta d}$ is a change in $\bm{d}$ over the initial length.

For illustration of reproducibility, the same ptychographic topography measurement was conducted along the (2 0 2) diffraction direction on a similar pillar, sample S2, that had also been previously mechanically compressed, see Fig. S8. The reconstructed amplitudes along the diffraction direction show many similarities in the type, contrast and spacing of the fringes, although their exact arrangement is not identical and could be explained by different strain and/or lattice rotation distribution inside the pillar. Sample S2 was also investigated by ptychographic topography at  the (2 2 0) Bragg condition along the forward direction (see Fig. S9), revealing at some angles a crystalline imperfection feature (Fig.~S9(b)) similar to that observed in sample~S1 at  the~(2~0~2) diffraction condition (Fig.~\ref{fig:f3}(b)). At a different angle, other interesting features were also observed (Fig. S9(c)). However, the exact determination of the type of defects seen here will require further studies.

In this paper, we report a new robust strain imaging technique, ptychographic topography, as well as its realization in both forward and diffraction direction. This new approach allows visualization of the exit wave after propagation of a beam through the crystal with high resolution (at least 29 nm as achieved in the present work) and both absorption and phase contrast. In the forward direction, we obtain a superposition of the strained areas within the sample and the transmission image of the specimen, which is useful to study strain in a crystal in context with its surrounding material, regardless of its structural nature. In the diffraction direction, we observed fringes caused by dynamical scattering effects due to strain and geometrical features in the sample both in absorption and phase contrast.

The use of a parallel beam offers opportunities for very high strain sensitivity when used on samples that present a sufficient degree of crystallinity. Signal-to-noise in ptychographic topography could be improved for such highly strained samples with the use of a coherently illuminated condenser designed to produce a flat illumination for X-ray transmission  microscopes \cite{34Jefimovs2008}. With the currently available coherent flux in 3rd generation synchrotron sources like the SLS, we estimate that coherent flux could be improved by about a factor of 10 already now by using this technology. With upcoming upgrades of synchrotron storage rings, an additional significant increase in the coherent flux will be possible.

\begin{acknowledgments}
We acknowledge the Paul Scherrer Institute, Villigen, Switzerland for provision of synchrotron radiation beamtime at the cSAXS beamline of the SLS. This work was supported by the SNF grant No 200021L\_169753, ANR-16-CE93-0006, by “Investissement d'Avenir” (LABEX INTERACTIFS, ANR-11-LABX-0017-01) and by Nouvelle Aquitaine Region / European Structural and Investment Funds (ERDF No P-2016-BAFE-94/95). M.V. was supported by the European Union's Horizon 2020 research and innovation program under the Marie Skłodowska-Curie grant agreement No 701647. K.W. acknowledges the support by the SNF grant  No~200021\_166304. Authors thank M. Guizar-Sicairos, P.~O.~Renault, T. Sadat, D. Le Bolloc'h, B. Kedjar and F.~Mignerot for fruitful discussions.
\end{acknowledgments}

\providecommand{\noopsort}[1]{}\providecommand{\singleletter}[1]{#1}%

\section{Media}

Media S1. Ptychographic topography of InSb micro-pillar in forward direction at different angular positions of the rocking curve around the (2 0 2) diffraction peak.

Media S2. Ptychographic topography of InSb micro-pillar in diffraction direction at different angular positions of the rocking curve around the (2~0~2) diffraction peak.

\section{Experimental details}

The samples were prepared by ion milling with Ga+ focused ion beam (FIB) on an InSb single-crystalline wedge with known orientation in the form of a series of cylindrically shaped micro-pillars on cylindrical pedestals. The pillars dimensions are 2 $\mu$m in diameter and 6 $\mu$m in height. The pedestals dimensions are 10 $\mu$m in diameter and 10 $\mu$m in height. Two equivalent pillars (S1 and S2) were investigated by ptychographic topography for reproducibility. The results from pillar S1 are shown in the main text while those from pillar S2 in the Supplemental Material.

The samples were uniaxially compressed with a dedicated micro-compression device equipped with a diamond flat punch \cite{35Kirchlechner2011}. The compression axis was chosen along to the [2 1 3] direction that corresponds to the pillar vertical axis. The pillars were compressed up to a force of 2.35 mN and the compression tip was retracted.

The ptychographic topography setup was built at the cSAXS beamline at the SLS. For the focused beam configuration, we used a Fresnel zone plate of 200 $\mu$m diameter and 90 nm outermost zone width upstream of the sample with a central stop of 60 $\mu$m diameter and an order-sorting aperture of 30 $\mu$m diameter. Such optical layout allowed achieving an illumination spot size of $\sim$100 nm in diameter. InSb samples were then brought to the (2 0 2) diffraction condition at 6.2 keV, corresponding to a Bragg angle  $\bm{\theta_B=25.88^{\circ}}$ and an orientation angle of the sample $\bm{\omega \sim 7^{\circ}}$, as shown in Fig.3(a) and Fig.3(d) (main text). The diffraction peak alignment was performed with the beam at the pedestal position. The rocking curves were recorded with an Eiger 500K detector placed along the diffraction direction and a \mbox{Pilatus 2M} detector along the forward direction.

For ptychographic topography in forward geometry we used the parallel-beam configuration, as shown in Fig.1 (main text). A pinhole of 3.5 $\mu$m diameter was placed on a 2D piezo translation stage 4.5 mm downstream the sample in forward direction. Samples were rocked around the (2 0 2) diffraction peak in a range of $\pm$0.7$^{\circ}$ with a step size of 0.01$^{\circ}$. At each rocking angle, the pinhole was scanned after the sample perpendicular to the incoming beam with a step size of 0.5 $\mu$m and 0.2 s exposure time covering a field of view of 12 x 12 $\mu$m$^2$. The scanning positions followed a Fermat spiral pattern \cite{36Huang2014}. The diffraction patterns were recorded with a Pilatus 2M detector, placed at 7.338 m from the sample in the forward direction.

In the diffraction geometry, using the parallel-beam configuration, a 2 $\mu$m pinhole carried by the 2D piezo motors was placed at 2.2 mm downstream the sample in the diffracted beam direction and used for scanning. The smaller, 2 $\mu$m pinhole was used for appropriate sampling for ptychography at 2.171 m. The data was acquired with the Eiger 500K detector, placed at 2.171 m along the diffracted beam direction. Samples were rocked around the (2 0 2) diffraction peak in a range of $\pm$0.02$^{\circ}$ with an angular step of 0.002$^{\circ}$. Ptychography scans were performed with a step size of 0.5 $\mu$m and 0.2 s exposure time following a Fermat spiral pattern \cite{36Huang2014}.

\begin{figure*}
\includegraphics[width=1.\textwidth]{SF1.pdf}
\caption{\label{fig:sf1}Resulting ptychographic reconstructions of the pinholes: a) in forward geometry, b)  and c) in diffraction geometry, 77\% and 23\% contribution respectively. Scale bar: 2 $\mu$m. Note: phase ramp was removed for clarity of the images. Phase ramp is an intrinsic degree of freedom in ptychographic reconstructions, as discussed in \cite{40Guizar-Sicairos2011}.}
\end{figure*}

\begin{figure*}
\includegraphics[width=0.8\textwidth]{SF2.pdf}
\caption{\label{fig:sf2}Resolution estimated using Fourier ring correlation of two individually reconstructed repeated scans in forward ptychographic topography. The region taken into account for the estimation comes from within the sample at the bottom of the pillar and beginning of the pedestal, where strain features are observed.}
\end{figure*}

\begin{figure*}
\includegraphics[width=0.9\textwidth]{SF3.pdf}
\caption{\label{fig:sf3}(a) Amplitude and (b) phase of the image reconstruction obtained in forward direction at the rocking angle of 0.03$^{\circ}$. (c) Amplitude and (d) phase of the image reconstruction in diffraction direction at the rocking angle of 0.002$^{\circ}$.}
\end{figure*}

\begin{figure*}
\includegraphics[width=0.9\textwidth]{SF4.pdf}
\caption{\label{fig:sf4}Simulations of the sample thickness along the beam path: (a) amplitude of forward and (c) diffraction direction ptychographic reconstruction, (b) projected sample thickness along the forward direction, (d) projected sample thickness along the diffraction direction.}
\end{figure*}

\begin{figure*}
\includegraphics[width=1.\textwidth]{SF5.pdf}
\caption{\label{fig:sf5}Pendellösung fringes simulations in symmetrical Laue-case with the pencil beam: (a) rocking curve around the (2 0 2) diffraction peak, acquired with the focused beam at the pedestal position. (b)-(d) Amplitudes of the ptychographic topography reconstructions in diffraction direction at specified rocking angles $\bm{\Delta \omega}$. (e)-(g) Simulated amplitudes based on pencil-beam symmetrical Laue dynamical theory, the Eq. 16 from [27] with (f) being at diffraction angle and (e) and (g) being at $\bm{\Delta \omega}$ from the diffraction angle.}
\end{figure*}

\begin{figure*}
\includegraphics[width=1.\textwidth]{SF6.pdf}
\caption{\label{fig:sf6}Intensity of the (2 0 2) diffraction peak integrated over all pixels of the detector as a function of rocking angle, acquired with focused beam: (a) comparison of integrated intensity on the diffraction peak at four characteristic positions (at the pedestal, bottom, middle and top of the pillar), (b) the (2 0 2) diffraction peak evolution along the pillar and pedestal height. Position of 0 height correspond to the pillar/pedestal interface.}
\end{figure*}

\begin{figure*}
\includegraphics[width=1.\textwidth]{SF7.pdf}
\caption{\label{fig:sf7}Scanning X-ray microscopy of the S1 sample with the focused beam of 100 nm diameter, scanning step size 100 nm, 0.1 s acquisition time. Sample is scanned at the rocking angle of -0.05$^{\circ}$. (a) Intensity integrated over the central area around the beam of the forward detector. (b) Intensity integrated over the entire area of the detector at diffraction direction. (c) Dark field image obtained by masking out only the peak from the perfect crystal (pedestal position 1) with characteristic diffraction patterns in (e). (d) Dark field image obtained by masking out the peak from the perfect crystal and using the ROI shown in (e) as a red rectangle. This ROI corresponds to the mild deformation, without taking into account very strong deformation in the form of peak splitting. Scale bar in (a)-(d): 1 $\mu$m. Scale bar in (e): 34.55 $\mu$m$^{-1}$.}
\end{figure*}

\begin{figure*}
\includegraphics[width=1.\textwidth]{SF8.pdf}
\caption{\label{figs:f8}Ptychographic topography results on the sample S2 shown for reproducibility purpose: (a) force-displacement curves of the compression test for samples S1 and S2. The mechanical curve for S2 has been artificially shifted for better comparison with the one for S1. Amplitude of the ptychographic topography reconstruction in the diffraction direction for the sample (b)~S1 and (c) S2. Scale bar: 2 $\mu$m.}
\end{figure*}

\begin{figure*}
\includegraphics[width=1.\textwidth]{SF9.pdf}
\caption{\label{fig:sf9}Ptychographic topography on the sample S2 in the forward direction. (a) Rocking curve with the focused beam at the center of the pillar position around (2 2 0) Bragg reflection. (b) and (c) amplitude of the ptychographic topography reconstruction in the forward direction at the right and left shoulder of the Bragg peak. Two features are visible, shown with arrows in (b) and (c). The feature shown with the red arrow in (b) is similar to the one observed in sample S1.}
\end{figure*}

\clearpage

\providecommand{\noopsort}[1]{}\providecommand{\singleletter}[1]{#1}%


\section{Introduction}

SVM models are one of the best performing predictive models in machine learning, as they can effectively separate data into differing labels while maximizing the margin of the decision function.
Despite the progress achieved with other predictive methods such as deep learning, SVM models remain competitive and compelling in areas likes healthcare, where data will never reach
the large volumes required to train deep neural networks models.
While there is extensive research on SVMs, there is little to no information about finding ways to use the margin to change labels of new datapoints.
If we are given a  datapoint which, based on the decision function of the SVM, is most likely an \textit{undesirable} outcome (e.g., patient at risk of cardiovascular disease), or a datapoint for which we know the class (e.g, a sick patient), we would like to use the SVM boundary to move the datapoint to a \textit{desirable} outcome. Moving the datapoint can be complex and challenging depending on the features themselves as well as the shape of the SVM boundary.
Having this functionality would be relevant to many applications such as medical care, customer satisfaction, and environmental protection.

In this paper, we tackle the question of
``What do I do with the prediction?''
or ``How do I use a prediction model to act upon an undesirable label?''.
Previous research (e.g., \cite{eloviciB03,liu00multilevel,Ras2002G,Ras2003IIS,trepos05}) has
defined {\em actionability} as giving a recommendation of the \textit{easiest} way for a user to change an "unsatisfactory situation" based on a set of rules.
Unfortunately,
while rule-based classifiers allow for interpretability of the feature decisions, they are not the best performing models.
Additionally, previous papers focus on the framework of defining costs of an action in rule-based classification and how to maximize gain for a given cost. In the context of an SVM, this part of the problem will be slightly simpler as we can assume we are in a Euclidean space and thus we will frame our problem as a minimization of a weighted Euclidean distance. To our knowledge, we are the first to propose a general approach for actionability, in the context of support vector machines.

We illustrate our approach with \textit{atherosclerosis}, a serious disease of the arteries characterized by the deposition of plaques of fatty material on their inner walls, causing serious complications like a reduced blood flow in the big arteries, which increases the risk for heart attack and stroke.
Atherosclerosis has no known cure, however, prevention can play an important role in reducing patient risk, by keeping under control the main risk factors: high cholesterol and triglycerides, tobacco consumption, diabetes, high BMI, high blood pressure, and lack of activity. The way these factors intertwine is unknown, and hoping to reduce all the factors at once is unrealistic for most patients.
In atherosclerosis, as in many other health problems, one challenge  that a physician might face is to make important decisions about what should be done to cure a patient or reduce his risk of a specific disease.
The purpose of actionability here is to suggest {\em actions} that are fine-grained modifications of some {\em actionable} risk factors  in order to decrease the risk of atherosclerosis in patients.

We define an action as a change in the value of some feature (e.g., weight of a patient, or his tobacco consumption). Our approach focuses on a framework where a datapoint is framed as a vector of numerical features. We will then use the vector to predict an outcome based on the given SVM model. The goal will be to minimize the \textit{weighted distance} of the action that shifts the features to a point along the margin of the desired outcome. The weighted distance will be some combination of the distance travelled in each feature multiplied by a weight that represents the challenge of moving each feature, that is how  actionable each feature is (e.g., how hard it is to stop smoking). The \textit{weight vector} used to weight these distances is decided by the user. An example of weighting, say in the application of assessing the risk of atherosclerosis, may be that the amount of alcohol consumed (easier to change) has a lower weight while BMI (harder to change) has a higher weight. The action returned will then be the change in each actionable feature required to achieve the desired outcome.

Through the lens of actionability, we also investigate  \textit{interpretability},  the ability to explain machine learning models in a form that is understandable to a human \cite{Doshi17}. By setting the weight vector to all 1's, we  use the recommended actions to rank-order the pertinent features
in the model.

In Section \ref{related}, we describe the related work on actionability. In Section \ref{set up}, we describe the problem set up. In Section \ref{linear SVM}, we explore the linear SVM solution.
In Section \ref{non-linear SVM}, we extend the solution to fit the non-linear SVM problem. In Section \ref{Experiments}, we test the model on both simulated data and medical data. In Section \ref{conclusion}, we discuss the results and conclusions we can make about the algorithm.

\section{Related Work}
\label{related}

In many real-world applications,
a domain expert can act upon a prediction in many ways, but ultimately would like to use the prediction and the model  to decide which actions to take.
This type of knowledge falls under the umbrella of actionability, an important but widely unexplored concept in machine learning.
A related topic is the interpretability of machine learning models, for which there is a surge in research interest from the community (e.g., \cite{NIPS2017_6993,lei-etal-2016-rationalizing,lime2016}).  Understanding why a model is making a prediction
increases our confidence in using the models, helps detect bias, and communicate/explain predictions to other  parties.
While interpretability aims to answer the question ``Why did the model make this prediction?'', actionability
gives  ways to act upon those models and their predictions and address the related key question  of
``What to do now?''.

Most research on learning actionable knowledge goes back to rule-based models,
that can be classified into three main lines of research:
(1) use of predefined set of simple actions that are mapped to classification rules or deviations \cite{AdomaviciusT1997,EloviciSK03,JiangWTF05,Shapiro94}; (2)  sift through a set of association or subgroup discovery rules \cite{Gamberger02,Lavrac2002ICMLWorkshop,Lavrac02,Liu01}  to identify descriptive actionable rules
of the form $\text{Condition} \to \text{Class}$, where {\em Condition} is a conjunction of features describing the target {\em Class}; (3) elaborate actions by comparing pairs of classification rules with contradicting classes but the same values for all stable attributes \cite {Ras2002G,Ras2003IIS, Ras2005,Tsay2005} to generate action rules.
Given an unsatisfactory situation, the work in \cite{trepos05,Trepos2011BuildingAF} discovers a set of action recommendations
to improve that situation using classification rules.
Finally, actionability is formalized as a case-based reasoning problem in \cite{Yang2002,Yang2003}. Given an example to reclassify, the authors propose to search for the closest cases with the desirable class label, among training examples,  centroids of the clusters of the opposite class, or
SVM support vectors. Choosing the closest support vector will be used as a baseline to compare our proposed approach.
For a detailed literature survey on rule-based actionability see \cite{Trepos2011BuildingAF}.

\section{Presenting the SVM Actionability Problem}
\label{set up}

Our model learns how to move a datapoint from the undesirable class to the desirable class. We will provide our general framework for both a linear and non-linear SVM. For a given linear SVM model, we have a decision boundary given by $\mathbf{v}^T\mathbf{x} + b = 0$. Where $\mathbf{x} \in \mathbb{R}^d$ (the input space). We choose to use vector $\mathbf{v}$ here as the decision vector because we will later use $\mathbf{w}$ for the  weight vector used in the actionability problem. In the case of a non-linear SVM, the decision boundary is given by $\mathbf{v}^T\phi(\mathbf{x}) + b = 0$, where $\phi$ is the feature expansion used for the SVM.

Additionally, we are given an initial point $\mathbf{x_0}$ for which we predict an unfavorable result, or for which we know the label is not desirable (say with label $y_0$). Note, for this formulation, we require that for any label $y$, $y \in \{-1, +1\}$. We are also given a weight vector $\mathbf{w}$ which symbolizes the weight vector of the \textit{loss} of acting on a feature (ranging between $0$ and $1$). This means the higher $w_i$ is, the harder it is to change that feature (i.e. it is \textit{static}) and the lower $w_i$ is, the easier it is to change that feature (i.e. it is \textit{actionable}). We assume that all features are normalized between $-1$ and $1$ so that we can also standardize the weight vector and the distance formulation problem.

The goal will be to find the nearest point $\mathbf{x_n}$ on the other side of the SVM boundary (including the margin). In other words, for the case of a linear SVM, the output is shown in Equation \ref{Linear Output}.

\begin{equation}
    \label{Linear Output}
    \begin{gathered}
        min_{\mathbf{x_n} \in \mathbb{R}^d} dist(\mathbf{x_0}, \mathbf{x_n}) \\ \mbox{such that }\mathbf{v}^T\mathbf{x_n} + b + y_0 = 0
    \end{gathered}
\end{equation}

where $dist(\mathbf{x_0}, \mathbf{x_n})$ is defined in Equation \ref{Weighted Distance}.
Equation \ref{non-linear Output} presents the case of a non-linear SVM.
\begin{equation}
    \label{non-linear Output}
    \begin{gathered}
        min_{\mathbf{x_n} \in \mathbb{R}^d} dist(\mathbf{x_0}, \mathbf{x_n}) \\
        \mbox{such that }\mathbf{v}^T\phi(\mathbf{x_n}) + b + y_0 = 0 \Longleftrightarrow \sum_{i=1}^{N} \alpha_i y_i K(\mathbf{x_i}, \mathbf{x_n}) + b + y_0 = 0
    \end{gathered}
\end{equation}

where $dist(\mathbf{x_0}, \mathbf{x_n})$ is once again defined in Equation \ref{Weighted Distance}, $N$ is the number of training points, $\mathbf{x_i}$ is a training point, $\alpha_i$ is the associated dual coefficient of training point $\mathbf{x_i}$, $y_i$ is the label for training point $\mathbf{x_i}$, and $K$ is the kernel function corresponding to the feature expansion $\phi$.

The function we are aiming to minimize is the weighted Euclidean distance between $\mathbf{x_0}$ and $\mathbf{x_n}$ in the \textit{original} feature space ($\mathbb{R}^d$). This is shown in Equation \ref{Weighted Distance}.
\begin{equation}
    \label{Weighted Distance}
    dist(\mathbf{x_0}, \mathbf{x_n}) = \left(\mathbf{w} \odot \left[\mathbf{x_0} - \mathbf{x_n}\right]\right)^T\left(\mathbf{w} \odot \left[\mathbf{x_0} - \mathbf{x_n}\right]\right)
\end{equation}
where $\odot$ is the Hadamard product, or element-wise multiplication.

\paragraph{Static Features}
Throughout this paper, we use the weight vector $\mathbf{w}$ to account for differing levels of actionable vs. static features. It is important to note, by making incredibly uneven weight values where some features have weights around $0.001$ while static features have weights at $1$, they will for all intents and purposes be static. This is the most interesting case for this paper. However, it should be noted that if we had a static variable such as age that cannot be moved at all, we could easily fix that variable. To do this, we can factor the static features into the intercept variable $b$ for each point $\mathbf{x_0}$. Let's say $x_{0_0}$ and $x_{0_1}$ are static features. Then we can modify the original constraint as given in Equation \ref{Static features}.
\begin{equation}
    \label{Static features}
    \begin{gathered}
        \mathbf{v}^T\mathbf{x_n} + b + y_0 = 0 \Longleftrightarrow \mathbf{v'}^T\mathbf{x_n'} + v_0x_{0_0} + v_1x_{0_1} + b + y_0 = 0 \\
        \mathbf{v'}^T\mathbf{x_n'} + b' + y_0 = 0 \mbox{, such that } b' = b + v_0x_{0_0} + v_1x_{0_1}
    \end{gathered}
\end{equation}
In this case, we now have $\mathbf{v}', \mathbf{x_n}' \in \mathbb{R}^{d-2}$. We can then simply perform the original optimization problem with the features in a lower dimension leaving the static features as the fixed inputs of $\mathbf{x_0}$.

\begin{figure}[htbp]
  \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics[width=\textwidth]{Linear_Example_1.png}
    \caption{Changing negative label to positive label}
    \label{Example Linear SVM:1}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics[width=\textwidth]{Linear_Example_2.png}
    \caption{Changing positive label to negative label}
    \label{Example Linear SVM:2}
  \end{subfigure}
  \caption{Examples of changing the label predicted by a linear SVM. In Figure \ref{Example Linear SVM:1}, the weights are $w_x = 0.2$, $w_y = 0.7$. On the other hand, in Figure \ref{Example Linear SVM:2}, the weights are $w_x = 1.0$, $w_y = 0.1$.}

  \label{Example Linear SVM}

\end{figure}
\section{Solution to Linear SVM}
\label{linear SVM}

We derive a solution for Equation \ref{Linear Output} using a Lagrangian and then performing gradient descent to optimize for distance. This derivation is shown in Appendix \ref{Linear SVM Solution via Gradient Descent}. The result is to choose $\mathbf{x_1}$ such that $\mathbf{v}^T\mathbf{x_1} + b + y_0 = 0$ and perform iterative updates $\mathbf{x_{j+1}} := \mathbf{x_j} - \eta \nabla\mathcal{L}(\mathbf{x_j})$ where $\nabla_{\mathbf{x_j}}\mathcal{L}(\mathbf{x_j}, \lambda)$ is defined in Equation \ref{Linear Gradient}.
\begin{equation}
    \label{Linear Gradient}
    \nabla_{\mathbf{x_j}}\mathcal{L}(\mathbf{x_j}, \lambda) := -2\left(\mathbf{w} \odot \left[\mathbf{x_0} - \mathbf{x_j}\right]\right)  + \left(\frac{2\mathbf{v}^T\left(\mathbf{w} \odot \left[\mathbf{x_0} - \mathbf{x_j}\right]\right)}{\mathbf{v}^T \mathbf{v}}\right) \mathbf{v}
\end{equation}
In Figure \ref{Example Linear SVM} there are two examples showing the gradient descent solution for a linear SVM. Both solutions are heavily influenced by the given weights for $x$ and $y$ respectively.

\section{Solution to Non-Linear SVM}
\label{non-linear SVM}
Just as we did for the linear SVM, we can formulate the solution to Equation \ref{non-linear Output} using a Lagrangian and then perform gradient descent to optimize for the distance while taking into account the constraint. This derivation is shown in Appendix \ref{Non-Linear SVM Solution via Gradient Descent}. The result is to choose $\mathbf{x_1}$ such that $\sum_{i=1}^{N} \alpha_i y_i K(\mathbf{x_i}, \mathbf{x_1}) + b + y_0 = 0$. For some problems, finding $\mathbf{x_1}$ is computationally infeasible, so an approximation is needed. In our experiment we use the nearest support vector on the margin. Then use $\nabla_{\mathbf{x_j}}\mathcal{L}(\mathbf{x_j}, \lambda)$ defined in Equation \ref{Non-linear Gradient} in the gradient descent algorithm.
\begin{equation}
    \label{Non-linear Gradient}
    \begin{gathered}
        \nabla_{\mathbf{x_j}}\mathcal{L}(\mathbf{x_j}, \lambda) = -2\left(\mathbf{w} \odot \left[\mathbf{x_0} - \mathbf{x_j}\right]\right) + \lambda \left(\sum_{i=1}^{N} \alpha_i y_i K'(\mathbf{x_i}, \mathbf{x_n})\right),
        \\
        \lambda = \frac{2\left(\sum_{i=1}^{N} \alpha_i y_i K'(\mathbf{x_i}, \mathbf{x_n})\right)^T\left(\mathbf{w} \odot \left[\mathbf{x_0} - \mathbf{x_n}\right]\right)}{\left(\sum_{i=1}^{N} \alpha_i y_i K'(\mathbf{x_i}, \mathbf{x_n})\right)^T \left(\sum_{i=1}^{N} \alpha_i y_i K'(\mathbf{x_i}, \mathbf{x_n})\right)}
    \end{gathered}
\end{equation}

\begin{figure}[htbp]
 \begin{subfigure}[b]{0.5\textwidth}
  \centerline{ \includegraphics[scale=0.4]{poly_circle.png}}
   \caption{Polynomial kernel example.}
   \label{Example_Circle_Poly}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.5\textwidth}
  \centerline{\includegraphics[scale=0.4]{rbf_moon.png}}
  \caption{RBF kernel example.}
  \label{Example_Moons_RBF}
  \end{subfigure}
  \caption{Examples with non-linear SVM}
  \label{Example of non linear SVM}
\end{figure}

where $K'(\mathbf{x_i}, \mathbf{x_n})$ is the derivative of the kernel function $K(\mathbf{x_i}, \mathbf{x_n})$ with respect to $\mathbf{x_n}$ (this must exist to find the nearest point).

Figure \ref{Example_Circle_Poly}, presents an example for a polynomial SVM that finds the nearest point with the opposite label to the initial point using gradient descent.

Figure \ref{Example_Moons_RBF} presents an example for a RBF SVM that finds the nearest point with the opposite label to the initial point using gradient descent.

\section{Experiments}
\label{Experiments}

We evaluate our approach and present our experiments on both simulated and medical data.
We also introduce a method of implementing interpretability through the suggested actions.

\subsection{Simulated Data}
\label{simulated data}

We simulate data using the \href{https://scikit-learn.org/stable/datasets/index.html}{sklearn datasets package}. This package creates separable data for an SVM classifier with noise. We use three different simulated datasets: 1) linearly separable data 2) a dataset where one group is inside a circle and the other is outside (the circles dataset) and 3) a dataset of two interleaving half circles (the moons dataset). To measure the success of the action proposed by our solution, we compare it to the only other research that's been done in SVM actionability which is to move to the nearest support vector that's at least on the margin of the desired class \cite{Yang2002}.

\paragraph{Linear SVM Results}

In this section we compare the gradient descent and nearest support vector solutions. We see the distances for 1,000 datapoints in Figure \ref{Simulated Distances:1}. The average weighted normalized distance for the gradient descent solution was $0.003$ and for the nearest support vector was $0.013$. The gradient descent solution shows a statistically significant p-value $< 0.05$ which implies that the distance from gradient descent to the initial point is less than that of the nearest support vector. The gradient descent found a solution in at most $2.60$ milliseconds.

\paragraph{Non-Linear SVM Results}

To compare the gradient descent and nearest support vector solutions, the distances for 1,000 datapoints with a RBF kernel are shown in Figure \ref{Simulated Distances:2} for the moons dataset.
The average weighted normalized distance for the gradient descent solution was $0.044$ and for the nearest support vector was $0.085$. The gradient descent solution shows a statistically significant p-value $< 0.05$ which implies that the distance from gradient descent to the initial point is less than that of the nearest support vector. The gradient descent found a solution in at most $916.72$ milliseconds.
The distances for 1,000 datapoints with a polynomial kernel are shown in Figure \ref{Simulated Distances:3} for the circles datasets. The average weighted normalized distance for the gradient descent solution was $0.015$ and for the nearest support vector was $0.022$. The gradient descent solution shows a statistically significant p-value $< 0.05$ which again implies that the distance from gradient descent to the initial point is less than that of the nearest support vector. The gradient descent found a solution in at most $64.6$ milliseconds.

\begin{figure}[htbp]
  \begin{subfigure}[b]{0.325\textwidth}
    \includegraphics[width=\textwidth]{linear_distances_boxplot.png}
    \caption{Linear SVM}
    \label{Simulated Distances:1}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.335\textwidth}
    \includegraphics[width=\textwidth]{rbf_moons_distances_boxplot.png}
    \caption{RBF SVM on moons}
    \label{Simulated Distances:2}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.325\textwidth}
    \includegraphics[width=\textwidth]{poly_circles_distances_boxplot.png}
    \caption{Polynomial SVM for circles}
    \label{Simulated Distances:3}
  \end{subfigure}
  \caption{Distances of the action for linear, polynomial and RBF SVM.}
  \label{Simulated Distances}
\end{figure}

\subsection{The Atherosclerosis dataset} \label{Atherosclerosis Data}

\begin{figure}[htbp]

\begin{center}
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{rbf_results/feature_changes/mixed_features.png}
    \caption{Action for RBF SVM}
    \label{Feature_Change:1}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{poly_results/mixed_features.png}
    \caption{Action for polynomial SVM}
    \label{Feature_Change:2}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{rbf_results/feature_changes/BMI.png}
    \caption{Action for RBF SVM}
    \label{Feature_Change:3}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{poly_results/feature_actions/BMI.png}
    \caption{Action for polynomial SVM}
    \label{Feature_Change:4}
  \end{subfigure}
  %
  \caption{Figures \ref{Feature_Change:1}-\ref{Feature_Change:2} are of SUBSC/TRIC action. Figures \ref{Feature_Change:3}-\ref{Feature_Change:4} are of BMI action. We compare gradient descent solution and nearest support vector. }
  \label{Feature_Change}
  \end{center}
\end{figure}

To illustrate the usefulness of our approach in preventing atherosclerosis, we conducted experiments using the atherosclerosis dataset derived from {\em Stulong}\footnote{\url{https://relational.fit.cvut.cz/dataset/Atherosclerosis}}, a twenty year study of the risk factors of the atherosclerosis in a population of 1,419 middle aged men.
The patients have been classified into three groups: the normal, the risk,  and the pathological groups. We also dispose of a granular integer risk score for each patient.  The dataset used was pre-processed for the  PKDD Discovery Challenge 2002. Our aim is to produce actions that would find the easiest way to take a patient at risk of atherosclerosis and get them to a point that would have a prediction of no risk.

When creating a SVM model to describe this dataset, we used the following features  [SUBSC, TRIC, TRIGL, SYST, DIAST, BMI, WEIGHT, CHLST, ALCO\_CONS, TOBA\_CONSO] as these have all shown impacts on atherosclerosis risk. There is a description of each of these features in Appendix \ref{Description of Atherosclerosis Risk Factors}. We then grouped together the pathological risk and risk groups as \textbf{positive risk} or $+1$ and no risk as \textbf{negative risk} or $-1$. Then, we tuned the SVM to perform best on this prediction problem using cross validation and tested on a test set of 20\% of the data. This process was performed 10 times. The RBF SVM achieved an f1-score of $0.68$  on $540$ negative risk examples and an f1-score of $0.91$ on $1960$ positive risk examples with an overall accuracy of $0.86$. On the other hand, the polynomial SVM achieved an f1-score of $0.61$ on $540$ negative risk examples and an f1-score of $0.91$ on $1960$ positive risk examples with an overall accuracy of $0.85$. This process led us to the best parameters for the two models: an RBF SVM with hyperparameters $\gamma = 1, C = 10$ and a polynomial SVM with hyperparameter degree $= 4$.

With the SVM models defined, the next step was to test the recommended actions based on the solution presented in Section \ref{non-linear SVM}. For each point that has a label of $+1$ and has an SVM prediction of $+1$, we found two points: one, the \textbf{nearest support vector} with a label of $-1$ and two, the solution via \textbf{gradient descent} of the nearest point on the margin presented in Section \ref{non-linear SVM}. Note, for this example, we choose a weight vector of $[1, 1, .5, .5, .5, .2, .2, .1, .05, .05]$ to correspond with the features [SUBSC, TRIC, TRIGL, SYST, DIAST, BMI, WEIGHT, CHLST, ALCO\_CONS, TOBA\_CONSO]. For the RBF SVM, the algorithm took a maximum time of $3.99s$ and for the polynomial SVM, the algorithm took a maximum time of $1.25s$.

We compare these two solutions using three different methods:
(1) measure the weighted distance from both solutions to the point we are moving, (2)  measure the action recommended by both solutions, and (3)  measure the predicted risk of both solutions. To measure (3), we create a linear model to predict the granular integer risk score of atherosclerosis which is measured from $1 - 10$. This linear model is presented in Equation \ref{Linear Model}. Using this regression model\footnote{Interestingly, observe the negative coefficient associated with alcohol consumption. It has been noted in previous studies that some alcohol consumption can be beneficial on cardiovascular health \cite{Lucas2002}}, we can calculate and compare the risk associated with the old and new datapoints. This will help assess the impact of the actions in reducing the risk of atherosclerosis in the patient.

{ \small  \begin{multline} \label{Linear Model}
    Risk = 0.0072 \cdot SUBSC + 0.0036 \cdot TRIC + 0.00004 \cdot TRIGL + 0.0088 \cdot SYST \\
     + 0.0068 \cdot DIAST + 0.0191 \cdot BMI + 0.0037 \cdot WEIGHT + 0.0049 \cdot CHLST \\
     - 0.1903 \cdot ALCO\_CONS + 0.8468 \cdot TOBA\_CONS - 1.0558
\end{multline}
}

\vspace*{-0.4cm}

\begin{wrapfigure}{r}{0.38\textwidth}
\vspace*{-0.5cm}
\includegraphics[scale=0.4]{rbf_results/rbf_distances_histogram.png}
\vspace*{-0.2cm}
\caption{RBF Distances Histogram}
\label{RBF_Distances_Histogram}
\vspace*{-0.4cm}
\end{wrapfigure}

In Figures \ref{Feature_Change:1}-\ref{Feature_Change:2}, we see a box plot for the actions for a RBF SVM and a polynomial SVM for two of the highly weighted features: SUBSC and TRIC. As we would hope, the gradient descent solution requires less movement than the nearest support vector for these features that are extremely hard to change. On the other hand, when investigating a feature with a lower weight, such as BMI, there is more relative movement, particularly for the gradient descent solution, as this is a feature that a patient can more easily change. This result is shown in Figures \ref{Feature_Change:3}-\ref{Feature_Change:4}. The rest of these feature action boxplots are shown in Appendix \ref{Atherosclerosis Feature Boxplots}.

For the RBF SVM, the average weighted distance of the gradient descent solution was $0.011$ and for the nearest support vector was $0.073$. For the polynomial SVM, the average weighted distance of the gradient descent solution was $0.012$ and for the nearest support vector was $0.144$. The maximum time to run the gradient descent algorithm on either kernel was $2.265s$. For both the RBF and polynomial SVM, our solution is statistically significantly closer to the original point than the solution presented by the nearest support vector. These results are presented as a histogram for the RBF SVM in Figure \ref{RBF_Distances_Histogram}. The same plot is shown for the polynomial SVM in Appendix \ref{Atherosclerosis Polynomial Histogram}. Additionally, we see these results presented in the form of a boxplot for both the RBF and polynomial SVM in Appendix \ref{Atherosclerosis Distances Boxplots}.

\begin{figure}[ht]
\begin{center}
  \begin{subfigure}[b]{\textwidth}
    \centerline{\includegraphics[scale=0.6]{rbf_results/heatmap_change_1.png}}
    \caption{Action for RBF SVM}
    \label{Example_Patients:1}
  \end{subfigure}

  \begin{subfigure}[b]{\textwidth}

    \centerline{\includegraphics[scale=0.6]{poly_results/heatmap_change_1.png}}
    \caption{Action for Poly SVM}
    \label{Example_Patients:2}
  \end{subfigure}
  \caption{Depicting Actions for 7 Patients using both RBF and Poly SVMs.}
  \label{Example_Patients}
  \end{center}
\end{figure}

In Figure \ref{Decreased Risk RBF}, we see a graph of the predicted risk of both the original point and the suggested point for both the gradient descent solution and the nearest support vector for the RBF SVM. The gradient descent solution shows a higher probability of decreasing the risk of the initial point. For the polynomial SVM, the same conclusion is found which is that the gradient descent solution shows a higher probability of decreasing the risk of the initial point. The figure depicting these results is shown in Appendix \ref{Atherosclerosis Decreased Risk Poly}.

\begin{figure}[ht]
\begin{center}
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{rbf_results/unweighted_grad_descent_risk_rbf.png}
    \label{Decreased Risk RBF:1}
  \end{subfigure}
  %
  \begin{subfigure}[b]{0.45\textwidth}
    \includegraphics[width=\textwidth]{rbf_results/unweighted_nearest_sv_risk_rbf.png}
    \label{Decreased Risk RBF:2}
  \end{subfigure}
  \caption{Comparing the predicted risk of the initial point against the predicted risk of the suggested point of both algorithms for a RBF SVM.}
  \label{Decreased Risk RBF}
\end{center}
\end{figure}

Finally, we have included a set of figures to visualize the recommended actions of both the gradient descent solution and the nearest support vector. In Figure \ref{Example_Patients:1}, we visualize the percent change in each feature recommended for the solutions using a RBF SVM. In Figure \ref{Example_Patients:2}, we see the same for a polynomial SVM. Although these are just a few randomly chosen patients, we see the desired trend that the changes required for the gradient descent solutions are fainter colors (smaller percent change) while the changes for the nearest support vector are darker colors (larger percent change).

\subsubsection{Atherosclerosis Interpretability}
\label{Atherosclerosis Interpretability Section}

Using the framework presented in the processing of the atherosclerosis dataset, we present a way to delve into the interpretability of the SVM that classifies patients as either negative or positive risk. To do this, we use results of the SVM actionability.

\begin{table}[htbp]

    \begin{center}
    \begin{tabular}{|m{3.5cm}||m{4.5cm}|m{5cm}|}
    \hline
     & Normalized Amplitude Mean & Normalized Amplitude Median \\
    \hline
    TOBA\_CONS & 0.1989 & 0.1689\\
    CHLST & 0.0750 & 0.0604\\
    BMI & 0.0749 & 0.0666\\
    SYST & 0.0661 & 0.0508\\
    TRIGL & 0.0552 & 0.0444\\
    DIAST & 0.0525 & 0.0398\\
    TRIC & 0.0407 & 0.0308\\
    WEIGHT & 0.0376 & 0.0265\\
    SUBSC & 0.0373 & 0.0269\\
    ALCO\_CONS & 0.0294 & 0.0195\\
    \hline
    \end{tabular}
    \caption{Feature interpretability}

    \label{Atherosclerosis Interpretability}
    \end{center}
    }
\end{table}

By using the same RBF SVM ($\gamma = 1, C = 10$) and a weight vector of all $1$s, we can investigate the suggested actions as a proxy for feature importance. That is, when all features have equal weight, the features that move most to switch a classification from risk to no risk are the most important features when decreasing atherosclerosis risk. We use this weight vector of all $1$s and measure the amplitude of all of the recommended actions (normalized by feature) to determine which features required the most change. In Table \ref{Atherosclerosis Interpretability}, we present the median and mean of the normalized amplitudes of the suggestion actions of all the features. Based on the results, changing TOBA\_CONS is the most important (by a substantial amount) in terms of decreasing the risk while ALCO\_CONS is the least important. The rest of the rankings allow one to identify the features an at-risk patient should focus most on when attempting to reduce risk of atherosclerosis. Polynomial SVM results are in Appendix \ref{Polynomial Atherosclerosis Interpretability}.

\section{Discussion and Conclusion}
\label{conclusion}
The task of devising actions or actionability based on predictive models has been relatively unexplored in modern machine learning research.
We propose a simple, yet an effective and efficient way of using SVM models for actionability.
We show an answer to the nearest point of any point that switches the label predicted by a linear SVM to a desired result. This provides a good solution to any application that implements a linear SVM to divide data.
For a non-linear SVM, we were able to find an algorithm via gradient descent that predicts the nearest point with a desirable outcome. This reduces the cost of the action.
However, it is important to note that this algorithm
is sensitive to the initial guess for the nearest point. A search of possible starting points should allow one to pick a point that will lend itself to finding the true global optima (such as the nearest support vector).
In Section \ref{Atherosclerosis Data}, we saw that the gradient descent solution gave an easier action than the nearest support vector with the given weight vector for both the RBF and polynomial SVM. Additionally, the gradient descent solution gave a higher probability of reducing predicted risk than the nearest support vector.
{Using the recommended actions, we explored the interpretability of the SVM models for the atherosclerosis dataset, and concluded  that tobacco consumption was the most important risk factor to adjusting the atherosclerosis risk.}

We must note that the action is only as good as the SVM model itself. If the SVM model is a good fit for the prediction problem, then the resulting action will also be relevant.
Additionally, to reduce uncertainty of a given action, one could adjust the algorithm to go \textit{beyond} the positive/negative margin to reach a point that is more confidently classified in the desired group.
In future work, it would be interesting to explore variations of the actionability problem. For example, it's possible that a user has the bandwidth to change a limited number of features.
Additionally, it would not be hard to expand the above results to a multiclass SVM classifier. We could then provide the nearest action to the desired class.
Finally, there is  more work to be done in exploring the weighting. Are there other more applicable ways to define actionable and static features? What other metrics could we use to replace the distance/cost metric that we aim to minimize?
Paired with visualization techniques, our SVM approach to actionability has the potential to have an immense impact in assisting physicians in
preventing diseases with actionable risk factors.
We hope that this paper will motivate the machine learning community to conduct research on  actionability so to take full advantage of the accurate prediction models.

\section{Broader Impact}
\label{broader impact}

This algorithm is an extension of the SVM algorithm, so therefore it will impact the community in similar ways that SVM has impacted the world. A suggested action on a predicted outcome of the SVM algorithm could have a potentially huge beneficial impact in {\bf healthcare} and the  world of {\bf precision medicine}.
Say a patient is told they will most likely need surgery, a doctor could then explain to the patient the easiest changes they could make so that the doctor would no longer recommend surgery as a solution. Thus, actionability could be used to decide on a prevention policy by providing  the physician with a tool for investigating the effects of the various factors on the risk of disease, for an individual patient.
Additionally, this could be used for a positive impact in the world of {\bf climate change}. It's possible that researchers use SVMs to predict outcomes of certain environments and that actionability would allow them to suggest how communities could achieve more desirable outcomes.

On the other hand, SVMs can be used
by companies who may be using SVM models to predict the success of an advertisement. This algorithm could hypothetically used in {\bf marketing and business strategies} to help companies attract more customers which may be viewed negatively in the eyes of the consumer. Similarly, politicians may be able to use this to change opinions of voters by feeding certain features that tend to change the minds of voters for their own gain.

While SVMs and the actionability approach we propose can be used maliciously, we do not believe this research would inherently put anyone at a disadvantage. However, we recognize that there are a few faults of this system. There is inherent bias in the weights provided by the user and therefore users could manipulate the system to give recommendations that enforce a previous bias. In some ways, it may be better to use this as an unweighted algorithm or require that extensive research is done into the weights of the actions.

\bibliographystyle{plain}