how to use SVM to match the testing data having one in result? [on hold]

The name of the pictureThe name of the pictureThe name of the pictureClash 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)






share|cite|improve this question













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
If this question can be reworded to fit the rules in the help center, please edit the question.












  • 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














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)






share|cite|improve this question













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
If this question can be reworded to fit the rules in the help center, please edit the question.












  • 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












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)






share|cite|improve this question













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)








share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








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
If this question can be reworded to fit the rules in the help center, please edit the question.




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
If this question can be reworded to fit the rules in the help center, please edit the question.











  • 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











  • 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















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Relationship between determinant of matrix and determinant of adjoint?

Color the edges and diagonals of a regular polygon