how to use SVM to match the testing data having one in result? [on hold]
Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
why svm result do not have one in result?
how to calculate result having one which is correct with testing data?
Description:
i use eigenvalues as features and label 1 when match future value,
and label 0 for the rest not match,
training 20 rows data and testing 20 rows data
if rising within range 10 dollars and dropping within range 10 dollars considered, each increment is 0.1 dollar, so 200 training data for one day
from numpy import linalg as LA
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
import pandas as pd
import datetime as dt
import re
import numpy as np
from dateutil import parser
import datetime
from sklearn import datasets
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn.externals import joblib
from sklearn import metrics
from sklearn.model_selection import learning_curve
from sklearn.svm import SVC
from sklearn.model_selection import validation_curve
currentdirectory = os.getcwd()
data = pd.read_excel(os.path.join(currentdirectory,"0005.HK2017.xls"), '0005.HK')
df = pd.DataFrame()
df = df.append(data)
ii = 1
jj = df['Close'][1:].tolist()
n = 0
y_train =
x_train =
testing = 20
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
#clf = svm.SVC(kernel='linear')
clf = svm.SVC()
clf.fit(x_train, y_train)
y_test =
x_test =
testing = 0
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
result = clf.predict(np.asarray(x_test))
metrics.f1_score(y_test, result, average='macro')
np.savetxt("runningresult.csv", result, delimiter=",")
np.savetxt("y_test.csv", y_test, delimiter=",")
There should be at least one one in result if it match
for i in range(1, 2):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
machine-learning
put on hold as off-topic by amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos
add a comment |Â
up vote
-1
down vote
favorite
why svm result do not have one in result?
how to calculate result having one which is correct with testing data?
Description:
i use eigenvalues as features and label 1 when match future value,
and label 0 for the rest not match,
training 20 rows data and testing 20 rows data
if rising within range 10 dollars and dropping within range 10 dollars considered, each increment is 0.1 dollar, so 200 training data for one day
from numpy import linalg as LA
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
import pandas as pd
import datetime as dt
import re
import numpy as np
from dateutil import parser
import datetime
from sklearn import datasets
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn.externals import joblib
from sklearn import metrics
from sklearn.model_selection import learning_curve
from sklearn.svm import SVC
from sklearn.model_selection import validation_curve
currentdirectory = os.getcwd()
data = pd.read_excel(os.path.join(currentdirectory,"0005.HK2017.xls"), '0005.HK')
df = pd.DataFrame()
df = df.append(data)
ii = 1
jj = df['Close'][1:].tolist()
n = 0
y_train =
x_train =
testing = 20
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
#clf = svm.SVC(kernel='linear')
clf = svm.SVC()
clf.fit(x_train, y_train)
y_test =
x_test =
testing = 0
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
result = clf.predict(np.asarray(x_test))
metrics.f1_score(y_test, result, average='macro')
np.savetxt("runningresult.csv", result, delimiter=",")
np.savetxt("y_test.csv", y_test, delimiter=",")
There should be at least one one in result if it match
for i in range(1, 2):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
machine-learning
put on hold as off-topic by amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos
Do you really think that anybody can understand your code, which is without any comment? Moreover, are you sure that this question is about mathematics?
â Taroccoesbrocco
13 hours ago
i add description
â HYL
13 hours ago
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
why svm result do not have one in result?
how to calculate result having one which is correct with testing data?
Description:
i use eigenvalues as features and label 1 when match future value,
and label 0 for the rest not match,
training 20 rows data and testing 20 rows data
if rising within range 10 dollars and dropping within range 10 dollars considered, each increment is 0.1 dollar, so 200 training data for one day
from numpy import linalg as LA
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
import pandas as pd
import datetime as dt
import re
import numpy as np
from dateutil import parser
import datetime
from sklearn import datasets
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn.externals import joblib
from sklearn import metrics
from sklearn.model_selection import learning_curve
from sklearn.svm import SVC
from sklearn.model_selection import validation_curve
currentdirectory = os.getcwd()
data = pd.read_excel(os.path.join(currentdirectory,"0005.HK2017.xls"), '0005.HK')
df = pd.DataFrame()
df = df.append(data)
ii = 1
jj = df['Close'][1:].tolist()
n = 0
y_train =
x_train =
testing = 20
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
#clf = svm.SVC(kernel='linear')
clf = svm.SVC()
clf.fit(x_train, y_train)
y_test =
x_test =
testing = 0
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
result = clf.predict(np.asarray(x_test))
metrics.f1_score(y_test, result, average='macro')
np.savetxt("runningresult.csv", result, delimiter=",")
np.savetxt("y_test.csv", y_test, delimiter=",")
There should be at least one one in result if it match
for i in range(1, 2):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
machine-learning
why svm result do not have one in result?
how to calculate result having one which is correct with testing data?
Description:
i use eigenvalues as features and label 1 when match future value,
and label 0 for the rest not match,
training 20 rows data and testing 20 rows data
if rising within range 10 dollars and dropping within range 10 dollars considered, each increment is 0.1 dollar, so 200 training data for one day
from numpy import linalg as LA
import numpy as np
import matplotlib.pyplot as plt
import sys
import os
import pandas as pd
import datetime as dt
import re
import numpy as np
from dateutil import parser
import datetime
from sklearn import datasets
import matplotlib.pyplot as plt
from sklearn import svm
from sklearn.externals import joblib
from sklearn import metrics
from sklearn.model_selection import learning_curve
from sklearn.svm import SVC
from sklearn.model_selection import validation_curve
currentdirectory = os.getcwd()
data = pd.read_excel(os.path.join(currentdirectory,"0005.HK2017.xls"), '0005.HK')
df = pd.DataFrame()
df = df.append(data)
ii = 1
jj = df['Close'][1:].tolist()
n = 0
y_train =
x_train =
testing = 20
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_train.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_train.append(1)
else:
y_train.append(0)
#clf = svm.SVC(kernel='linear')
clf = svm.SVC()
clf.fit(x_train, y_train)
y_test =
x_test =
testing = 0
for i in range(1+testing, 10+testing):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]+j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
x_test.append(list(w))
if jj[i+0]-j*0.1 == jj[i-1]:
y_test.append(1)
else:
y_test.append(0)
result = clf.predict(np.asarray(x_test))
metrics.f1_score(y_test, result, average='macro')
np.savetxt("runningresult.csv", result, delimiter=",")
np.savetxt("y_test.csv", y_test, delimiter=",")
There should be at least one one in result if it match
for i in range(1, 2):
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]+j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
for j in range(1, 100):
w, v = LA.eig(np.array([[jj[i+0]-j*0.1,jj[i+1],jj[i+2]], [jj[i+3],jj[i+4],jj[i+5]],[jj[i+6],jj[i+7],jj[i+7]]]))
if clf.predict([w]) == 1:
print(jj[i+0]+j*0.1)
machine-learning
edited 5 hours ago
Khovanov
105
105
asked 14 hours ago
HYL
121
121
put on hold as off-topic by amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos
put on hold as off-topic by amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos 13 hours ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â amWhy, Siong Thye Goh, Arnaud Mortier, max_zorn, José Carlos Santos
Do you really think that anybody can understand your code, which is without any comment? Moreover, are you sure that this question is about mathematics?
â Taroccoesbrocco
13 hours ago
i add description
â HYL
13 hours ago
add a comment |Â
Do you really think that anybody can understand your code, which is without any comment? Moreover, are you sure that this question is about mathematics?
â Taroccoesbrocco
13 hours ago
i add description
â HYL
13 hours ago
Do you really think that anybody can understand your code, which is without any comment? Moreover, are you sure that this question is about mathematics?
â Taroccoesbrocco
13 hours ago
Do you really think that anybody can understand your code, which is without any comment? Moreover, are you sure that this question is about mathematics?
â Taroccoesbrocco
13 hours ago
i add description
â HYL
13 hours ago
i add description
â HYL
13 hours ago
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Do you really think that anybody can understand your code, which is without any comment? Moreover, are you sure that this question is about mathematics?
â Taroccoesbrocco
13 hours ago
i add description
â HYL
13 hours ago