def starcraft_sp_test(): # Create DataLoader instance to load and format data dataLoader = DataLoader() logging.info("Program started") logging.info("Loading starcraft data") # Read skillcraft dataset, the class index is the second column dataLoader.read(filename="data/SkillCraft1_Dataset.csv", classIndex=1, numOfFeatures=15) # Normalize data values from 0 - 1 #dataLoader.normalize() # Create new labels to fit into binary classification dataLoader.scaleToBinary(5) # Spectral Clustering # Binary clustering(dataLoader.x_train, dataLoader.y_train, writer_starcraft, 'starcraft-binary', multiple=True, binary=True) # Multiclass #clustering(dataLoader.x_train, dataLoader.multi_y_train, writer_starcraft, 'starcraft-multiclass', multiple=True, binary=False) # Write all the results writer_starcraft.save()
def starcraft_svm_test(): # Create DataLoader instance to load and format data dataLoader = DataLoader() logging.info("Program started") logging.info("Loading starcraft data") # Read skillcraft dataset, the class index is the second column dataLoader.read(filename="data/SkillCraft1_Dataset.csv", classIndex=1, numOfFeatures=15) multi_label_count = dataLoader.labelCount(8) # Creates plots for a few of the data features # dataLoader.visualize() # Normalize data values from 0 - 1 #dataLoader.normalize() # Create new labels to fit into binary classification dataLoader.scaleToBinary(5) label_count = dataLoader.binaryLabelCount(5) logging.info("Number of examples per class") logging.info("Casual - (1): " + str(label_count[0])) logging.info("Hardcore - (-1): " + str(label_count[1])) label_count = dataLoader.labelCount(8) logDataCount(label_count) """ # Create SVM svm = SVM() # Train and predict for binary svm logging.info("Running SVM for binary classification") # Train for binary single run with these objects logging.info("Single binary SVM") svm.train(dataLoader.x_train, dataLoader.y_train, dataLoader.x_test, dataLoader.y_test) # Train and test binary svm multiple times for all available binary variables logging.info("Multiple runs with different parameters - binary SVM") svm.train(dataLoader.x_train, dataLoader.y_train, dataLoader.x_test, dataLoader.y_test, iterate=True) # Save binary results to excel sheet logging.info("Saving binary SVM results") svm.results.to_excel(writer_starcraft, sheet_name='binary-svm') # MULTI CLASS SVM logging.info("Running SVM for multiclass classification") # Train and predict for multi-class data using the linear svm from liblinear implementation logging.info("Running SVM for multiclass classification with liblinear implementation") svm.train(dataLoader.x_train, dataLoader.multi_y_train, dataLoader.x_test, dataLoader.multi_y_test, binary=False) logging.info("Saving multiclass liblinear results") svm.results.to_excel(writer_starcraft, sheet_name='multiclass-liblinear') # Train for multi-class single run with these objects using the libsvm implementation logging.info("Running SVM for multiclass classification with libsvm implementation") svm.train(dataLoader.x_train, dataLoader.multi_y_train, dataLoader.x_test, dataLoader.multi_y_test, binary=False, linear=False) logging.info("Saving multiclass libsvm results") svm.results.to_excel(writer_starcraft, sheet_name='multiclass-libsvm') # Train and test multi-class svm multiple times for all available multi-class variables logging.info("Running SVM for multiclass classification for all available multi-class variables") svm.train(dataLoader.x_train, dataLoader.multi_y_train, dataLoader.x_test, dataLoader.multi_y_test, iterate=True, binary=False) logging.info("Saving multiclass multiple-runs results") svm.results.to_excel(writer_starcraft, sheet_name='multiclass-multiple-variables') # Train and test multi-class svm multiple times with KPCA-LDA logging.info("Running SVM for multiclass classification with KPCA-LDA") svm.train(dataLoader.x_train, dataLoader.multi_y_train, dataLoader.x_test, dataLoader.multi_y_test, iterate=True, binary=False, decomposition=True) logging.info("Saving multiclass multiple-runs results") svm.results.to_excel(writer_starcraft, sheet_name='multiclass-kpca-lda') # KNN and NC nearest(dataLoader.x_train, dataLoader.y_train, dataLoader.x_test, dataLoader.y_test, dataLoader.multi_y_train, dataLoader.multi_y_test, writer_starcraft) """ clustering(dataLoader.x_train, dataLoader.y_train, dataLoader.x_test, dataLoader.y_test) # Write all the results writer_starcraft.save()