def plot(): train_time,trainingX,trainingY = read_data(0,70000) test_time,testingX,testingY = read_data(130000,162000) plt.plot(trainingX[:,2], scale*trainingY, 'b.', markersize=6, label=u'Observations', color=BLUE) plt.xlabel('Time [s]') plt.ylabel('Acceleration [g]') plt.legend(loc='upper left') # Plot the training time series fig = plt.figure() plt.plot(train_time, scale*trainingY, 'b', label=u'Observations', color=BLUE) plt.xlabel('Time [s]') plt.ylabel('Acceleration [g]') plt.title('Predictions for Training Set') # Plot the testing time series fig = plt.figure() plt.plot(test_time, scale*testingY, 'b', label=u'Observations', color=BLUE) plt.xlabel('Time [s]') plt.ylabel('Acceleration [g]') plt.title('Bridge Acceleration') plt.legend(['Recorded time series','Predicted Values']) plt.xlim([660,700]) plt.savefig('test.png')
def run(self): # Get command line arguments and initialize test_dir with directory self.init_arguments() self.test_dir = self.args.directory # Get test_set by calling read_data from test_data.py test_set = test_data.read_data(self.test_dir) for test_doc in test_set.values(): # Initially creates a .key file from default rake and adds default keywords to the file self.get_keywords_for_key_file(test_doc) # Gets optimum parameters by using .key file created in previous step, and creates # a rake object using these parameters self.get_final_keywords(test_doc, test_set) print('Keywords will be stored in a .key file with the same name as the input file.')
__author__ = 'a_medelyan' import test_data import rake import sys # reading a directory with test documents input_dir = sys.argv[1] # number of top ranked keywords to evaluate top = int(sys.argv[2]) test_set = test_data.read_data(input_dir) best_fmeasure = 0 best_vals = [] for min_char_length in range(3, 8): for max_words_length in range(3, 6): for min_keyword_frequency in range(1, 7): rake_object = rake.Rake("SmartStoplist.txt", min_char_length, max_words_length, min_keyword_frequency) total_fmeasure = 0 for test_doc in test_set.values(): keywords = rake_object.run(test_doc.text) num_manual_keywords = len(test_doc.keywords) correct = 0 try: for i in range(0, min(top, len(keywords))): if keywords[i][0] in set(test_doc.keywords): correct += 1
from __future__ import absolute_import from __future__ import print_function from six.moves import range __author__ = 'a_medelyan' import test_data import rake import sys # reading a directory with test documents input_dir = sys.argv[1] # number of top ranked keywords to evaluate top = int(sys.argv[2]) test_set = test_data.read_data(input_dir) best_fmeasure = 0 best_vals = [] for min_char_length in range(3,8): for max_words_length in range(3,6): for min_keyword_frequency in range(1,7): rake_object = rake.Rake("SmartStoplist.txt", min_char_length, max_words_length, min_keyword_frequency) total_fmeasure = 0 for test_doc in test_set.values(): keywords = rake_object.run(test_doc.text) num_manual_keywords = len(test_doc.keywords) correct = 0 try: for i in range(0,min(top, len(keywords))):