-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial commit #1
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about keep using pandas
through the whole code...?
python/createModels/createModels.py
Outdated
return X, Y | ||
|
||
if __name__ == "__main__": | ||
baselineWithHistory("../generateStockData/data/EVO.ST_2020-01-01_2020-05-31.csv") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty bad & dangerous pathing. Works for now though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y, only works if the other user has created that exact file together with the data folder. Any suggestions to make it pretty?
python/createModels/helpFunctions.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ordo is not beautiful, you can do better ;)
@@ -0,0 +1,18 @@ | |||
def splitData(X, Y, amount): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use sklearn
train_test_split
It's awesome :)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.