Download ML_Model.py from prathamg007/Mission_Impossible: direct link, hf CLI and curl.
- Browser
- Download file 877 Bytes
-
https://huggingface.co/prathamg007/Mission_Impossible/resolve/main/ML_Model.py
- Command line
-
hf download hf://prathamg007/Mission_Impossible/ML_Model.py
-
curl -L -o ML_Model.py https://huggingface.co/prathamg007/Mission_Impossible/resolve/main/ML_Model.py
877 Bytes
| import pandas as pd | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.metrics import mean_squared_error | |
| df = pd.read_csv("normalized_train_dataset_with_train_number.csv") | |
| X = df[["departure_station", "arrival_station", "departure_time", "arrival_time", "day_of_week", "train_type", "distance_km"]] | |
| y = df["train_number"] #Defining features and target | |
| model = LinearRegression() #Initializing the model | |
| model.fit(X, y) # Training the model | |
| weights = model.coef_ #Extracting weights and biases | |
| bias = model.intercept_ | |
| feature_names = X.columns | |
| print("Learned Weights:") | |
| for feature, weight in zip(feature_names, weights): | |
| print(f"{feature}: {weight:.4f}") | |
| print(f"\nLearned Bias (Intercept): {bias:.4f}") | |
| y_pred = model.predict(X) # Evaluate the model | |
| mse = mean_squared_error(y, y_pred) | |
| print(f"\nMean Squared Error on Training Data: {mse:.4f}") |