Spaces:
Sleeping
Sleeping
Update train_model.py
Browse files- train_model.py +12 -0
train_model.py
CHANGED
|
@@ -12,6 +12,18 @@ except FileNotFoundError:
|
|
| 12 |
print("Error: 'enhanced_mantle_training.csv' not found. Please check the file path.")
|
| 13 |
exit()
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Prepare the features (temperature, duration) and target (risk_level)
|
| 16 |
X = df[["temperature", "duration"]] # Features: temperature and duration
|
| 17 |
y = df["risk_level"] # Target: risk_level
|
|
|
|
| 12 |
print("Error: 'enhanced_mantle_training.csv' not found. Please check the file path.")
|
| 13 |
exit()
|
| 14 |
|
| 15 |
+
# Ensure that the necessary columns are present in the dataset
|
| 16 |
+
required_columns = ["temperature", "duration", "risk_level"]
|
| 17 |
+
if not all(col in df.columns for col in required_columns):
|
| 18 |
+
print(f"Error: Missing one or more required columns. Ensure the dataset contains {required_columns}.")
|
| 19 |
+
exit()
|
| 20 |
+
|
| 21 |
+
# Check for any missing values in the data
|
| 22 |
+
if df.isnull().any().any():
|
| 23 |
+
print("Warning: Dataset contains missing values. Please clean the data.")
|
| 24 |
+
# Optionally, you can fill missing values or drop rows with missing data
|
| 25 |
+
df = df.dropna() # Drop rows with missing data, or use df.fillna() to fill missing values
|
| 26 |
+
|
| 27 |
# Prepare the features (temperature, duration) and target (risk_level)
|
| 28 |
X = df[["temperature", "duration"]] # Features: temperature and duration
|
| 29 |
y = df["risk_level"] # Target: risk_level
|