Exemple #1
0
def build_route_models(route, variant=0):
    """
    For a variant of a route, construct a set of models representing that route

    """

    all_stops = prep_data(route)
    from dbanalysis.classes import stop_link_model as slm
    stops_dictionary = json.loads(
        open('/home/student/dbanalysis/stops_trimmed.json', 'r').read())
    rts_dictionary = rts = json.loads(
        open('/home/student/dbanalysis/trimmed_routes.json', 'r').read())
    rt = rts_dictionary[route][variant]
    models = []
    for i in range(1, len(rt) - 1):
        fromstop = rt[i]
        tostop = rt[i + 1]
        data = all_stops[(all_stops['fromstop'] == fromstop)
                         & (all_stops['tostop'] == tostop)]
        stop_data = stops_dictionary[str(fromstop)]
        models.append(
            slm.stop_link_model(fromstop,
                                tostop,
                                data,
                                stop_data,
                                clf='neural'))

    return models
 def train_models(self):
     """
     Train models for this stop. Currently, it is agnostic as to the route being modelled for
     """
     from dbanalysis.classes import stop_link_model as slm
     data = self.get_all_data()
     self.linkmodels = {}
     for link in self.stop_links:
         in_data = data[data['stopB']==link]            
         self.linkmodels[link] = slm.stop_link_model(self.stop_id, link, in_data,clf='Linear')
     del data
     del in_data
Exemple #3
0
 def train_models(self, split=None):
     """
     Train models for this stop. Currently, it is agnostic as to the route being modelled for.
     Later, there should probably be seperate dwell time models for every route, though this is a bit
     of a burden I think. Or the dwell time model will have to accept route id as a feature.
     """
     from dbanalysis.classes import stop_link_model_refac as slm
     data = self.get_all_data()
     self.linkmodels = {}
     for link in self.stop_links:
         in_data = data[data['stopB'] == link]
         self.linkmodels[link] = slm.stop_link_model(self.stop_id, link,\
                                  in_data,clf=self.regressor_type,train_test=split,\
                                     dimension = self.dimension,\
                                     model_dwell_time=self.model_dwell_time)
         del in_data
     #make sure to delete all data.
     del data