prediction_functions.py
def comprehensive_nomissing_model(Participants,\
                                  class_,\
                                  minlen=10,\
                                  training=0.7,\
                                  sample_size=10,\
                                  scaling=False,\
                                  cumsum=True):


    """
            trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.

    Parameters
    ----------
    Participants: class of participants for the corresponding 2 tests
    
    class_: which class we are working on (0/1/2)
    
    minlen_set : list
        size of each participant data.

    training : scalar
        Training set proportional.
        
    sample_size: number for loop
        Default is 50
    
    scaling: if severity of symptoms being considered
      Defalt: False (directly predicting raw scores),
              otherwise True (scaling the predicted score to severity of symptoms)
    
    cumsum: a parameter in data-transforming step, can be set to True for all models

    Returns
    -------

    accuracy: average accuracy for each case
    mae: average MAE for each case
    
    
    
    """



    random.seed(42)
    
    random_state=42

    standardise_set=[False, True, True]
    count_set=[False, True, True]
    feedforward_set=[False, True, True]
    naive_set=[True,  False,  False]
    time_set=[False,  True,  True]
    missing_clean_set=[False,False,False]

    order_set=[None,int(2),int(3)]

    feature_set=[int(0),int(1)]
    
    y_collections=[[] for i in range(int(len(feature_set)*len(standardise_set)))]
    y_pred_collections=[[] for i in range(int(len(feature_set)*len(standardise_set)))]
    
    accuracy=np.zeros((len(feature_set),len(standardise_set)))
    mse=np.zeros((len(feature_set),len(standardise_set)))
    mae=np.zeros((len(feature_set),len(standardise_set)))
    r2=np.zeros((len(feature_set),len(standardise_set)))
    
    for i in range(sample_size):
        train_set, test_set = buildData_prediction_nomissing(Participants,\
                                                             training=training,\
                                                              minlen=minlen,\
                                                             class_=class_)

        for j in range(len(standardise_set)):

            for ii in range(len(feature_set)):

                X_train,y_train=data_model(train_set,\
                                           order=order_set[j],\
                                           standardise=standardise_set[j],\
                                           count=count_set[j],\
                                           feedforward=feedforward_set[j],\
                                           missing_clean=missing_clean_set[j],\
                                           time=time_set[j],\
                                           naive=naive_set[j],\
                                           feature=feature_set[ii],\
                                           cumsum=cumsum)


                X_test,y_test=data_model(test_set,\
                                         order=order_set[j],\
                                         standardise=standardise_set[j],\
                                         count=count_set[j],\
                                         feedforward=feedforward_set[j],\
                                         missing_clean=missing_clean_set[j],\
                                         time=time_set[j],\
                                         naive=naive_set[j],\
                                         feature=feature_set[ii],\
                                         cumsum=cumsum)
                
                current_index=int(j*len(feature_set)+ii)
                

   
                y_test_pred_=rf_nextdaymodel(X_train,y_train,X_test,\
                                             regression=True,\
                                             feature=feature_set[ii])
                
                if scaling:
                    
                    y_test_pred_=scaling_list(y_test_pred_,\
                                              feature=feature_set[ii])
                    y_test=scaling_list(y_test,\
                                        feature=feature_set[ii])                
                    
                y_pred_collections[current_index].append(y_test_pred_)
                
                y_collections[current_index].append(y_test)


                
    for j in range(len(standardise_set)):

        for ii in range(len(feature_set)):
            current_index=int(j*len(feature_set)+ii)


            
            accuracy[ii,j],mae[ii,j]=MAE(y_pred_collections[current_index],\
                                         y_collections[current_index],\
                                         feature=feature_set[ii])
            


    return accuracy, mae

            trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.

    Parameters
    ----------
    Participants: class of participants for the corresponding 2 tests
    
    class_: which class we are working on (0/1/2)
    
    minlen_set : list
        size of each participant data.

    training : scalar
        Training set proportional.
        
    sample_size: number for loop
        Default is 50
    
    scaling: if severity of symptoms being considered
      Defalt: False (directly predicting raw scores),
              otherwise True (scaling the predicted score to severity of symptoms)
    
    cumsum: a parameter in data-transforming step, can be set to True for all models

    Returns
    -------

    accuracy: average accuracy for each case
    mae: average MAE for each case
    
    
    
    
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.
Parameters

