KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Academy Advanced Capstone 1.3 clarification

  • Advanced Capstone 1.3 clarification

    Posted by roryk on May 11, 2023 at 12:00 am

    Hi, I’m currently trying the advanced capstone and was slightly confused with the function in section 1.3

     

    I’m not sure how the output makes sense, for the rows with lapId = 2, there are no events between those times, so how are the sensorValues generated? I can ignore lapId in the window join, but then testSection[`exercise1] reports 1.3 failing with wrong values, so I don’t know what I’m doing wrong. I can post code if required but didn’t want to potentially spoil it for others.

    roryk replied 8 months, 2 weeks ago 3 Members · 8 Replies
  • 8 Replies
  • Laura

    Administrator
    May 11, 2023 at 12:00 am

    HI  , wj takes the initial value within the window to be the prevailing values that existed before the window started.

    So for example in the case of tempBackRight for the second time interval between 12:02:56.325 and 12:03:33.564:

    • you are correct there is no event between this time for tempBackRight
    •  wj will take the prevailing value that existed before the window started i.e. 20.87774 which happens to be the only entry for this sensor.
    • This is a useful feature of wj because we would rather have the last known value over a table with a lot of nulls

    Note that if we did want to consider the values that only occurred during the window, we could use wj1. Hope that helps. It is correct in this example to not have lapId as a column to join, the laps are represented already by the time and endTime values defining the lap window.

    If you’re still getting an error you can share your attempt with a spoiler tag and I can better help with where you might be going wrong.

     

     

    Thanks,

    Michaela

  • roryk

    Member
    May 11, 2023 at 12:00 am

    Hi Michaela,

    Thanks for explaining the behaviour, I managed to fix the function and now it passes. I was joining on more columns than required. I see why you don’t need to join on lapId, but does it not make sense to join on date/session? Any default values from another date or session don’t seem like they would be particularly meaningful to me. Or is it expected to do any filtering before using the function, and therefore it’s not an issue? This doesn’t matter for the capstone, it’s more out of curiosity and what might be expected in practice.

  • Laura

    Administrator
    May 11, 2023 at 12:00 am

    You are correct that in the real world in practice date or session could be considered – it depends what the end goal is.

    Taking date for example you could either:

    • join on time (no date included)
      • gives an average value over a certain window across multiple days
      • this tells the user that after say 3 days of practice sessions on average the sensor value is X in the morning or afternoon
      • for example this might indicate if temperature tyres are colder in the morning and hotter in the afternoon meaning we might want to adjust the car setup in the later sessions
      • in this scenario we don’t care about date – rather just the time of day it happened
    • join on date and time
      • gives an average value over a certain window on a specific day
      • the dataset would be much larger (triple the size if 3 days)
      • this would be useful if I wanted to have the breakdown of averages per window per day

    The same is true for session – we don’t actually care what session it is – we just want averages per time of day.

    Hope this makes sense!

  • ab

    Member
    July 5, 2023 at 12:00 am

    hi, can you please help me with your solution. I’m stuck on this problem since 2 days.

  • Laura

    Administrator
    July 5, 2023 at 12:00 am

    Hi  , what error are you seeing? Can you provide some detail on what you have tried so far so I can better help? If you want to add your code for this solution you can use the spoiler tag when posting or feel free to IM it to me.

     

    Thanks,

    Michaela

  • ab

    Member
    July 5, 2023 at 12:00 am

    #spoiler

    distinctSensors: distinct select sensorId from sensor

    crosspdt:(select from event) cross distinctSensors

    windows:(crosspdt[`time];crosspdt[`endtime])

    f:{avg each x}
    wj[windows;`sensorId`time;select from crosspdt;(select from sensor;(f;`sensorValue))]

    Pls suggest

  • Laura

    Administrator
    July 6, 2023 at 12:00 am

    When I try to run the above I get a `length error.

    A few things I spotted:

    • watch out when you specify endtime – it should be endTime. Otherwise windows is pair of list but only the first is populated and the second is null.windows:(crosspdt[`time];crosspdt[`endTime])?
    • think you do not require function f, try with just with avg directly in the wj (avg;`sensorValue)?

     

  • ab

    Member
    July 7, 2023 at 12:00 am

    hey yes already worked. thanks for the help.

Log in to reply.