Пример #1
0
 def _preprocess(self, x, y, valid_x, valid_y):
     self.normalize_x = data_helper.normalizeX(x, self.b)
     self.normalize_valid_x = data_helper.normalizeX(valid_x, self.b)
     # self.floorID_y = y[:, 2]
     #
     # self.floorID_valid_y = valid_y[:, 2]
     self.normY.fit(y[:, 0], y[:, 1])
     self.longitude_normalize_y, self.latitude_normalize_y = self.normY.normalizeY(
         y[:, 0], y[:, 1])
     self.longitude_normalize_valid_y, self.latitude_normalize_valid_y = self.normY.normalizeY(
         valid_y[:, 0], valid_y[:, 1])
Пример #2
0
    def _preprocess(self, x, y, valid_x, valid_y):
        self.normalize_x = data_helper.normalizeX(x, self.b)
        self.normalize_valid_x = data_helper.normalizeX(valid_x, self.b)
        # self.pos_x,self.pos_y=y[:,0],y[:,1]
        # self.normY.fit(y[:, 0], y[:, 1])
        self.pos_x, self.pos_y = self.normY.normalizeY(y[:, 0], y[:, 1])
        self.floorID_y = y[:, 2]
        # self.buildingID_y = y[:, 3]

        self.valid_pos_x, self.valid_pos_y = self.normY.normalizeY(
            valid_y[:, 0], valid_y[:, 1])
        self.floorID_valid_y = valid_y[:, 2]
Пример #3
0
    def predict(self, x):
        predict_buildingID=[]
        predict_floorID=[]
        predict_longitude=[]
        predict_latitude=[]
        x = data_helper.normalizeX(x,self.b)

#################predict_Location
        if Run_Location:
            self.position_model = load_model('Location_model/Location_model.h5')
            predict_Location= self.position_model.predict(x)
            predict_longitude, predict_latitude = self.normY.reverse_normalizeY(predict_Location[:, 0],
                                                                             predict_Location[:, 1])

##################predict_floor
        if Train_New_Floor:
            predict_floorID = self.new_floor_model.predict(x)
            predict_floorID = data_helper.oneHotDecode(predict_floorID)
        elif Run_Floor:
            self.floor_model = load_model('Floor_model/floor_model(AE_' + self.AE_floor_bottleneck + ')-Conv(' + self.floor_layers + ').h5')
            predict_floorID = self.floor_model.predict(x)
            predict_floorID = data_helper.oneHotDecode(predict_floorID)

################predict_building
        if Run_Building:
            self.building_model= load_model(os.path.join(Building_model_dir,('building_model(AE_' + self.AE_building_bottleneck + ')-3.h5')))
            predict_buildingID = self.building_model.predict(x)
            predict_buildingID = data_helper.oneHotDecode(predict_buildingID)

        return predict_buildingID,predict_floorID ,predict_longitude,predict_latitude
    def predict(self, x):
        """
            Predict the tag by the model
            You should train the model before calling this function

            Arg:    x   - The feature array that you want to predict
            Ret:    The predict result whose shape is [num_of_row, 4]
        """
        # Load model
        self.load()

        # Testing
        x = data_helper.normalizeX(x)
        predict_longitude = self.longitude_regression_model.predict(x)
        predict_latitude = self.latitude_regression_model.predict(x)
        predict_floor = self.floor_classifier.predict(x)
        predict_building = self.building_classifier.predict(x)

        # Reverse normalization
        predict_longitude, predict_latitude = data_helper.reverse_normalizeY(predict_longitude, predict_latitude)

        # Return the result
        res = np.concatenate((np.expand_dims(predict_longitude, axis=-1), 
            np.expand_dims(predict_latitude, axis=-1)), axis=-1)
        res = np.concatenate((res, np.expand_dims(predict_floor, axis=-1)), axis=-1)
        res = np.concatenate((res, np.expand_dims(predict_building, axis=-1)), axis=-1)
        return res
Пример #5
0
    def predict(self, x):
        predict_buildingID=[]
        predict_floorID=[]
        predict_longitude=[]
        predict_latitude=[]
        x = data_helper.normalizeX(x)

#################predict_Location
        if Run_Location:
            self.position_model = load_model('Location_model/Location_model.h5')
            predict_Location= self.position_model.predict(x)
            predict_longitude, predict_latitude = self.normY.reverse_normalizeY(predict_Location[:, 0],
                                                                             predict_Location[:, 1])

##################predict_floor
        if Run_Floor:
            self.floor_model = load_model('Floor_model/floor_model(AE_' + self.AE_floor_bottleneck + ')-Conv(' + self.floor_layers + ').h5')
            predict_floorID = self.floor_model.predict(x)


            predict_floorID=predict_floorID[0]+predict_floorID[1]+predict_floorID[2]
            predict_floorID=data_helper.oneHotDecode(predict_floorID)

            # predict_floorID = data_helper.oneHotDecode_list(predict_floorID)
            # predict_floorID=np.round(np.mean(predict_floorID,axis=0))

            # predict_floorID = data_helper.oneHotDecode_list(predict_floorID)
            # predict_floorID = np.round(np.median(predict_floorID, axis=0))
################predict_building
        if Run_Building:
            self.building_model= load_model(os.path.join(Building_model_dir,('building_model(AE_' + self.AE_building_bottleneck + ')-3.h5')))
            predict_buildingID = self.building_model.predict(x)
            predict_buildingID = data_helper.oneHotDecode(predict_buildingID)

        return predict_buildingID,predict_floorID ,predict_longitude,predict_latitude
Пример #6
0
    def predict(self, x):
        x = data_helper.normalizeX(x, self.b)
        self.floor_model = load_model(
            os.path.join(Floor_model_dir, ('Floor_model.h5')))
        predict_floorID = self.floor_model.predict(x)
        predict_floorID = data_helper.oneHotDecode(predict_floorID)

        return predict_floorID
Пример #7
0
    def predict(self, x):
        x = data_helper.normalizeX(x, self.b)

        self.position_model = load_model(
            os.path.join(Location_model_dir, ('Location_model.h5')))
        predict_Location = self.position_model.predict(x)
        predict_longitude, predict_latitude = self.normY.reverse_normalizeY(
            predict_Location[:, 0], predict_Location[:, 1])

        return predict_longitude, predict_latitude
    def _preprocess(self, x, y):
        """
            Data pre-processing for the x and y array
            It's not recommend to use this function directly!

            Arg:    x   - The feature array
                    y   - The tag array
        """
        self.normalize_x = data_helper.normalizeX(x)
        self.longitude_normalize_y, self.latitude_normalize_y = data_helper.normalizeY(y[:, 0], y[:, 1])
        self.floorID_y = y[:, 2]
        self.buildingID_y = y[:, 3]
    def predict(self, x):
        x = data_helper.normalizeX(x)
        predict_longitude = self.longitude_regression_model.predict(x)
        predict_latitude = self.latitude_regression_model.predict(x)
        predict_floorID = self.floor_model.predict(x)
        predict_buildingID = self.building_model.predict(x)

        # Reverse normalization
        predict_longitude, predict_latitude = data_helper.reverse_normalizeY(
            predict_longitude, predict_latitude)
        predict_floorID = data_helper.oneHotDecode(predict_floorID)
        predict_buildingID = data_helper.oneHotDecode(predict_buildingID)

        # Return the result
        res = np.concatenate((np.expand_dims(predict_longitude, axis=-1),
                              np.expand_dims(predict_latitude, axis=-1)),
                             axis=-1)
        res = np.concatenate((res, np.expand_dims(predict_floorID, axis=-1)),
                             axis=-1)
        res = np.concatenate(
            (res, np.expand_dims(predict_buildingID, axis=-1)), axis=-1)
        return res
Пример #10
0
    def _preprocess(self, x, y, valid_x, valid_y):
        self.normalize_x = data_helper.normalizeX(x, self.b)
        self.normalize_valid_x = data_helper.normalizeX(valid_x, self.b)
        self.floorID_y = y[:, 2]

        self.floorID_valid_y = valid_y[:, 2]