V8055 commited on
Commit
0b03d9d
·
verified ·
1 Parent(s): 6e33b23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -20
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import numpy as np
2
  import pandas as pd
3
- import matplotlib.pyplot as plt
4
  from sklearn.model_selection import train_test_split
5
  from sklearn.linear_model import LinearRegression
6
  from sklearn.metrics import mean_squared_error, r2_score
@@ -41,22 +41,5 @@ print(f"Training R²: {train_r2:.4f}")
41
  print(f"Test R²: {test_r2:.4f}")
42
  print(f"\nModel Equation: y = {model.coef_[0]:.4f}x + {model.intercept_:.4f}")
43
 
44
- # Create visualization
45
- plt.figure(figsize=(10, 6))
46
-
47
- # Plot training data
48
- plt.scatter(X_train, y_train, color='blue', alpha=0.5, label='Training Data')
49
- # Plot test data
50
- plt.scatter(X_test, y_test, color='green', alpha=0.5, label='Test Data')
51
-
52
- # Plot regression line
53
- X_line = np.linspace(0, 10, 100).reshape(-1, 1)
54
- y_line = model.predict(X_line)
55
- plt.plot(X_line, y_line, color='red', label='Regression Line')
56
-
57
- plt.xlabel('X')
58
- plt.ylabel('y')
59
- plt.title('Linear Regression: Training and Test Data with Regression Line')
60
- plt.legend()
61
- plt.grid(True, alpha=0.3)
62
- plt.show()
 
1
  import numpy as np
2
  import pandas as pd
3
+
4
  from sklearn.model_selection import train_test_split
5
  from sklearn.linear_model import LinearRegression
6
  from sklearn.metrics import mean_squared_error, r2_score
 
41
  print(f"Test R²: {test_r2:.4f}")
42
  print(f"\nModel Equation: y = {model.coef_[0]:.4f}x + {model.intercept_:.4f}")
43
 
44
+
45
+