features_obj = Features(pose_objects=pose_objects) features_obj.compute_features() # reduced_feature_matrix = features_obj.compute_pca() # print(reduced_feature_matrix) # print(len(reduced_feature_matrix),len(reduced_feature_matrix[0])) # X = reduced_feature_matrix X = features_obj.get_features() Y = [obj.label for obj in pose_objects] print(len(X), len(Y)) clf_rforest = Classification('RForest', X, Y) clf_rforest.get_classifier_object() clf_rforest.get_metrics() pickle.dump(clf_rforest.get_classifier(), open('RForest_model.pkl', 'wb')) print() clf_svm = Classification('svm', X, Y) clf_svm.get_classifier_object() clf_svm.get_metrics() pickle.dump(clf_svm.get_classifier(), open('SVM_model.pkl', 'wb')) print() clf_lda = Classification('lda', X, Y) clf_lda.get_classifier_object() clf_lda.get_metrics() pickle.dump(clf_lda.get_classifier(), open('LDA_model.pkl', 'wb')) clf_dt = Classification('logreg', X, Y) clf_dt.get_classifier_object()
# clf_deci = Classification('DeciTree', x, y) # clf_deci.get_classifier_object() # clf_deci.get_metrics() # pickle.dump(clf_deci.get_classifier(), open('DeciTree_model.pkl', 'wb')) # print() # clf_svm = Classification('svm', x, y) # clf_svm.get_classifier_object() # clf_svm.get_metrics() # pickle.dump(clf_svm.get_classifier(), open('svm_model.pkl', 'wb')) # print() clf_rforest = Classification('RForest', x, y) clf_rforest.get_classifier_object() clf_rforest.get_metrics() pickle.dump(clf_rforest.get_classifier(), open('RForest_model.pkl', 'wb')) print() clf = Classification('XGB', np.array(x), np.array(y)) clf.get_classifier_object() clf.get_metrics() pickle.dump(clf.get_classifier(), open('XGBoost_model.pkl', 'wb')) print() clf = Classification('NaiveBayes', np.array(x), np.array(y)) clf.get_classifier_object() clf.get_metrics() pickle.dump(clf.get_classifier(), open('NaiveBayes_model.pkl', 'wb')) print() clf = Classification('AdaBoost', np.array(x), np.array(y))