Untitled

mail@pastecode.io avatarunknown
plain_text
23 days ago
3.3 kB
1
Indexable
Never
This is one more function-

def event_prediction_tfidf(input_ticket_category, input_ticket_type, input_ticket_item, input_ticket_summary, input_ticket_desc, input_ticket_severity):
    #pdb.set_trace()
    
    global tfidf_matrix,tf_count_matrix,tfidf_vector,count_vector,df_act
    ## First join 5 parameters andd then call input_data_preprocessing
    data_to_be_processed=str(input_ticket_category) +' ' + str(input_ticket_type) +' ' +str(input_ticket_item) + ' ' + str(input_ticket_summary) + ' ' +str(input_ticket_desc) + ' ' + str(input_ticket_severity)

    ## Input Data Preprocessing
    input_processed_text = input_data_preprocessing(data_to_be_processed) ## 5 different fields
    
    print("Input processed Text : ",input_processed_text)
    #pdb.set_trace()
      
    ##TFIDF Prediction
    tfidf_pred,input_tfidfmatrx = input_evalution(input_processed_text,tfidf_matrix,tfidf_vector,df_act)
    
    ##TF_count Prediction
    tf_count_pred,input_tfcountmatrx = input_evalution_count(input_processed_text,tf_count_matrix,count_vector,df_act)
    #pdb.set_trace()
    
    
    tfidf_pred['score_new'] = tfidf_pred['score']*0.5
    tf_count_pred['score_new'] = tf_count_pred['score']*0.5
    
    tfidf_pred['flag'] = 'tfidf'
    tf_count_pred['flag'] = 'tf_count'
    
    overall_result = pd.concat([tfidf_pred,tf_count_pred])
    print("Overall Result : ",overall_result)
    if len(overall_result)>0:
    
        overall_result = overall_result.sort_values(by='score_new',ascending=False)
        #print it and then change it
        overall_result.drop_duplicates(subset = 'event_id',inplace=True)
        #overall_result =overall_result[overall_result['event_type']==input_event_type]
    
    
        overall_result['fuzz_valid_score'] = overall_result.apply(lambda row: fuzz_score(input_processed_text,row['clean_text_event_title']),axis=1)
        overall_result = overall_result[(overall_result['fuzz_valid_score']>config.fuzzy_threshold) |(overall_result['score_new']>=config.tf_threshold)]
        overall_result = overall_result.head(config.max_reccom)

        overall_result_1 = overall_result[overall_result['event_type']==input_event_type]

        overall_result_2 = overall_result[overall_result['event_type']!=input_event_type]

        if len(overall_result_1) < 10:
            overall_result = overall_result_1.append(overall_result_2, ignore_index=True)
        else:
            overall_result = overall_result_1
    
        event_id_list = overall_result['event_id'].tolist()
        event_title_list = overall_result[config.target_column].tolist()
    
        return event_id_list,event_title_list ##  we need only result list
   
    else:
    
        event_id_list = []
        event_title_list = []
        return event_id_list,event_title_list  ## user recommendation list 

I have modified few things as per my requirement. but I am stuck here after these lines till end-

overall_result.drop_duplicates(subset = 'event_id',inplace=True)
 #overall_result =overall_result[overall_result['event_type']==input_event_type]

Like I dont have any event_id in my columns and person who resolved is target column and rest columns I am passing as input.

Can you help me here with changes please.