def get_records(): ''' get records from database ''' conn = module_io.db_connect() query = module_io.load_sql("../sql/query-features-train.sql") records = module_io.db_query(conn, query) return records
import module_io from sklearn.ensemble import RandomForestClassifier if __name__=="__main__": # look backwared & look forward look_backward = 29 look_forward = 4 # get records from database print "getting features from database" conn = module_io.db_connect() query = module_io.load_sql("../sql/query-features-test.sql") records = module_io.db_query(conn, query) # load model classifier = module_io.load_model("../model/benchmark.pickle") # clean features features = [] for record in records: vector_feature = list(record[1:]) for index in range(len(vector_feature)): if vector_feature[index] is None: vector_feature[index] = 0 features.append(vector_feature) # get features range_test = features[look_backward:(-look_forward)] features_test = [] for index in range(look_backward, len(features) - look_forward):
import module_io from sklearn.ensemble import RandomForestClassifier if __name__ == "__main__": # look backwared & look forward look_backward = 29 look_forward = 4 # get records from database print "getting features from database" conn = module_io.db_connect() query = module_io.load_sql("../sql/query-features-test.sql") records = module_io.db_query(conn, query) # load model classifier = module_io.load_model("../model/benchmark.pickle") # clean features features = [] for record in records: vector_feature = list(record[1:]) for index in range(len(vector_feature)): if vector_feature[index] is None: vector_feature[index] = 0 features.append(vector_feature) # get features range_test = features[look_backward:(-look_forward)] features_test = [] for index in range(look_backward, len(features) - look_forward):