class of participants for the corresponding 2 tests

which class we are working on (0/1/2)

minlen_set : list
size of each participant data.

training : scalar
Training set proportional.

number for loop
Default is 50

if severity of symptoms being considered
Defalt: False (directly predicting raw scores),
otherwise True (scaling the predicted score to severity of symptoms)

a parameter in data-transforming step, can be set to True for all models

Returns

average accuracy for each case
mae: average MAE for each case
trying models ( stateMRSPM level 2 naive model ) with different parameters in len ( set ) or order in one - go . Parameters class of participants for the corresponding 2 tests which class we are working on ( 0 / 1 / 2 ) minlen_set : list size of each participant data . training : scalar Training set proportional . number for loop Default is 50 if severity of symptoms being considered Defalt : False ( directly predicting raw scores ) otherwise True ( scaling the predicted score to severity of symptoms ) a parameter in data - transforming step can be set to True for all models Returns average accuracy for each case mae : average MAE for each case
def comprehensive_nomissing_model(Participants,\
                                  class_,\
                                  minlen=10,\
                                  training=0.7,\
                                  sample_size=10,\
                                  scaling=False,\
                                  cumsum=True):
    random.seed(42)
    random_state=42
    standardise_set=[False, True, True]
    count_set=[False, True, True]
    feedforward_set=[False, True, True]
    naive_set=[True,  False,  False]
    time_set=[False,  True,  True]
    missing_clean_set=[False,False,False]
    order_set=[None,int(2),int(3)]
    feature_set=[int(0),int(1)]
    y_collections=[[] for i in range(int(len(feature_set)*len(standardise_set)))]
    y_pred_collections=[[] for i in range(int(len(feature_set)*len(standardise_set)))]
    accuracy=np.zeros((len(feature_set),len(standardise_set)))
    mse=np.zeros((len(feature_set),len(standardise_set)))
    mae=np.zeros((len(feature_set),len(standardise_set)))
    r2=np.zeros((len(feature_set),len(standardise_set)))
    for i in range(sample_size):
        train_set, test_set = buildData_prediction_nomissing(Participants,\
                                                             training=training,\
                                                              minlen=minlen,\
                                                             class_=class_)
        for j in range(len(standardise_set)):
            for ii in range(len(feature_set)):
                X_train,y_train=data_model(train_set,\
                                           order=order_set[j],\
                                           standardise=standardise_set[j],\
                                           count=count_set[j],\
                                           feedforward=feedforward_set[j],\
                                           missing_clean=missing_clean_set[j],\
                                           time=time_set[j],\
                                           naive=naive_set[j],\
                                           feature=feature_set[ii],\
                                           cumsum=cumsum)
                X_test,y_test=data_model(test_set,\
                                         order=order_set[j],\
                                         standardise=standardise_set[j],\
                                         count=count_set[j],\
                                         feedforward=feedforward_set[j],\
                                         missing_clean=missing_clean_set[j],\
                                         time=time_set[j],\
                                         naive=naive_set[j],\
                                         feature=feature_set[ii],\
                                         cumsum=cumsum)
                current_index=int(j*len(feature_set)+ii)
                y_test_pred_=rf_nextdaymodel(X_train,y_train,X_test,\
                                             regression=True,\
                                             feature=feature_set[ii])
                if scaling:
                    y_test_pred_=scaling_list(y_test_pred_,\
                                              feature=feature_set[ii])
                    y_test=scaling_list(y_test,\
                                        feature=feature_set[ii])                
                y_pred_collections[current_index].append(y_test_pred_)
                y_collections[current_index].append(y_test)
    for j in range(len(standardise_set)):
        for ii in range(len(feature_set)):
            current_index=int(j*len(feature_set)+ii)
            accuracy[ii,j],mae[ii,j]=MAE(y_pred_collections[current_index],\
                                         y_collections[current_index],\
                                         feature=feature_set[ii])
    return accuracy, mae
