Esempio n. 1
0
def KNN(trainning_X, train_Y, predict_X, task_name, origin_data, stock_id):
    clf = KNeighborsClassifier(5)
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name, clf_name="KNN(5)", result=res_)
    tsk.save()
Esempio n. 2
0
def SVC(trainning_X, train_Y, predict_X, task_name, origin_data, stock_id):
    clf = svm.SVC(gamma=2, C=1)
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name, clf_name="RBF SVM", result=res_)
    tsk.save()
Esempio n. 3
0
def adaboost(trainning_X, train_Y, predict_X, task_name, origin_data,
             stock_id):
    clf = AdaBoostClassifier()
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name, clf_name="adaboost", result=res_)
    tsk.save()
Esempio n. 4
0
def RandomForest(trainning_X, train_Y, predict_X, task_name, origin_data,
                 stock_id):
    clf = RandomForestClassifier(max_depth=5, n_estimators=10, max_features=1)
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name,
                          clf_name="Random Forest",
                          result=res_)
    tsk.save()
Esempio n. 5
0
def DecisionTree(trainning_X, train_Y, predict_X, task_name, origin_data,
                 stock_id):
    clf = DecisionTreeClassifier(max_depth=5)
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name,
                          clf_name="Decision Tree",
                          result=res_)
    tsk.save()
Esempio n. 6
0
def LinearDiscriminant(trainning_X, train_Y, predict_X, task_name, origin_data,
                       stock_id):
    clf = LinearDiscriminantAnalysis()
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name,
                          clf_name="Linear Discriminant Analysis",
                          result=res_)
    tsk.save()
Esempio n. 7
0
def Gaussian(trainning_X, train_Y, predict_X, task_name, origin_data,
             stock_id):
    clf = GaussianNB()
    clf.fit(trainning_X, train_Y)
    res = clf.predict(predict_X)
    res_ = []
    for i in range(len(res)):
        if res[i] == 1:
            res_.append(origin_data[stock_id][i])
    tsk = training_result(taskName=task_name,
                          clf_name="GaussianNB",
                          result=res_)
    tsk.save()