Answers.Body: <p>I think <em>Anomaly Detection</em> (AD) applied to timeseries, should do the job. Basically, AD aims at finding anomalies in your data which, in your case, should be <em>local</em> sudden changes along the <span class="math-container">$y$</span>-axis.</p>
  <p>Usually, in AD you need a way to score each sample (e.g., a distance or similarity) such that data samples that are above or below a given threshold are considered as anomalous or outliers.</p>
  <p>Moreover, if you have training data such that you can create a map <span class="math-container">$(y(x), x_0)$</span>  then you may want to first try a simpler <em>classification</em> approach, then you can try AD with labeled data, and if necessary (e.g., a large part of your data miss the <span class="math-container">$x_0$</span> label), you can even try <em>unsupervised AD</em>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-28T09:09:14.820Z
Answers.Text: thanks for the pointers: I'll see where it takes me.
Answers.UserDisplayName: Tomislav Nakic-Alfirevic
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-23T22:04:20.573Z
Answers.LastActivityDate: 2023-11-23T22:04:20.573Z
Answers.UserDisplayName: Luca Anzalone
Body: <p>I have a function that looks something like this (in blue):</p>
  <p><a href="https://i.sstatic.net/uH96D.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uH96D.png" alt="enter image description here" /></a></p>
  <p>I'm curious to hear what kind of ML/AI algorithm might be useful to detect the approximate x0 value at which the function y(x) significantly changes in a finite domain on the X-axis  (point highlighted with the red dotted line).</p>
  <p>In the most trivial case, AI is probably overkill, but things quickly get complicated if e.g. there are multiple such points of interest in a function, if there are relationships between multiple such points and so on.</p>
  <p>Basically, the input would be a set of y(x) values and the output would be x0 or a vector of values from the X-axis where there is a &quot;significant&quot; change in value. I have plenty of input data with known x0 values I could use for training.</p>
  <p>Which algorithms might come in handy, what kind of approaches?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-23T22:48:25.377Z
Comments.Text: You want to give the x/y pairs to the AI and it givens you a binary score for the points where the function changes a lot?
Comments.UserDisplayName: Alberto
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-28T09:07:25.867Z
Comments.Text: @Alberto, yes, that's basically it.
Comments.UserDisplayName: Tomislav Nakic-Alfirevic
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-28T21:11:54.993Z
Comments.Text: what about just plain math? if you have a mesh of Xs and the corresponding Ys, you just need to find the highest derivative, which you can approximate using the neighbors of each point in the mesh
Comments.UserDisplayName: Alberto
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-29T19:46:39.180Z
Comments.Text: @Alberto, thank you for the suggestion. The thing is, this is quite a simplified example. The slope could be jagged, for example. That could easily confuse a plain math/highest derivative approach. That said, it could easily confuse an ML algorithm, too, but there I have hope that it can be trained to look beyond the noise. :)
  
  And as I said, this is the first step: I'm working my way to multiple related "anomalies" such as this one, and math quickly becomes unwieldy there, I expect.
Comments.UserDisplayName: Tomislav Nakic-Alfirevic
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-11-29T20:00:16.540Z
Comments.Text: I see how jagged points might screw the derivative, but this is already been studied in CV, I suggest you to give a look to the "Gaussian derivative" (https://hannibunny.github.io/orbook/preprocessing/04gaussianDerivatives.html#derivatives-of-the-2-dimensional-gauss-filter) which is widely used in CV to solve the jagged signal problem
Comments.UserDisplayName: Alberto
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-02T11:54:00.770Z
Comments.Text: Thanks for the hint, Alberto: maybe it turns out to be helpful.
Comments.UserDisplayName: Tomislav Nakic-Alfirevic
Tags: <machine-learning>
Title: What kind of ML/AI approach might work well for "edge" detection in a function?
UserDisplayName: Tomislav Nakic-Alfirevic
ThreadText: # What kind of ML/AI approach might work well for "edge" detection in a function?
  
  (Asked by: username_0 on 2023-11-23)
  
  I have a function that looks something like this (in blue):
  
  [![enter image description here](https://i.sstatic.net/uH96D.png)](https://i.sstatic.net/uH96D.png)
  
  I'm curious to hear what kind of ML/AI algorithm might be useful to detect the approximate x0 value at which the function y(x) significantly changes in a finite domain on the X-axis (point highlighted with the red dotted line).
  
  In the most trivial case, AI is probably overkill, but things quickly get complicated if e.g. there are multiple such points of interest in a function, if there are relationships between multiple such points and so on.
  
  Basically, the input would be a set of y(x) values and the output would be x0 or a vector of values from the X-axis where there is a "significant" change in value. I have plenty of input data with known x0 values I could use for training.
  
  Which algorithms might come in handy, what kind of approaches?
  
  **Tags:** machine-learning
  > **Comments:**
  > **username_1**: You want to give the x/y pairs to the AI and it givens you a binary score for the points where the function changes a lot?  
  > **username_0**: @Alberto, yes, that's basically it.  
  > **username_1**: what about just plain math? if you have a mesh of Xs and the corresponding Ys, you just need to find the highest derivative, which you can approximate using the neighbors of each point in the mesh  
  > **username_0**: @Alberto, thank you for the suggestion. The thing is, this is quite a simplified example. The slope could be jagged, for example. That could easily confuse a plain math/highest derivative approach. That said, it could easily confuse an ML algorithm, too, but there I have hope that it can be trained to look beyond the noise. :)  And as I said, this is the first step: I'm working my way to multiple related "anomalies" such as this one, and math quickly becomes unwieldy there, I expect.  
  > **username_1**: I see how jagged points might screw the derivative, but this is already been studied in CV, I suggest you to give a look to the "Gaussian derivative" (https://hannibunny.github.io/orbook/preprocessing/04gaussianDerivatives.html#derivatives-of-the-2-dimensional-gauss-filter) which is widely used in CV to solve the jagged signal problem  
  > **username_0**: Thanks for the hint, Alberto: maybe it turns out to be helpful.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-11-23. Score: 1
  
  I think *Anomaly Detection* (AD) applied to timeseries, should do the job. Basically, AD aims at finding anomalies in your data which, in your case, should be *local* sudden changes along the $y$-axis.
  
  Usually, in AD you need a way to score each sample (e.g., a distance or similarity) such that data samples that are above or below a given threshold are considered as anomalous or outliers.
  
  Moreover, if you have training data such that you can create a map $(y(x), x\_0)$ then you may want to first try a simpler *classification* approach, then you can try AD with labeled data, and if necessary (e.g., a large part of your data miss the $x\_0$ label), you can even try *unsupervised AD*.
  
  > **Comments:**
  > **username_0**: thanks for the pointers: I'll see where it takes me.  
  
  ---
  
  