This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
YearsExperience,Salary | ||
1.1,39343.00 | ||
1.3,46205.00 | ||
1.5,37731.00 | ||
2.0,43525.00 | ||
2.2,39891.00 | ||
2.9,56642.00 | ||
3.0,60150.00 | ||
3.2,54445.00 | ||
3.2,64445.00 | ||
3.7,57189.00 | ||
3.9,63218.00 | ||
4.0,55794.00 | ||
4.0,56957.00 | ||
4.1,57081.00 | ||
4.5,61111.00 | ||
4.9,67938.00 | ||
5.1,66029.00 | ||
5.3,83088.00 | ||
5.9,81363.00 | ||
6.0,93940.00 | ||
6.8,91738.00 | ||
7.1,98273.00 | ||
7.9,101302.00 | ||
8.2,113812.00 | ||
8.7,109431.00 | ||
9.0,105582.00 | ||
9.5,116969.00 | ||
9.6,112635.00 | ||
10.3,122391.00 | ||
10.5,121872.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
observation_date,ECOMSA | ||
2011-01-01,9668.86 | ||
2011-04-01,10795.59 | ||
2011-07-01,12959.36 | ||
2011-10-01,11680.76 | ||
2012-01-01,13919.98 | ||
2012-04-01,14334.31 | ||
2012-07-01,16510.52 | ||
2012-10-01,15500.27 | ||
2013-01-01,15993.59 | ||
2013-04-01,15956.83 | ||
2013-07-01,19535.96 | ||
2013-10-01,17628.57 | ||
2014-01-01,19905.05 | ||
2014-04-01,19370.01 | ||
2014-07-01,22609.42 | ||
2014-10-01,20847.64 | ||
2015-01-01,25160.03 | ||
2015-04-01,26376.12 | ||
2015-07-01,30709.11 | ||
2015-10-01,28427.74 | ||
2016-01-01,31770.19 | ||
2016-04-01,33540.70 | ||
2016-07-01,35564.10 | ||
2016-10-01,36377.03 | ||
2017-01-01,41252.10 | ||
2017-04-01,47138.21 | ||
2017-07-01,56096.90 | ||
2017-10-01,52838.28 | ||
2018-01-01,56672.95 | ||
2018-04-01,63083.56 | ||
2018-07-01,76672.68 | ||
2018-10-01,75088.54 | ||
2019-01-01,78769.81 | ||
2019-04-01,87255.83 | ||
2019-07-01,99103.90 | ||
2019-10-01,103265.11 | ||
2020-01-01,101339.37 | ||
2020-04-01,111949.08 | ||
2020-07-01,148634.52 | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
observation_date,ECOMSA | ||
2011,45104.57 | ||
2012,60265.08 | ||
2013,69114.95 | ||
2014,82732.12 | ||
2015,110673 | ||
2016,137252 | ||
2017,197325.5 | ||
2018,271517.7 | ||
2019,368394.7 | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, | ||
, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
|
||
dataset = pd.read_csv('fortensor.csv') | ||
X = dataset.iloc[:,:-1].values #independent variable array | ||
y = dataset.iloc[:,1].values #dependent variable vector | ||
|
||
from sklearn.model_selection import train_test_split | ||
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=1/3,random_state=0) | ||
|
||
from sklearn.linear_model import LinearRegression | ||
regressor = LinearRegression() | ||
regressor.fit(X_train,y_train) #actually produces the linear eqn for the data | ||
y_pred = regressor.predict(X_test) | ||
print("y is \n",y_pred) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pandas as pd | ||
|
||
# create dataset | ||
df = pd.DataFrame({'dates': [2011,2012,2013,2014,2015,2016,2017,2018,2019], | ||
'score': [45104.57, 60265.08, 69114.95, 82732.12, 110673, 137252, 197325.5, 271517.7, 368394.7]}) | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
plt.scatter(df.dates, df.score) | ||
plt.title('Hours studied vs. Exam Score') | ||
plt.xlabel('Hours') | ||
plt.ylabel('Score') | ||
plt.show() | ||
|
||
df.boxplot(column=['score']) | ||
import statsmodels.api as sm | ||
|
||
#define response variable | ||
y = df['score'] | ||
|
||
#define explanatory variable | ||
x = df[['dates']] | ||
|
||
#add constant to predictor variables | ||
x = sm.add_constant(x) | ||
|
||
#fit linear regression model | ||
model = sm.OLS(y, x).fit() | ||
|
||
#view model summary | ||
print(model.summary()) | ||
#define figure size | ||
fig = plt.figure(figsize=(12,8)) | ||
|
||
#produce residual plots | ||
fig = sm.graphics.plot_regress_exog(model, 'dates', fig=fig) | ||
|
||
#define residuals | ||
res = model.resid | ||
|
||
#create Q-Q plot | ||
fig = sm.qqplot(res, fit=True, line="45") | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import tensorflow as tf | ||
import pandas as pd | ||
from tensorflow import keras | ||
import numpy as np | ||
|
||
def house_model(y_new): | ||
xs = np.array([20.11,20.12,20.13,20.14,20.15,20.16,20.17,20.18,20.19]) | ||
ys = np.array([100.0,150.0,200.0,250.0,300.0,350.0,400.0,450.0,500.0]) | ||
model = tf.keras.Sequential([keras.layers.Dense(units = 2,input_shape=[1])]) | ||
model.compile(optimizer='sgd',loss='mean_squared_error') | ||
model.fit(xs,ys,epochs=200) | ||
return model.predict(y_new)[0] | ||
|
||
test = house_model([30.12]) | ||
print(test) |