Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

initial commit #1

wants to merge 5 commits into from

Conversation

denkhan
Copy link

@denkhan denkhan commented Jun 6, 2020

No description provided.

Copy link
Member

@Lundez Lundez left a 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"]
Copy link
Member

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...?

return X, Y

if __name__ == "__main__":
baselineWithHistory("../generateStockData/data/EVO.ST_2020-01-01_2020-05-31.csv")
Copy link
Member

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.

Copy link
Author

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?

print("-----------------------------")

def createHistoryData(X, Y, days):
X = [[X[j] for j in range(i, i+days)] for i in range(0, len(X)-days)]
Copy link
Member

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):
Copy link
Member

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)
Copy link
Member

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')
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants