[Python] Predictive modelling - Regression with grouped id's and moving average

Discussão em 'Python' iniciado por Stack, Março 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem with a predictive modelling problem. The starting position is shown below. S1-S2 are sensor measurements and RUL is my target value.

    DataStructure:


    id period s1 s2 s3 RUL
    1 1 510.23 643.43 1585.29 6
    1 2 512.34 644.89 1586.12 5
    1 3 514.65 645.11 1587.99 4
    1 4 512.98 647.59 1588.45 3
    1 5 516.34 649.04 1590.65 2
    1 6 518.12 652.62 1593.09 1
    2 1 509.77 640.61 1584.91 9
    2 2 510.26 642.06 1586.00 8
    2 3 511.95 643.62 1588.09 7
    2 4 513.51 646.51 1589.45 6
    2 5 512.17 648.06 1589.54 5
    2 6 515.56 646.11 1586.22 4
    2 7 518.78 649.34 1586.96 3
    2 8 519.90 650.30 1588.95 2
    2 9 521.05 651.39 1591.34 1
    3 1 501.11 653.99 1580.45 8
    3 2 511.45 643.23 1584.09 7
    3 3 505.45 643.78 1586.11 6
    3 4 504.45 643.43 1588.34 5
    3 5 506.45 643.71 1589.89 4
    3 6 511.45 643.33 1591.21 3
    3 7 516.45 643.61 1592.42 2
    3 8 518.45 643.05 1596.77 1

    Target:


    My target is to predict the remaining usefull live (RUL) of unseen data. In this case I have only 1 type of machine with different id's (That means 1 type and 3 different physical systems). For the prediction the id doesn't matter, because it's the same machine. Furthermore, I want to add new features. The moving average of s1 s2 and s3. So I have to add three new column with the names a1, a2 and a3.

    For instance, a1 should look like:

    a1
    NaN
    NaN
    512.41
    513.32
    514.66
    515.81
    NaN
    NaN
    510.66
    511.91
    512.54
    513.75
    515.50
    518.08
    519.91
    NaN
    NaN
    506.00
    507.12
    505.45
    507.45
    511.45
    515.45


    The next problem is, that I can't work with NaN, because it's a string. How can I ignore/work with it for a1, a2, and a3 ?

    Next Question is: How can I use a regression models like RandomForest and Bagged Decision Trees with a train_test_split to predict the RUL of unseen new data? (Of course I need more data, this example gives just the structure.) [s1],[s2],[s3] are my inputs and RUL is the output. Furthermore, I want to evaluate the model with Mean Absolut Error, Mean Squared Error and R².

    Finaly, I want to use the gridsearch Method for tuning.

    I know what I wanna do, but I'm not able to realize it with python. A complete code would be perfect.

    Continue reading...

Compartilhe esta Página