Spaces:
Runtime error
Runtime error
Commit
·
75004a2
1
Parent(s):
46d90b6
Delete app.py
Browse files
app.py
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
# Simple Linear Regression
|
2 |
-
|
3 |
-
# Importing the libraries
|
4 |
-
import numpy as np
|
5 |
-
import matplotlib.pyplot as plt
|
6 |
-
import pandas as pd
|
7 |
-
|
8 |
-
# Importing the dataset
|
9 |
-
dataset = pd.read_csv('Salary_Data.csv')
|
10 |
-
X = dataset.iloc[:, :-1].values
|
11 |
-
y = dataset.iloc[:, -1].values
|
12 |
-
|
13 |
-
# Splitting the dataset into the Training set and Test set
|
14 |
-
from sklearn.model_selection import train_test_split
|
15 |
-
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 1/3, random_state = 0)
|
16 |
-
|
17 |
-
# Training the Simple Linear Regression model on the Training set
|
18 |
-
from sklearn.linear_model import LinearRegression
|
19 |
-
regressor = LinearRegression()
|
20 |
-
regressor.fit(X_train, y_train)
|
21 |
-
|
22 |
-
# Predicting the Test set results
|
23 |
-
y_pred = regressor.predict(X_test)
|
24 |
-
|
25 |
-
# Visualising the Training set results
|
26 |
-
plt.scatter(X_train, y_train, color = 'red')
|
27 |
-
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
|
28 |
-
plt.title('Salary vs Experience (Training set)')
|
29 |
-
plt.xlabel('Years of Experience')
|
30 |
-
plt.ylabel('Salary')
|
31 |
-
plt.show()
|
32 |
-
|
33 |
-
# Visualising the Test set results
|
34 |
-
plt.scatter(X_test, y_test, color = 'red')
|
35 |
-
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
|
36 |
-
plt.title('Salary vs Experience (Test set)')
|
37 |
-
plt.xlabel('Years of Experience')
|
38 |
-
plt.ylabel('Salary')
|
39 |
-
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|