-
Notifications
You must be signed in to change notification settings - Fork 0
/
someResults.py
79 lines (65 loc) · 2 KB
/
someResults.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm, preprocessing
import pandas as pd
from matplotlib import style
style.use("ggplot")
FEATURES = ['DE Ratio',
'Trailing P/E',
'Price/Sales',
'Price/Book',
'Profit Margin',
'Operating Margin',
'Return on Assets',
'Return on Equity',
'Revenue Per Share',
'Market Cap',
'Enterprise Value',
'Forward P/E',
'PEG Ratio',
'Enterprise Value/Revenue',
'Enterprise Value/EBITDA',
'Revenue',
'Gross Profit',
'EBITDA',
'Net Income Avl to Common ',
'Diluted EPS',
'Earnings Growth',
'Revenue Growth',
'Total Cash',
'Total Cash Per Share',
'Total Debt',
'Current Ratio',
'Book Value Per Share',
'Cash Flow',
'Beta',
'Held by Insiders',
'Held by Institutions',
'Shares Short (as of',
'Short Ratio',
'Short % of Float',
'Shares Short (prior ']
def Build_Data_Set():
data_df = pd.read_csv("key_stats_acc_perf_NO_NA.csv")
# data_df = data_df[:100]
data_df = data_df.reindex(np.random.permutation(data_df.index))
data_df.fillna(0)
X = np.array(data_df[FEATURES].values)
y = (data_df["Status"]
.replace("underperform",0)
.replace("outperform",1)
.values.tolist())
X = preprocessing.scale(X)
return X,y
def Analysis():
test_size = 1000
X, y = Build_Data_Set()
print(len(X))
clf = svm.SVC(kernel="linear", C=1.0)
clf.fit(X[:-test_size], y[:-test_size])
correct_count = 0
for x in range(1, test_size + 1):
if clf.predict(X[[-x]])[0] == y[-x]:
correct_count += 1
print("Accuracy:", (correct_count / test_size) * 100.00)
Analysis()