-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAzureMachineLearningScript.1.py
More file actions
40 lines (30 loc) · 1.21 KB
/
AzureMachineLearningScript.1.py
File metadata and controls
40 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# The script MUST contain a function named azureml_main
# which is the entry point for this module.
# imports up here can be used to
import pandas as pd
import numpy as np
# The entry point function can contain up to two input arguments:
def azureml_main(stock_data = None):
stock_data_length = len(stock_data)
prices = np.array(stock_data[stock_data.columns[0]]) # 株価データ
# 株価の上昇率を算出
modified_data = []
for i in range(1, stock_data_length):
modified_data.append(float(prices[i] - prices[i - 1]) / float(prices[i - 1]))
modified_data_length = len(modified_data)
# 前日までの2週間分の上昇率のデータ
sequential_data = []
# 正解値 価格上昇: 1 価格低下: 0
answers = []
day_range = 7 * 2 # 2週間
for day in range(day_range):
sequential_data.append([])
for i in range(day_range, modified_data_length):
sequential_data[day].append(modified_data[i - day_range + day])
for i in range(day_range, modified_data_length):
answers.append(1 if modified_data[i] > 0 else 0)
result = pd.DataFrame()
for i in range(day_range):
result["Rate" + str(i)] = sequential_data[0]
result["Answer"] = answers
return result