diff options
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | notebook/ft_linear_regression_notebook.ipynb (renamed from ft_linear_regression_notebook.ipynb) | 0 | ||||
| -rw-r--r-- | notebook/ft_linear_regression_notebook.md (renamed from ft_linear_regression_notebook.md) | 0 | ||||
| -rw-r--r-- | notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_14_0.png (renamed from ft_linear_regression_notebook_files/ft_linear_regression_notebook_14_0.png) | bin | 7281 -> 7281 bytes | |||
| -rw-r--r-- | notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_17_0.png (renamed from ft_linear_regression_notebook_files/ft_linear_regression_notebook_17_0.png) | bin | 10346 -> 10346 bytes | |||
| -rw-r--r-- | notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_2_0.png (renamed from ft_linear_regression_notebook_files/ft_linear_regression_notebook_2_0.png) | bin | 6208 -> 6208 bytes | |||
| -rw-r--r-- | notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_4_0.png (renamed from ft_linear_regression_notebook_files/ft_linear_regression_notebook_4_0.png) | bin | 10044 -> 10044 bytes | |||
| -rw-r--r-- | notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_6_0.png (renamed from ft_linear_regression_notebook_files/ft_linear_regression_notebook_6_0.png) | bin | 10948 -> 10948 bytes | |||
| -rw-r--r-- | src/predict.py | 22 | ||||
| -rw-r--r-- | src/theta | 1 | ||||
| -rw-r--r-- | src/train.py | 32 |
11 files changed, 56 insertions, 1 deletions
@@ -4,4 +4,4 @@ ft\_linear\_regression project of school 42 # Explaination -Check out the jupyter notebook, markdown version [here](./ft_linear_regression_notebook.md). +Check out the jupyter notebook, markdown version [here](./notebook/ft_linear_regression_notebook.md). diff --git a/ft_linear_regression_notebook.ipynb b/notebook/ft_linear_regression_notebook.ipynb index 6b61b71..6b61b71 100644 --- a/ft_linear_regression_notebook.ipynb +++ b/notebook/ft_linear_regression_notebook.ipynb diff --git a/ft_linear_regression_notebook.md b/notebook/ft_linear_regression_notebook.md index 1754f62..1754f62 100644 --- a/ft_linear_regression_notebook.md +++ b/notebook/ft_linear_regression_notebook.md diff --git a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_14_0.png b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_14_0.png Binary files differindex 66ea667..66ea667 100644 --- a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_14_0.png +++ b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_14_0.png diff --git a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_17_0.png b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_17_0.png Binary files differindex 1394372..1394372 100644 --- a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_17_0.png +++ b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_17_0.png diff --git a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_2_0.png b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_2_0.png Binary files differindex 0da582d..0da582d 100644 --- a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_2_0.png +++ b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_2_0.png diff --git a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_4_0.png b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_4_0.png Binary files differindex efdd169..efdd169 100644 --- a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_4_0.png +++ b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_4_0.png diff --git a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_6_0.png b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_6_0.png Binary files differindex 4ed9c99..4ed9c99 100644 --- a/ft_linear_regression_notebook_files/ft_linear_regression_notebook_6_0.png +++ b/notebook/ft_linear_regression_notebook_files/ft_linear_regression_notebook_6_0.png diff --git a/src/predict.py b/src/predict.py new file mode 100644 index 0000000..85c7eac --- /dev/null +++ b/src/predict.py @@ -0,0 +1,22 @@ +class Predictor: + def __init__(self, filename='theta'): + self.filename = filename + self.theta1, self.theta0 = self.read_theta() + + def make_prediction(self, x): + return x * self.theta1 + self.theta0 + + def read_theta(self): + try: + with open(self.filename, 'r') as file: + strs = file.read().strip().split(",") + if len(strs) != 2: + raise "wrong theta file format" + return int(strs[0]), int(strs[1]) + except IOError: + print(self.filename, "do not exist") + +if __name__ == "__main__": + p = Predictor() + x = int(input("Enter a mileage: ")) + print("The predicted price for this mileage is", p.make_prediction(x)) diff --git a/src/theta b/src/theta new file mode 100644 index 0000000..15794e0 --- /dev/null +++ b/src/theta @@ -0,0 +1 @@ +0,0 diff --git a/src/train.py b/src/train.py new file mode 100644 index 0000000..a31d032 --- /dev/null +++ b/src/train.py @@ -0,0 +1,32 @@ +class Model: + def __init__(self, filename='../data.csv'): + self.datafile = filename + + def train(self): + pass + + def partial_theta1(self): + pass + + def partial_theta0(self): + pass + + def gradient_descent(self): + pass + + def read_data(self): + pass + + def normalize_data(self): + pass + + def write_theta(self): + pass + + +if __name__ == "__main__": + m = Model() + m.read_data() + m.normalize_data() + m.train() + m.write_theta() |
