Download test.py from soham901/smallML: direct link, hf CLI and curl.
- Browser
- Download file 997 Bytes
-
https://huggingface.co/soham901/smallML/resolve/main/test.py
- Command line
-
hf download hf://soham901/smallML/test.py
-
curl -L -o test.py https://huggingface.co/soham901/smallML/resolve/main/test.py
997 Bytes
| # house_price_prediction.py | |
| import pandas as pd | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.linear_model import LinearRegression | |
| from sklearn.metrics import mean_squared_error | |
| import joblib | |
| # Generate some sample data | |
| data = {'Size': [1400, 1600, 1700, 1875, 1100, 1550, 2350, 2450, 1425, 1700], | |
| 'Price': [245000, 312000, 279000, 308000, 199000, 219000, 405000, 324000, 319000, 255000]} | |
| df = pd.DataFrame(data) | |
| # Split the data into features (X) and target variable (y) | |
| X = df[['Size']] | |
| y = df['Price'] | |
| # Split the data into training and testing sets | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) | |
| # Train a linear regression model | |
| model = LinearRegression() | |
| model.fit(X_train, y_train) | |
| # Make predictions on the test set | |
| y_pred = model.predict(X_test) | |
| # Evaluate the model | |
| mse = mean_squared_error(y_test, y_pred) | |
| print(f'Mean Squared Error: {mse}') | |
| # Save the model | |
| joblib.dump(model, 'house_price_model.joblib') | |