__author__ = 'Thong_Le' from libs.features import extractFeature, randomSample from libs.models import buildClassifer from libs.config import * # 1. Read txt data tupleData = store.loadTxtData() # 2. Extract features featureTuples = extractFeature(feature_func, preprocessing_func, tupleData) store.saveFeature(featureTuples) # 3.1 Random Training and Testing Data x = randomSample() store.saveTrainingTestingData(x) # 3.2 Load Training and Testing Data modelData = store.loadTrainingTestingData() # 3.3 Train model print('=> Training model...') clf_model = buildClassifer() clf_model.fit(modelData['X_train'], modelData['y_train']) y_hat = clf_model.predict(modelData['X_test']) print( 'Acc = ', sum([1 for (y1, y2) in zip(modelData['y_test'], y_hat) if (y1 == y2)]) / len(y_hat))
__author__ = 'Thong_Le' from libs.features import extractFeature, randomSample from libs.models import buildClassifer from libs.config import * # 1. Read txt data tupleData = store.loadTxtData() # 2. Extract features featureTuples = extractFeature(feature_func, preprocessing_func, tupleData) store.saveFeature(featureTuples) # 3.1 Random Training and Testing Data x = randomSample() store.saveTrainingTestingData(x) # 3.2 Load Training and Testing Data modelData = store.loadTrainingTestingData() # 3.3 Train model print('=> Training model...') clf_model = buildClassifer() clf_model.fit(modelData['X_train'], modelData['y_train']) y_hat = clf_model.predict(modelData['X_test']) print('Acc = ', sum([1 for (y1, y2) in zip(modelData['y_test'], y_hat) if (y1 == y2)]) / len(y_hat)) store.saveClassifier(clf_model) # 4. Test
def exc(): # store.loadFeatureCSV() # 4.1 Random Training and Testing Data x = randomSample() # store.saveTrainingTestingData(x) store.saveTrainingTestingDataCSV(x, getFeatureNames())
from libs import store from libs.features import extractFeature, randomSample from libs.models import buildClassifer from config import * # 1. Read txt data tupleData = store.loadTxtData() # 2. Extract features featureTuples = extractFeature(feature_func) store.saveFeature(featureTuples) accs = [] if (standard_data): X_train, y_train, X_test, y_test = randomSample() X_train, y_train, X_test, y_test = np.asarray(X_train), np.asarray( y_train), np.asarray(X_test), np.asarray(y_test) print('=> Testing model with static data...') for i in range(nTesting): # 3.3 Train model print('==> Training model ' + str(i) + '...') clf_model = buildClassifer() clf_model.fit(X_train, y_train) y_hat = clf_model.predict(X_test) tacc = sum([1 for (y1, y2) in zip(y_test, y_hat) if (y1 == y2) ]) / len(y_hat) print('<== Acc = ', tacc) accs.append(tacc)
from libs.features import extractFeature, randomSample from libs.models import buildClassifer from libs.config import * import numpy as np # 1. Read txt data tupleData = store.loadTxtData() # 2. Extract features featureTuples = extractFeature(feature_func, preprocessing_func, tupleData) store.saveFeature(featureTuples) accs = [] if (standard_data): X_train, y_train, X_test, y_test = randomSample() X_train, y_train, X_test, y_test = np.asarray(X_train), np.asarray(y_train), np.asarray(X_test), np.asarray(y_test) print('=> Testing model with static data...') for i in range(nTesting): # 3.3 Train model print('==> Training model ' + str(i) + '...') clf_model = buildClassifer() clf_model.fit(X_train, y_train) y_hat = clf_model.predict(X_test) tacc = sum([1 for (y1, y2) in zip(y_test, y_hat) if (y1 == y2)]) / len(y_hat) print('<== Acc = ', tacc) accs.append(tacc) else: print('=> Testing model with random data...')