Spaces:
Sleeping
Sleeping
| import numpy as np | |
| from sklearn.linear_model import LogisticRegression | |
| import joblib | |
| # Generate synthetic data | |
| np.random.seed(42) | |
| n_samples = 200 | |
| X = np.column_stack([ | |
| np.random.uniform(0, 24, n_samples), # usage_hours | |
| np.random.uniform(0, 24, n_samples), # idle_hours | |
| np.random.uniform(0, 10, n_samples), # movement_frequency | |
| np.random.uniform(10, 100, n_samples) # cost_per_hour | |
| ]) | |
| y = [] | |
| for usage, idle, movement, cost in X: | |
| if usage < 5 and idle > 15: | |
| y.append(1) # Pause Rent | |
| elif idle > 10 and movement < 2: | |
| y.append(0) # Move | |
| elif cost > 80: | |
| y.append(3) # Replace | |
| else: | |
| y.append(2) # Repair | |
| y = np.array(y) | |
| # Train logistic regression model | |
| model = LogisticRegression(multi_class='ovr', max_iter=200) | |
| model.fit(X, y) | |
| # Save model to disk | |
| joblib.dump(model, "equipment_utilization_model.joblib") | |
| print("Model trained and saved as 'equipment_utilization_model.joblib'") | |