initial commit#1
Conversation
Lundez
left a comment
There was a problem hiding this comment.
You wanted someone to chop your code to pieces, consider it done 🪓
|
|
||
| def prepareData(stockData): | ||
| pd_data = pd.read_csv(stockData) | ||
| X = pd_data["Open"] |
There was a problem hiding this comment.
How about keep using pandas through the whole code...?
| return X, Y | ||
|
|
||
| if __name__ == "__main__": | ||
| baselineWithHistory("../generateStockData/data/EVO.ST_2020-01-01_2020-05-31.csv") No newline at end of file |
There was a problem hiding this comment.
Pretty bad & dangerous pathing. Works for now though.
There was a problem hiding this comment.
Y, only works if the other user has created that exact file together with the data folder. Any suggestions to make it pretty?
| print("-----------------------------") | ||
|
|
||
| def createHistoryData(X, Y, days): | ||
| X = [[X[j] for j in range(i, i+days)] for i in range(0, len(X)-days)] |
There was a problem hiding this comment.
This ordo is not beautiful, you can do better ;)
| @@ -0,0 +1,18 @@ | |||
| def splitData(X, Y, amount): | |||
| X, Y = hf.createHistoryData(X, Y, 10) | ||
| X_train, X_test, Y_train, Y_test = hf.splitData(X, Y, 0.75) | ||
| regr = LinearRegression() | ||
| regr.fit(X_train, Y_train) |
There was a problem hiding this comment.
Let's make this better by using sklearn tools to print the f1-score etc.
|
|
||
| def generateData(stocks, start_date, end_date): | ||
| for stock in stocks: | ||
| panel_data = data.DataReader(stock, start=start_date, end=end_date, data_source='yahoo') |
There was a problem hiding this comment.
Cool, didn't know pandas had this functionality!
| if __name__ == "__main__": | ||
| start_date = "2019-01-01" | ||
| end_date = "2020-05-31" | ||
| generateData(["INVE-B.ST", "EVO.ST"], start_date, end_date) No newline at end of file |
There was a problem hiding this comment.
What does those map too? I "enjoy" how you mix raw strings with named ones ;)
| @@ -0,0 +1,30 @@ | |||
| import pandas as pd | |||
| from sklearn.linear_model import LinearRegression | |||
| import helpFunctions as hf | |||
There was a problem hiding this comment.
camelCase? How about snake_case please
| @@ -0,0 +1,30 @@ | |||
| import pandas as pd | |||
| from sklearn.linear_model import LinearRegression | |||
There was a problem hiding this comment.
Should test more models! Take a look at my code (it's not good though, but it displays a little you might learn something from)
No description provided.