Scénario de test & Cas d'usage
Creates a dataset named 'machine_sensors'. The target 'rul_hours' is a function of sensor readings, machine age, and type, with non-linear patterns and random noise to simulate real-world conditions.
| 1 | DATA machine_sensors; |
| 2 | call streaminit(42); |
| 3 | DO machine_id = 1 to 2000; |
| 4 | machine_type = ifn(rand('UNIFORM') < 0.4, 'TypeA', 'TypeB'); |
| 5 | age_days = floor(rand('UNIFORM') * 1000); |
| 6 | sensor1_vibration = 5 * cos(age_days / 100) + rand('NORMAL', 0, 0.5); |
| 7 | sensor2_temp = 70 + 0.05 * age_days + rand('NORMAL', 0, 2) + ifn(machine_type='TypeB', 10, 0); |
| 8 | rul_hours = 5000 - (age_days * 2) - (sensor1_vibration**2 * 10) - (sensor2_temp - 70)*5 + rand('NORMAL', 0, 50); |
| 9 | IF rul_hours < 0 THEN rul_hours = 0; |
| 10 | OUTPUT; |
| 11 | END; |
| 12 | RUN; |
| 1 | PROC CASUTIL; |
| 2 | load DATA=machine_sensors casout='machine_sensors' replace; |
| 3 | RUN; |
| 4 | QUIT; |
| 1 | PROC CAS; |
| 2 | LOADACTIONSET 'bart'; |
| 3 | bart.bartGauss / |
| 4 | TABLE={name='machine_sensors'}, |
| 5 | target='rul_hours', |
| 6 | inputs={'age_days', 'sensor1_vibration', 'sensor2_temp', 'machine_type'}, |
| 7 | nominals={'machine_type'}, |
| 8 | nTree=50, |
| 9 | nBI=200, |
| 10 | nMC=1000, |
| 11 | seed=1234, |
| 12 | store={name='rul_model_store', replace=true}, |
| 13 | OUTPUT={casOut={name='rul_predictions', replace=true}, pred='predicted_rul', resid='residual'}, |
| 14 | outputTables={names={'VarImp', 'FitStatistics'}}; |
| 15 | RUN; |
| 16 | QUIT; |
The action successfully trains a BART model and saves it to 'rul_model_store'. An output table 'rul_predictions' is created containing the original data plus columns for the predicted RUL and residuals. The 'VarImp' table should show that 'age_days' and sensor readings are important predictors. The model is ready to be used by the 'bartScore' action on new data.