def main(targets): global test_flag if 'data' in targets: HW1.main() if 'test-project' in targets: beg = time.time() test_flag = 1 sample_size, categories = HW2.loadConfig("config/test-params.json") paths = HW2.loadEnv("config/env.json") HW2.getTestData(categories, sample_size) smalis = HW2.prepare_data(test_flag) df, xy = HW2.makeDF(smalis) train_df, train_y, test_df, test_y = HW2.splitTrain(df, xy) A_train = HW2.makeA(train_df, train_df["apps"].unique(), df.shape[0]) P_train = HW2.makeP(train_df, df.shape[0]) A_test = HW2.makeA(test_df, test_df["apps"].unique(), df.shape[0]) P_test = HW2.makeP(test_df, df.shape[0]) #y = [i[1] for i in xy] AAT_train = A_train.dot( A_train.T) #HW2.matrixply([A_train, A_train.T]) AATest = A_test.dot(A_train.T) clf = HW2.trainModel(AAT_train, train_y) preds = HW2.modelPredict(clf, AATest) HW2.getMetrics(preds, test_y, paths["AA^T"], "AA^T") APAT_train = A_train.dot(P_train).dot(A_train.T) APATest = A_test.dot(P_test).dot(A_train.T) clf = HW2.trainModel(APAT_train, train_y) preds = HW2.modelPredict(clf, APATest) HW2.getMetrics(preds, test_y, paths["APA^T"], "APA^T") B_train = HW2.makeB(train_df, df.shape[0]) B_test = HW2.makeB(test_df, df.shape[0]) ABAT_train = A_train.dot(B_train).dot(A_train.T) ABATest = A_test.dot(B_test).dot(A_train.T) clf = HW2.trainModel(ABAT_train, train_y) preds = HW2.modelPredict(clf, ABATest) HW2.getMetrics(preds, test_y, paths["ABA^T"], "ABA^T") APBPTAT_train = A_train.dot(P_train).dot(B_train).dot(P_train.T).dot( A_train.T) APBPTATest = A_test.dot(P_test).dot(B_test).dot(P_train.T).dot( A_train.T) clf = HW2.trainModel(APBPTAT_train, train_y) preds = HW2.modelPredict(clf, APBPTATest) HW2.getMetrics(preds, test_y, paths["APBP^TA^T"], "APBP^TA^T") if 'process' in targets: #cleans and prepares the data for analysis #smalis = getAllSmaliFiles("Apps") print(test_flag) smalis = HW2.prepare_data(test_flag) x, y = HW2.makeBaselineFeatures(smalis) HW2.baseline(x, y) return
def main(targets): global test_flag if 'data' in targets: HW1.main() if 'test-data' in targets: test_flag = 1 HW2.getTestData() if 'process' in targets: #cleans and prepares the data for analysis #smalis = getAllSmaliFiles("Apps") print(test_flag) smalis = HW2.prepare_data(test_flag) x, y = HW2.makeBaselineFeatures(smalis) HW2.baseline(x, y) return