Answers.Body: <p>My response in the comment was getting too large.
  As I mentioned, you can use pandas to solve your problem.</p>
  <p>You can have three variables named: fridge_power, AC_power, and light_power.</p>
  <p>All are the floating point vectors of size Nx1. You should take the moving average of all three of them and then compare any instantaneous value with the average window. If the instantaneous value is higher than 2*sigma, where sigma is the standard deviation, then it should notify that instance as anomaly.</p>
  <p>Perhaps the following code snippet can help. You need to modify the part where you are taking the input dataframes (df). If any confusion, let me know in the comments and I can help.</p>
  <pre><code>import pandas as pd
  
  # Assuming you have three vectors: fridge_power, AC_power, light_power
  # Replace these with your actual data
  fridge_power = [...]  # Nx1 floating-point vector
  AC_power = [...]      # Nx1 floating-point vector
  light_power = [...]   # Nx1 floating-point vector
  
  # Create a DataFrame with the vectors
  df = pd.DataFrame({
      'fridge_power': fridge_power,
      'AC_power': AC_power,
      'light_power': light_power
  })
  
  # Calculate the moving average for each column
  window_size = 10  # Choose your desired window size
  ma_df = df.rolling(window=window_size).mean()
  
  # Calculate the standard deviation for each column
  sigma_df = df.rolling(window=window_size).std()
  
  # Check for anomalies
  threshold = 2  # Adjust as needed
  anomalies = (df &gt; ma_df + 2 * sigma_df)  # Boolean DataFrame indicating anomalies
  
  # Notify instances with anomalies
  anomaly_instances = anomalies.any(axis=1)
  print(&quot;Anomaly instances:&quot;)
  print(df[anomaly_instances])
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-09T13:29:51.990Z
Answers.Text: Just thought it was something for machine learning. 
  But you are right, I can identify most of the interesting appliances by hand and just do it somewhat old style.
Answers.UserDisplayName: povlhp
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-03-08T07:12:46.177Z
Answers.LastActivityDate: 2024-03-08T07:12:46.177Z
Answers.UserDisplayName: SJa
Body: <p>I am learning Tensorflow, and I have a specific problem I want to solve.
  I want to identify on/off of my large power consumers at home. And calculate the power consumption elsewhere.</p>
  <p>I expect to input arrays of say 10 or 30 samples of voltage (of each of my 3 phases), Amps, and Watts. Not sure if V*A is needed, as it can be implicitly called. Then when some patterns happens (say fridge or freezer compressor starting - causing a high pulse) I should be able to identify them. Hope to do the same with oven and stove, and dryer, 3000W water kettle, 3000W iron etc.</p>
  <p>Any good idea how to do this ? I know I will have to create lots of samples, but should I just run it with Keras ? Handle the time series like an image ?</p>
  <p>Should I create another array of the different devices and their status ? And how ? Or should I just use that info for validation ? I think a current status is important for off-detection, and possible for change in power of the stove.</p>
  <p>Any pointers on identifying events in time series are welcome</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-08T07:05:52.217Z
Comments.Text: Why do you want to use keras? It does not seem like a machine learning problem. 
  It more seems like pattern recognition problem either in the run-time or on the offline data. Keras is a library for AI and deep- learning.
  
  You can do this easily using Pandas.
Comments.UserDisplayName: SJa
Tags: <machine-learning><tensorflow><time-series>
Title: Beginner need help - identify data
UserDisplayName: povlhp
ThreadText: # Beginner need help - identify data
  
  (Asked by: username_0 on 2024-03-05)
  
  I am learning Tensorflow, and I have a specific problem I want to solve.
  I want to identify on/off of my large power consumers at home. And calculate the power consumption elsewhere.
  
  I expect to input arrays of say 10 or 30 samples of voltage (of each of my 3 phases), Amps, and Watts. Not sure if V\*A is needed, as it can be implicitly called. Then when some patterns happens (say fridge or freezer compressor starting - causing a high pulse) I should be able to identify them. Hope to do the same with oven and stove, and dryer, 3000W water kettle, 3000W iron etc.
  
  Any good idea how to do this ? I know I will have to create lots of samples, but should I just run it with Keras ? Handle the time series like an image ?
  
  Should I create another array of the different devices and their status ? And how ? Or should I just use that info for validation ? I think a current status is important for off-detection, and possible for change in power of the stove.
  
  Any pointers on identifying events in time series are welcome
  
  **Tags:** machine-learning, tensorflow, time-series
  > **Comments:**
  > **username_1**: Why do you want to use keras? It does not seem like a machine learning problem.  It more seems like pattern recognition problem either in the run-time or on the offline data. Keras is a library for AI and deep- learning.  You can do this easily using Pandas.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-03-08. Score: 0
  
  My response in the comment was getting too large.
  As I mentioned, you can use pandas to solve your problem.
  You can have three variables named: fridge_power, AC_power, and light_power.
  All are the floating point vectors of size Nx1. You should take the moving average of all three of them and then compare any instantaneous value with the average window. If the instantaneous value is higher than 2*sigma, where sigma is the standard deviation, then it should notify that instance as anomaly.
  Perhaps the following code snippet can help. You need to modify the part where you are taking the input dataframes (df). If any confusion, let me know in the comments and I can help.
  import pandas as pd
  
  # Assuming you have three vectors: fridge_power, AC_power, light_power
  # Replace these with your actual data
  fridge_power = [...]  # Nx1 floating-point vector
  AC_power = [...]      # Nx1 floating-point vector
  light_power = [...]   # Nx1 floating-point vector
  
  # Create a DataFrame with the vectors
  df = pd.DataFrame({
      'fridge_power': fridge_power,
      'AC_power': AC_power,
      'light_power': light_power
  })
  
  # Calculate the moving average for each column
  window_size = 10  # Choose your desired window size
  ma_df = df.rolling(window=window_size).mean()
  
  # Calculate the standard deviation for each column
  sigma_df = df.rolling(window=window_size).std()
  
  # Check for anomalies
  threshold = 2  # Adjust as needed
  anomalies = (df > ma_df + 2 * sigma_df)  # Boolean DataFrame indicating anomalies
  
  # Notify instances with anomalies
  anomaly_instances = anomalies.any(axis=1)
  print("Anomaly instances:")
  print(df[anomaly_instances])
  
  > **Comments:**
  > **username_0**: Just thought it was something for machine learning.  But you are right, I can identify most of the interesting appliances by hand and just do it somewhat old style.  
  
  ---
  
  