Skip to main content
Solved

Cognite Charts - flag the far-off datapoints


Forum|alt.badge.img+2

I have a CDF chart that is showing some output based on the timeseries associated with. I want to flag the points on the chart that are beyond some threshold. (say anything >0.5 and <-0.5 is abnormal and need to be flagged off in the chart) IS there a way to show that in the CDF charts visualization.

Best answer by Knut Vidvei

Using Python code and InDSL you will have the full freedom to customize your views. These preferences will vary from user to user, and customer to customer.

However, you can still do a lot in the fronted. if you use the visualization setting in the outlier detection time series, and set Type to “none”, it will show the dots as you have in your Python plot above. I scaled here the y-axis so that the results with 0 is below the view line.

Allowing full flexibility as you have in Python in a no-code frontend is a bigger challenge, as it would lead to an unmanageable number of settings and buttons. 

View original
Did this topic help you find an answer to your question?

9 replies

Knut Vidvei
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 132 replies
  • August 30, 2023

Hello,

This is a great question. You have two options based on if you need to evaluate historic thresholds, or be alerted on future thresholds.

  1. Future thresholds. In the right hand menu, choose Monitoring and create a monitoring-job to evaluate the threshold for future incoming data. You will receive an email when it is breached, and alerts are available in Charts under menu “Alerts”
     
  2. Historic threshold breaches. Use the right hand menu “Thresholds”, and select Over or Under or Between. The breaches and the total duration is shown. It is however not “flagged” or highlighted in the Chart beyond showing the threshold line as if now.


Knut


Forum|alt.badge.img+2
  • Author
  • 42 replies
  • August 30, 2023

Thanks @Knut Vidvei. Is there a way to use Outlier detection and visualise that in the same timeseries?

I am not able to understand and use that in CDF charts. 

 

Actually, It must look like the box plots and must show all the normal points and the outliers in a different color.


Knut Vidvei
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 132 replies
  • August 30, 2023

Hi,

The outlier detection gives you a new time series that based on your settings calculates whether the data points in the source time series are outliers or not.

The new time series will be 0 if no outliers are found and 1 if there are outliers that match your input settings.
 

 


If you want to go deeper, and see Python code and examples using the underlying Industrial Data Science Library you can also see details here:
https://indsl.docs.cognite.com/auto_examples/data_quality/plot_out_of_range.html
 

Knut


Forum|alt.badge.img+2
  • Author
  • 42 replies
  • August 30, 2023

Hi @Knut Vidvei 

I would want to show that in the same chart itself. That is what my customer is asking for. If I have to work outside charts, I can use core Python and other visualization tools to show that details. 

For ex: this code will show it pretty well using core Python. 

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Generate example time series data
np.random.seed(42)
n_points = 100
timestamps = pd.date_range(start='2023-01-01', periods=n_points, freq='D')
values = np.random.normal(loc=50, scale=10, size=n_points)
values[20] = 150  # Adding an outlier

data = pd.DataFrame({'Timestamp': timestamps, 'Value': values})

data['Z-Score'] = (data['Value'] - data['Value'].mean()) / data['Value'].std()

outlier_threshold = 2

outliers = data[data['Z-Score'].abs() > outlier_threshold]

# Plotting
plt.figure(figsize=(10, 6))
plt.plot(data['Timestamp'], data['Value'], label='Time Series')
plt.scatter(outliers['Timestamp'], outliers['Value'], color='red', label='Outliers')
plt.xlabel('Timestamp')
plt.ylabel('Value')
plt.title('Time Series with Outliers')
plt.legend()
plt.grid(True)
plt.show()

The output will look like this for the above standard-python code snippet.

Outlier Sample chart visual using standard python

 


Knut Vidvei
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 132 replies
  • Answer
  • August 30, 2023

Using Python code and InDSL you will have the full freedom to customize your views. These preferences will vary from user to user, and customer to customer.

However, you can still do a lot in the fronted. if you use the visualization setting in the outlier detection time series, and set Type to “none”, it will show the dots as you have in your Python plot above. I scaled here the y-axis so that the results with 0 is below the view line.

Allowing full flexibility as you have in Python in a no-code frontend is a bigger challenge, as it would lead to an unmanageable number of settings and buttons. 


Forum|alt.badge.img+2
  • Author
  • 42 replies
  • August 30, 2023

Please could you share a clear example with steps; I dont see any type or such setting in CDF charts in front-end.

 


  • Practitioner
  • 20 replies
  • August 30, 2023

@eashwar11 You should just be able to click on the corresponding coloured square under the “style” in your screenshot to get the same menu that @Knut Vidvei has shown.


Knut Vidvei
Seasoned Practitioner
Forum|alt.badge.img
  • Seasoned Practitioner
  • 132 replies
  • August 30, 2023

Hi,

I zoomed in and highlighted the option with a red box here:

 


  • Seasoned Practitioner
  • 223 replies
  • September 4, 2023

Hi @eashwar11, did this help? 


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings