FukuML/MLBase.py
def prediction(self, input_data='', mode='test_data'):

        '''
        Make prediction
        input test data
        output the prediction
        '''

        prediction = {}

        if (self.status != 'train'):
            print("Please load train data and init W then train the W first.")
            return prediction

        if (input_data == ''):
            print("Please input test data for prediction.")
            return prediction

        if mode == 'future_data':
            data = input_data.split()
            input_data_x = [float(v) for v in data]
            input_data_x = utility.DatasetLoader.feature_transform(
                np.array(input_data_x).reshape(1, -1),
                self.feature_transform_mode,
                self.feature_transform_degree
            )
            input_data_x = np.ravel(input_data_x)
            prediction = self.score_function(input_data_x, self.W)
            return {"input_data_x": input_data_x, "input_data_y": None, "prediction": prediction}
        else:
            data = input_data.split()
            input_data_x = [float(v) for v in data[:-1]]
            input_data_x = utility.DatasetLoader.feature_transform(
                np.array(input_data_x).reshape(1, -1),
                self.feature_transform_mode,
                self.feature_transform_degree
            )
            input_data_x = np.ravel(input_data_x)
            input_data_y = float(data[-1])
            prediction = self.score_function(input_data_x, self.W)
            return {"input_data_x": input_data_x, "input_data_y": input_data_y, "prediction": prediction}
def prediction(self, input_data='', mode='test_data'):

        '''
        Make prediction
        input test data
        output the prediction
        '''

        prediction = {}

        if (self.status != 'train'):
            print("Please load train data and init W then train the W first.")
            return prediction

        if (input_data == ''):
            print("Please input test data for prediction.")
            return prediction

        if mode == 'future_data':
            data = input_data.split()
            input_data_x = [float(v) for v in data]
            input_data_x = utility.DatasetLoader.feature_transform(
                np.array(input_data_x).reshape(1, -1),
                self.feature_transform_mode,
                self.feature_transform_degree
            )
            input_data_x = np.ravel(input_data_x)
            prediction = self.score_function(input_data_x, self.W)
            return {"input_data_x": input_data_x, "input_data_y": None, "prediction": prediction}
        else:
            data = input_data.split()
            input_data_x = [float(v) for v in data[:-1]]
            input_data_x = utility.DatasetLoader.feature_transform(
                np.array(input_data_x).reshape(1, -1),
                self.feature_transform_mode,
                self.feature_transform_degree
            )
            input_data_x = np.ravel(input_data_x)
            input_data_y = float(data[-1])
            prediction = self.score_function(input_data_x, self.W)
            return {"input_data_x": input_data_x, "input_data_y": input_data_y, "prediction": prediction}
def prediction ( self , input_data = '' , mode = 'test_data' ) : prediction = { } if ( self . status != 'train' ) : print ( "Please load train data and init W then train the W first." ) return prediction if ( input_data == '' ) : print ( "Please input test data for prediction." ) return prediction if mode == 'future_data' : data = input_data . split ( ) input_data_x = [ float ( v ) for v in data ] input_data_x = utility . DatasetLoader . feature_transform ( np . array ( input_data_x ) . reshape ( 1 , - 1 ) , self . feature_transform_mode , self . feature_transform_degree ) input_data_x = np . ravel ( input_data_x ) prediction = self . score_function ( input_data_x , self . W ) return { "input_data_x" : input_data_x , "input_data_y" : None , "prediction" : prediction } else : data = input_data . split ( ) input_data_x = [ float ( v ) for v in data [ : - 1 ] ] input_data_x = utility . DatasetLoader . feature_transform ( np . array ( input_data_x ) . reshape ( 1 , - 1 ) , self . feature_transform_mode , self . feature_transform_degree ) input_data_x = np . ravel ( input_data_x ) input_data_y = float ( data [ - 1 ] ) prediction = self . score_function ( input_data_x , self . W ) return { "input_data_x" : input_data_x , "input_data_y" : input_data_y , "prediction" : prediction }
Make prediction
        input test data
        output the prediction
Make prediction input test data output the prediction