Spaces:
No application file
No application file
Delete engine_model.pkl
Browse files- engine_model.pkl +0 -28
engine_model.pkl
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
import xgboost as xgb
|
| 3 |
-
import joblib
|
| 4 |
-
|
| 5 |
-
# Load the dataset directly from the web
|
| 6 |
-
url = "https://raw.githubusercontent.com/datasets-machine-learning/nasa-turbofan-failure-prediction/master/data/train_FD001.txt"
|
| 7 |
-
cols = ['unit', 'cycles', 'os1', 'os2', 'os3'] + [f's{i}' for i in range(1, 22)]
|
| 8 |
-
df = pd.read_csv(url, sep='\s+', header=None, names=cols)
|
| 9 |
-
|
| 10 |
-
# Calculate RUL (Remaining Useful Life)
|
| 11 |
-
max_cycles = df.groupby('unit')['cycles'].max().reset_index()
|
| 12 |
-
max_cycles.columns = ['unit', 'max_of_unit']
|
| 13 |
-
df = df.merge(max_cycles, on='unit', how='left')
|
| 14 |
-
df['RUL'] = df['max_of_unit'] - df['cycles']
|
| 15 |
-
|
| 16 |
-
# We use exactly 15 features to match the app.py logic
|
| 17 |
-
# (cycles + 14 sensor/settings columns)
|
| 18 |
-
features = ['cycles', 's2', 's3', 's4', 's7', 's8', 's11', 's12', 's13', 's15', 's17', 's20', 's21', 'os1', 'os2']
|
| 19 |
-
X = df[features]
|
| 20 |
-
y = df['RUL']
|
| 21 |
-
|
| 22 |
-
# Train the model
|
| 23 |
-
model = xgb.XGBRegressor(n_estimators=100, learning_rate=0.1)
|
| 24 |
-
model.fit(X, y)
|
| 25 |
-
|
| 26 |
-
# SAVE THE FILE
|
| 27 |
-
joblib.dump(model, 'engine_model.pkl')
|
| 28 |
-
print("✅ Done! 'engine_model.pkl' created in your folder.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|