def comprehensive_nomissing_model ( Participants , class_ , minlen = 10 , training = 0.7 , sample_size = 10 , scaling = False , cumsum = True ) : random . seed ( 42 ) random_state = 42 standardise_set = [ False , True , True ] count_set = [ False , True , True ] feedforward_set = [ False , True , True ] naive_set = [ True , False , False ] time_set = [ False , True , True ] missing_clean_set = [ False , False , False ] order_set = [ None , int ( 2 ) , int ( 3 ) ] feature_set = [ int ( 0 ) , int ( 1 ) ] y_collections = [ [ ] for i in range ( int ( len ( feature_set ) * len ( standardise_set ) ) ) ] y_pred_collections = [ [ ] for i in range ( int ( len ( feature_set ) * len ( standardise_set ) ) ) ] accuracy = np . zeros ( ( len ( feature_set ) , len ( standardise_set ) ) ) mse = np . zeros ( ( len ( feature_set ) , len ( standardise_set ) ) ) mae = np . zeros ( ( len ( feature_set ) , len ( standardise_set ) ) ) r2 = np . zeros ( ( len ( feature_set ) , len ( standardise_set ) ) ) for i in range ( sample_size ) : train_set , test_set = buildData_prediction_nomissing ( Participants , training = training , minlen = minlen , class_ = class_ ) for j in range ( len ( standardise_set ) ) : for ii in range ( len ( feature_set ) ) : X_train , y_train = data_model ( train_set , order = order_set [ j ] , standardise = standardise_set [ j ] , count = count_set [ j ] , feedforward = feedforward_set [ j ] , missing_clean = missing_clean_set [ j ] , time = time_set [ j ] , naive = naive_set [ j ] , feature = feature_set [ ii ] , cumsum = cumsum ) X_test , y_test = data_model ( test_set , order = order_set [ j ] , standardise = standardise_set [ j ] , count = count_set [ j ] , feedforward = feedforward_set [ j ] , missing_clean = missing_clean_set [ j ] , time = time_set [ j ] , naive = naive_set [ j ] , feature = feature_set [ ii ] , cumsum = cumsum ) current_index = int ( j * len ( feature_set ) + ii ) y_test_pred_ = rf_nextdaymodel ( X_train , y_train , X_test , regression = True , feature = feature_set [ ii ] ) if scaling : y_test_pred_ = scaling_list ( y_test_pred_ , feature = feature_set [ ii ] ) y_test = scaling_list ( y_test , feature = feature_set [ ii ] ) y_pred_collections [ current_index ] . append ( y_test_pred_ ) y_collections [ current_index ] . append ( y_test ) for j in range ( len ( standardise_set ) ) : for ii in range ( len ( feature_set ) ) : current_index = int ( j * len ( feature_set ) + ii ) accuracy [ ii , j ] , mae [ ii , j ] = MAE ( y_pred_collections [ current_index ] , y_collections [ current_index ] , feature = feature_set [ ii ] ) return accuracy , mae
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.
trying models ( stateMRSPM level 2 naive model ) with different parameters in len ( set ) or order in one - go .
"""
            trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.

    Parameters
    ----------
    Participants: class of participants for the corresponding 2 tests
    
    class_: which class we are working on (0/1/2)
    
    minlen_set : list
        size of each participant data.

    training : scalar
        Training set proportional.
        
    sample_size: number for loop
        Default is 50
    
    scaling: if severity of symptoms being considered
      Defalt: False (directly predicting raw scores),
              otherwise True (scaling the predicted score to severity of symptoms)
    
    cumsum: a parameter in data-transforming step, can be set to True for all models

    Returns
    -------

    accuracy: average accuracy for each case
    mae: average MAE for each case
    
    
    
    """
Participants
class_
minlen
training
sample_size
scaling
cumsum