idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
42,200
def html_dataset_type ( is_binary , is_imbalanced ) : result = "<h2>Dataset Type : </h2>\n" balance_type = "Balanced" class_type = "Binary Classification" if is_imbalanced : balance_type = "Imbalanced" if not is_binary : class_type = "Multi-Class Classification" result += "<ul>\n\n<li>{0}</li>\n\n<li>{1}</li>\n</ul>\n" . format ( class_type , balance_type ) result += "<p>{0}</p>\n" . format ( RECOMMEND_HTML_MESSAGE ) result += "<p>{0}</p>\n" . format ( RECOMMEND_HTML_MESSAGE2 ) return result
Return HTML report file dataset type .
42,201
def color_check ( color ) : if isinstance ( color , ( tuple , list ) ) : if all ( map ( lambda x : isinstance ( x , int ) , color ) ) : if all ( map ( lambda x : x < 256 , color ) ) : return list ( color ) if isinstance ( color , str ) : color_lower = color . lower ( ) if color_lower in TABLE_COLOR . keys ( ) : return TABLE_COLOR [ color_lower ] return [ 0 , 0 , 0 ]
Check input color format .
42,202
def html_table_color ( row , item , color = ( 0 , 0 , 0 ) ) : result = [ 0 , 0 , 0 ] color_list = color_check ( color ) max_color = max ( color_list ) back_color_index = 255 - int ( ( item / ( sum ( list ( row . values ( ) ) ) + 1 ) ) * 255 ) for i in range ( 3 ) : result [ i ] = back_color_index - ( max_color - color_list [ i ] ) if result [ i ] < 0 : result [ i ] = 0 return result
Return background color of each cell of table .
42,203
def html_table ( classes , table , rgb_color , normalize = False ) : result = "" result += "<h2>Confusion Matrix " if normalize : result += "(Normalized)" result += ": </h2>\n" result += '<table>\n' result += '<tr align="center">' + "\n" result += '<td>Actual</td>\n' result += '<td>Predict\n' table_size = str ( ( len ( classes ) + 1 ) * 7 ) + "em" result += '<table style="border:1px solid black;border-collapse: collapse;height:{0};width:{0};">\n' . format ( table_size ) classes . sort ( ) result += '<tr align="center">\n<td></td>\n' part_2 = "" for i in classes : class_name = str ( i ) if len ( class_name ) > 6 : class_name = class_name [ : 4 ] + "..." result += '<td style="border:1px solid ' 'black;padding:10px;height:7em;width:7em;">' + class_name + '</td>\n' part_2 += '<tr align="center">\n' part_2 += '<td style="border:1px solid ' 'black;padding:10px;height:7em;width:7em;">' + class_name + '</td>\n' for j in classes : item = table [ i ] [ j ] color = "black;" back_color = html_table_color ( table [ i ] , item , rgb_color ) if min ( back_color ) < 128 : color = "white" part_2 += '<td style="background-color: rgb({0},{1},{2});color:{3};padding:10px;height:7em;width:7em;">' . format ( str ( back_color [ 0 ] ) , str ( back_color [ 1 ] ) , str ( back_color [ 2 ] ) , color ) + str ( item ) + '</td>\n' part_2 += "</tr>\n" result += '</tr>\n' part_2 += "</table>\n</td>\n</tr>\n</table>\n" result += part_2 return result
Return HTML report file confusion matrix .
42,204
def html_overall_stat ( overall_stat , digit = 5 , overall_param = None , recommended_list = ( ) ) : result = "" result += "<h2>Overall Statistics : </h2>\n" result += '<table style="border:1px solid black;border-collapse: collapse;">\n' overall_stat_keys = sorted ( overall_stat . keys ( ) ) if isinstance ( overall_param , list ) : if set ( overall_param ) <= set ( overall_stat_keys ) : overall_stat_keys = sorted ( overall_param ) if len ( overall_stat_keys ) < 1 : return "" for i in overall_stat_keys : background_color = DEFAULT_BACKGROUND_COLOR if i in recommended_list : background_color = RECOMMEND_BACKGROUND_COLOR result += '<tr align="center">\n' result += '<td style="border:1px solid black;padding:4px;text-align:left;background-color:{};"><a href="' . format ( background_color ) + DOCUMENT_ADR + PARAMS_LINK [ i ] + '" style="text-decoration:None;">' + str ( i ) + '</a></td>\n' if i in BENCHMARK_LIST : background_color = BENCHMARK_COLOR [ overall_stat [ i ] ] result += '<td style="border:1px solid black;padding:4px;background-color:{};">' . format ( background_color ) else : result += '<td style="border:1px solid black;padding:4px;">' result += rounder ( overall_stat [ i ] , digit ) + '</td>\n' result += "</tr>\n" result += "</table>\n" return result
Return HTML report file overall stat .
42,205
def html_class_stat ( classes , class_stat , digit = 5 , class_param = None , recommended_list = ( ) ) : result = "" result += "<h2>Class Statistics : </h2>\n" result += '<table style="border:1px solid black;border-collapse: collapse;">\n' result += '<tr align="center">\n<td>Class</td>\n' for i in classes : result += '<td style="border:1px solid black;padding:4px;border-collapse: collapse;">' + str ( i ) + '</td>\n' result += '<td>Description</td>\n' result += '</tr>\n' class_stat_keys = sorted ( class_stat . keys ( ) ) if isinstance ( class_param , list ) : if set ( class_param ) <= set ( class_stat_keys ) : class_stat_keys = class_param classes . sort ( ) if len ( classes ) < 1 or len ( class_stat_keys ) < 1 : return "" for i in class_stat_keys : background_color = DEFAULT_BACKGROUND_COLOR if i in recommended_list : background_color = RECOMMEND_BACKGROUND_COLOR result += '<tr align="center" style="border:1px solid black;border-collapse: collapse;">\n' result += '<td style="border:1px solid black;padding:4px;border-collapse: collapse;background-color:{};"><a href="' . format ( background_color ) + DOCUMENT_ADR + PARAMS_LINK [ i ] + '" style="text-decoration:None;">' + str ( i ) + '</a></td>\n' for j in classes : if i in BENCHMARK_LIST : background_color = BENCHMARK_COLOR [ class_stat [ i ] [ j ] ] result += '<td style="border:1px solid black;padding:4px;border-collapse: collapse;background-color:{};">' . format ( background_color ) else : result += '<td style="border:1px solid black;padding:4px;border-collapse: collapse;">' result += rounder ( class_stat [ i ] [ j ] , digit ) + '</td>\n' params_text = PARAMS_DESCRIPTION [ i ] if i not in CAPITALIZE_FILTER : params_text = params_text . capitalize ( ) result += '<td style="border:1px solid black;padding:4px;border-collapse: collapse;text-align:left;">' + params_text + '</td>\n' result += "</tr>\n" result += "</table>\n" return result
Return HTML report file class_stat .
42,206
def table_print ( classes , table ) : classes_len = len ( classes ) table_list = [ ] for key in classes : table_list . extend ( list ( table [ key ] . values ( ) ) ) table_list . extend ( classes ) table_max_length = max ( map ( len , map ( str , table_list ) ) ) shift = "%-" + str ( 7 + table_max_length ) + "s" result = shift % "Predict" + shift * classes_len % tuple ( map ( str , classes ) ) + "\n" result = result + "Actual\n" classes . sort ( ) for key in classes : row = [ table [ key ] [ i ] for i in classes ] result += shift % str ( key ) + shift * classes_len % tuple ( map ( str , row ) ) + "\n\n" if classes_len >= CLASS_NUMBER_THRESHOLD : result += "\n" + "Warning : " + CLASS_NUMBER_WARNING + "\n" return result
Return printable confusion matrix .
42,207
def csv_matrix_print ( classes , table ) : result = "" classes . sort ( ) for i in classes : for j in classes : result += str ( table [ i ] [ j ] ) + "," result = result [ : - 1 ] + "\n" return result [ : - 1 ]
Return matrix as csv data .
42,208
def csv_print ( classes , class_stat , digit = 5 , class_param = None ) : result = "Class" classes . sort ( ) for item in classes : result += ',"' + str ( item ) + '"' result += "\n" class_stat_keys = sorted ( class_stat . keys ( ) ) if isinstance ( class_param , list ) : if set ( class_param ) <= set ( class_stat_keys ) : class_stat_keys = class_param if len ( class_stat_keys ) < 1 or len ( classes ) < 1 : return "" for key in class_stat_keys : row = [ rounder ( class_stat [ key ] [ i ] , digit ) for i in classes ] result += key + "," + "," . join ( row ) result += "\n" return result
Return csv file data .
42,209
def stat_print ( classes , class_stat , overall_stat , digit = 5 , overall_param = None , class_param = None ) : shift = max ( map ( len , PARAMS_DESCRIPTION . values ( ) ) ) + 5 classes_len = len ( classes ) overall_stat_keys = sorted ( overall_stat . keys ( ) ) result = "" if isinstance ( overall_param , list ) : if set ( overall_param ) <= set ( overall_stat_keys ) : overall_stat_keys = sorted ( overall_param ) if len ( overall_stat_keys ) > 0 : result = "Overall Statistics : " + "\n\n" for key in overall_stat_keys : result += key + " " * ( shift - len ( key ) + 7 ) + rounder ( overall_stat [ key ] , digit ) + "\n" class_stat_keys = sorted ( class_stat . keys ( ) ) if isinstance ( class_param , list ) : if set ( class_param ) <= set ( class_stat_keys ) : class_stat_keys = sorted ( class_param ) classes . sort ( ) if len ( class_stat_keys ) > 0 and len ( classes ) > 0 : class_shift = max ( max ( map ( lambda x : len ( str ( x ) ) , classes ) ) + 5 , digit + 6 , 14 ) class_shift_format = "%-" + str ( class_shift ) + "s" result += "\nClass Statistics :\n\n" result += "Classes" + shift * " " + class_shift_format * classes_len % tuple ( map ( str , classes ) ) + "\n" rounder_map = partial ( rounder , digit = digit ) for key in class_stat_keys : row = [ class_stat [ key ] [ i ] for i in classes ] params_text = PARAMS_DESCRIPTION [ key ] if key not in CAPITALIZE_FILTER : params_text = params_text . capitalize ( ) result += key + "(" + params_text + ")" + " " * ( shift - len ( key ) - len ( PARAMS_DESCRIPTION [ key ] ) + 5 ) + class_shift_format * classes_len % tuple ( map ( rounder_map , row ) ) + "\n" if classes_len >= CLASS_NUMBER_THRESHOLD : result += "\n" + "Warning : " + CLASS_NUMBER_WARNING + "\n" return result
Return printable statistics table .
42,210
def compare_report_print ( sorted_list , scores , best_name ) : title_items = [ "Rank" , "Name" , "Class-Score" , "Overall-Score" ] class_scores_len = map ( lambda x : len ( str ( x [ "class" ] ) ) , list ( scores . values ( ) ) ) shifts = [ "%-" + str ( len ( sorted_list ) + 4 ) + "s" , "%-" + str ( max ( map ( lambda x : len ( str ( x ) ) , sorted_list ) ) + 4 ) + "s" , "%-" + str ( max ( class_scores_len ) + 11 ) + "s" ] result = "" result += "Best : " + str ( best_name ) + "\n\n" result += ( "" . join ( shifts ) ) % tuple ( title_items [ : - 1 ] ) + title_items [ - 1 ] + "\n" prev_rank = 0 for index , cm in enumerate ( sorted_list ) : rank = index if scores [ sorted_list [ rank ] ] == scores [ sorted_list [ prev_rank ] ] : rank = prev_rank result += ( "" . join ( shifts ) ) % ( str ( rank + 1 ) , str ( cm ) , str ( scores [ cm ] [ "class" ] ) ) + str ( scores [ cm ] [ "overall" ] ) + "\n" prev_rank = rank if best_name is None : result += "\nWarning: " + COMPARE_RESULT_WARNING return result
Return compare report .
42,211
def online_help ( param = None ) : try : PARAMS_LINK_KEYS = sorted ( PARAMS_LINK . keys ( ) ) if param in PARAMS_LINK_KEYS : webbrowser . open_new_tab ( DOCUMENT_ADR + PARAMS_LINK [ param ] ) elif param in range ( 1 , len ( PARAMS_LINK_KEYS ) + 1 ) : webbrowser . open_new_tab ( DOCUMENT_ADR + PARAMS_LINK [ PARAMS_LINK_KEYS [ param - 1 ] ] ) else : print ( "Please choose one parameter : \n" ) print ( 'Example : online_help("J") or online_help(2)\n' ) for index , item in enumerate ( PARAMS_LINK_KEYS ) : print ( str ( index + 1 ) + "-" + item ) except Exception : print ( "Error in online help" )
Open online document in web browser .
42,212
def rounder ( input_number , digit = 5 ) : if isinstance ( input_number , tuple ) : tuple_list = list ( input_number ) tuple_str = [ ] for i in tuple_list : if isfloat ( i ) : tuple_str . append ( str ( numpy . around ( i , digit ) ) ) else : tuple_str . append ( str ( i ) ) return "(" + "," . join ( tuple_str ) + ")" if isfloat ( input_number ) : return str ( numpy . around ( input_number , digit ) ) return str ( input_number )
Round input number and convert to str .
42,213
def class_filter ( classes , class_name ) : result_classes = classes if isinstance ( class_name , list ) : if set ( class_name ) <= set ( classes ) : result_classes = class_name return result_classes
Filter classes by comparing two lists .
42,214
def vector_check ( vector ) : for i in vector : if isinstance ( i , int ) is False : return False if i < 0 : return False return True
Check input vector items type .
42,215
def matrix_check ( table ) : try : if len ( table . keys ( ) ) == 0 : return False for i in table . keys ( ) : if table . keys ( ) != table [ i ] . keys ( ) or vector_check ( list ( table [ i ] . values ( ) ) ) is False : return False return True except Exception : return False
Check input matrix format .
42,216
def vector_filter ( actual_vector , predict_vector ) : temp = [ ] temp . extend ( actual_vector ) temp . extend ( predict_vector ) types = set ( map ( type , temp ) ) if len ( types ) > 1 : return [ list ( map ( str , actual_vector ) ) , list ( map ( str , predict_vector ) ) ] return [ actual_vector , predict_vector ]
Convert different type of items in vectors to str .
42,217
def class_check ( vector ) : for i in vector : if not isinstance ( i , type ( vector [ 0 ] ) ) : return False return True
Check different items in matrix classes .
42,218
def one_vs_all_func ( classes , table , TP , TN , FP , FN , class_name ) : try : report_classes = [ str ( class_name ) , "~" ] report_table = { str ( class_name ) : { str ( class_name ) : TP [ class_name ] , "~" : FN [ class_name ] } , "~" : { str ( class_name ) : FP [ class_name ] , "~" : TN [ class_name ] } } return [ report_classes , report_table ] except Exception : return [ classes , table ]
One - Vs - All mode handler .
42,219
def normalized_table_calc ( classes , table ) : map_dict = { k : 0 for k in classes } new_table = { k : map_dict . copy ( ) for k in classes } for key in classes : div = sum ( table [ key ] . values ( ) ) if div == 0 : div = 1 for item in classes : new_table [ key ] [ item ] = numpy . around ( table [ key ] [ item ] / div , 5 ) return new_table
Return normalized confusion matrix .
42,220
def transpose_func ( classes , table ) : transposed_table = table for i , item1 in enumerate ( classes ) : for j , item2 in enumerate ( classes ) : if i > j : temp = transposed_table [ item1 ] [ item2 ] transposed_table [ item1 ] [ item2 ] = transposed_table [ item2 ] [ item1 ] transposed_table [ item2 ] [ item1 ] = temp return transposed_table
Transpose table .
42,221
def matrix_params_from_table ( table , transpose = False ) : classes = sorted ( table . keys ( ) ) map_dict = { k : 0 for k in classes } TP_dict = map_dict . copy ( ) TN_dict = map_dict . copy ( ) FP_dict = map_dict . copy ( ) FN_dict = map_dict . copy ( ) for i in classes : TP_dict [ i ] = table [ i ] [ i ] sum_row = sum ( list ( table [ i ] . values ( ) ) ) for j in classes : if j != i : FN_dict [ i ] += table [ i ] [ j ] FP_dict [ j ] += table [ i ] [ j ] TN_dict [ j ] += sum_row - table [ i ] [ j ] if transpose : temp = FN_dict FN_dict = FP_dict FP_dict = temp table = transpose_func ( classes , table ) return [ classes , table , TP_dict , TN_dict , FP_dict , FN_dict ]
Calculate TP TN FP FN from confusion matrix .
42,222
def matrix_params_calc ( actual_vector , predict_vector , sample_weight ) : if isinstance ( actual_vector , numpy . ndarray ) : actual_vector = actual_vector . tolist ( ) if isinstance ( predict_vector , numpy . ndarray ) : predict_vector = predict_vector . tolist ( ) classes = set ( actual_vector ) . union ( set ( predict_vector ) ) classes = sorted ( classes ) map_dict = { k : 0 for k in classes } table = { k : map_dict . copy ( ) for k in classes } weight_vector = [ 1 ] * len ( actual_vector ) if isinstance ( sample_weight , ( list , numpy . ndarray ) ) : if len ( sample_weight ) == len ( actual_vector ) : weight_vector = sample_weight for index , item in enumerate ( actual_vector ) : table [ item ] [ predict_vector [ index ] ] += 1 * weight_vector [ index ] [ classes , table , TP_dict , TN_dict , FP_dict , FN_dict ] = matrix_params_from_table ( table ) return [ classes , table , TP_dict , TN_dict , FP_dict , FN_dict ]
Calculate TP TN FP FN for each class .
42,223
def imbalance_check ( P ) : p_list = list ( P . values ( ) ) max_value = max ( p_list ) min_value = min ( p_list ) if min_value > 0 : balance_ratio = max_value / min_value else : balance_ratio = max_value is_imbalanced = False if balance_ratio > BALANCE_RATIO_THRESHOLD : is_imbalanced = True return is_imbalanced
Check if the dataset is imbalanced .
42,224
def binary_check ( classes ) : num_classes = len ( classes ) is_binary = False if num_classes == 2 : is_binary = True return is_binary
Check if the problem is a binary classification .
42,225
def statistic_recommend ( classes , P ) : if imbalance_check ( P ) : return IMBALANCED_RECOMMEND if binary_check ( classes ) : return BINARY_RECOMMEND return MULTICLASS_RECOMMEND
Return recommend parameters which are more suitable due to the input dataset characteristics .
42,226
def print_result ( failed = False ) : message = "Version tag tests " if not failed : print ( "\n" + message + "passed!" ) else : print ( "\n" + message + "failed!" ) print ( "Passed : " + str ( TEST_NUMBER - Failed ) + "/" + str ( TEST_NUMBER ) )
Print final result .
42,227
def AUNP_calc ( classes , P , POP , AUC_dict ) : try : result = 0 for i in classes : result += ( P [ i ] / POP [ i ] ) * AUC_dict [ i ] return result except Exception : return "None"
Calculate AUNP .
42,228
def overall_MCC_calc ( classes , table , TOP , P ) : try : cov_x_y = 0 cov_x_x = 0 cov_y_y = 0 matrix_sum = sum ( list ( TOP . values ( ) ) ) for i in classes : cov_x_x += TOP [ i ] * ( matrix_sum - TOP [ i ] ) cov_y_y += P [ i ] * ( matrix_sum - P [ i ] ) cov_x_y += ( table [ i ] [ i ] * matrix_sum - P [ i ] * TOP [ i ] ) return cov_x_y / ( math . sqrt ( cov_y_y * cov_x_x ) ) except Exception : return "None"
Calculate Overall_MCC .
42,229
def convex_combination ( classes , TP , TOP , P , class_name , modified = False ) : try : class_number = len ( classes ) alpha = 1 if class_number == 2 : alpha = 0 matrix_sum = sum ( list ( TOP . values ( ) ) ) TP_sum = sum ( list ( TP . values ( ) ) ) up = TOP [ class_name ] + P [ class_name ] down = 2 * matrix_sum if modified : down -= ( alpha * TP_sum ) up -= TP [ class_name ] return up / down except Exception : return "None"
Calculate Overall_CEN coefficient .
42,230
def ncr ( n , r ) : r = min ( r , n - r ) numer = reduce ( op . mul , range ( n , n - r , - 1 ) , 1 ) denom = reduce ( op . mul , range ( 1 , r + 1 ) , 1 ) return numer // denom
Calculate n choose r .
42,231
def p_value_calc ( TP , POP , NIR ) : try : n = POP x = sum ( list ( TP . values ( ) ) ) p = NIR result = 0 for j in range ( x ) : result += ncr ( n , j ) * ( p ** j ) * ( ( 1 - p ) ** ( n - j ) ) return 1 - result except Exception : return "None"
Calculate p_value .
42,232
def hamming_calc ( TP , POP ) : try : length = POP return ( 1 / length ) * ( length - sum ( TP . values ( ) ) ) except Exception : return "None"
Calculate hamming loss .
42,233
def zero_one_loss_calc ( TP , POP ) : try : length = POP return ( length - sum ( TP . values ( ) ) ) except Exception : return "None"
Calculate zero - one loss .
42,234
def entropy_calc ( item , POP ) : try : result = 0 for i in item . keys ( ) : likelihood = item [ i ] / POP [ i ] if likelihood != 0 : result += likelihood * math . log ( likelihood , 2 ) return - result except Exception : return "None"
Calculate reference and response likelihood .
42,235
def cross_entropy_calc ( TOP , P , POP ) : try : result = 0 for i in TOP . keys ( ) : reference_likelihood = P [ i ] / POP [ i ] response_likelihood = TOP [ i ] / POP [ i ] if response_likelihood != 0 and reference_likelihood != 0 : result += reference_likelihood * math . log ( response_likelihood , 2 ) return - result except Exception : return "None"
Calculate cross entropy .
42,236
def joint_entropy_calc ( classes , table , POP ) : try : result = 0 for i in classes : for index , j in enumerate ( classes ) : p_prime = table [ i ] [ j ] / POP [ i ] if p_prime != 0 : result += p_prime * math . log ( p_prime , 2 ) return - result except Exception : return "None"
Calculate joint entropy .
42,237
def conditional_entropy_calc ( classes , table , P , POP ) : try : result = 0 for i in classes : temp = 0 for index , j in enumerate ( classes ) : p_prime = 0 if P [ i ] != 0 : p_prime = table [ i ] [ j ] / P [ i ] if p_prime != 0 : temp += p_prime * math . log ( p_prime , 2 ) result += temp * ( P [ i ] / POP [ i ] ) return - result except Exception : return "None"
Calculate conditional entropy .
42,238
def lambda_B_calc ( classes , table , TOP , POP ) : try : result = 0 length = POP maxresponse = max ( list ( TOP . values ( ) ) ) for i in classes : result += max ( list ( table [ i ] . values ( ) ) ) result = ( result - maxresponse ) / ( length - maxresponse ) return result except Exception : return "None"
Calculate Goodman and Kruskal s lambda B .
42,239
def lambda_A_calc ( classes , table , P , POP ) : try : result = 0 maxreference = max ( list ( P . values ( ) ) ) length = POP for i in classes : col = [ ] for col_item in table . values ( ) : col . append ( col_item [ i ] ) result += max ( col ) result = ( result - maxreference ) / ( length - maxreference ) return result except Exception : return "None"
Calculate Goodman and Kruskal s lambda A .
42,240
def chi_square_calc ( classes , table , TOP , P , POP ) : try : result = 0 for i in classes : for index , j in enumerate ( classes ) : expected = ( TOP [ j ] * P [ i ] ) / ( POP [ i ] ) result += ( ( table [ i ] [ j ] - expected ) ** 2 ) / expected return result except Exception : return "None"
Calculate chi - squared .
42,241
def kappa_se_calc ( PA , PE , POP ) : try : result = math . sqrt ( ( PA * ( 1 - PA ) ) / ( POP * ( ( 1 - PE ) ** 2 ) ) ) return result except Exception : return "None"
Calculate kappa standard error .
42,242
def micro_calc ( TP , item ) : try : TP_sum = sum ( TP . values ( ) ) item_sum = sum ( item . values ( ) ) return TP_sum / ( TP_sum + item_sum ) except Exception : return "None"
Calculate PPV_Micro and TPR_Micro .
42,243
def macro_calc ( item ) : try : item_sum = sum ( item . values ( ) ) item_len = len ( item . values ( ) ) return item_sum / item_len except Exception : return "None"
Calculate PPV_Macro and TPR_Macro .
42,244
def PC_PI_calc ( P , TOP , POP ) : try : result = 0 for i in P . keys ( ) : result += ( ( P [ i ] + TOP [ i ] ) / ( 2 * POP [ i ] ) ) ** 2 return result except Exception : return "None"
Calculate percent chance agreement for Scott s Pi .
42,245
def PC_AC1_calc ( P , TOP , POP ) : try : result = 0 classes = list ( P . keys ( ) ) for i in classes : pi = ( ( P [ i ] + TOP [ i ] ) / ( 2 * POP [ i ] ) ) result += pi * ( 1 - pi ) result = result / ( len ( classes ) - 1 ) return result except Exception : return "None"
Calculate percent chance agreement for Gwet s AC1 .
42,246
def overall_jaccard_index_calc ( jaccard_list ) : try : jaccard_sum = sum ( jaccard_list ) jaccard_mean = jaccard_sum / len ( jaccard_list ) return ( jaccard_sum , jaccard_mean ) except Exception : return "None"
Calculate overall jaccard index .
42,247
def overall_accuracy_calc ( TP , POP ) : try : overall_accuracy = sum ( TP . values ( ) ) / POP return overall_accuracy except Exception : return "None"
Calculate overall accuracy .
42,248
def AUC_analysis ( AUC ) : try : if AUC == "None" : return "None" if AUC < 0.6 : return "Poor" if AUC >= 0.6 and AUC < 0.7 : return "Fair" if AUC >= 0.7 and AUC < 0.8 : return "Good" if AUC >= 0.8 and AUC < 0.9 : return "Very Good" return "Excellent" except Exception : return "None"
Analysis AUC with interpretation table .
42,249
def kappa_analysis_cicchetti ( kappa ) : try : if kappa < 0.4 : return "Poor" if kappa >= 0.4 and kappa < 0.59 : return "Fair" if kappa >= 0.59 and kappa < 0.74 : return "Good" if kappa >= 0.74 and kappa <= 1 : return "Excellent" return "None" except Exception : return "None"
Analysis kappa number with Cicchetti benchmark .
42,250
def kappa_analysis_koch ( kappa ) : try : if kappa < 0 : return "Poor" if kappa >= 0 and kappa < 0.2 : return "Slight" if kappa >= 0.20 and kappa < 0.4 : return "Fair" if kappa >= 0.40 and kappa < 0.6 : return "Moderate" if kappa >= 0.60 and kappa < 0.8 : return "Substantial" if kappa >= 0.80 and kappa <= 1 : return "Almost Perfect" return "None" except Exception : return "None"
Analysis kappa number with Landis - Koch benchmark .
42,251
def kappa_analysis_altman ( kappa ) : try : if kappa < 0.2 : return "Poor" if kappa >= 0.20 and kappa < 0.4 : return "Fair" if kappa >= 0.40 and kappa < 0.6 : return "Moderate" if kappa >= 0.60 and kappa < 0.8 : return "Good" if kappa >= 0.80 and kappa <= 1 : return "Very Good" return "None" except Exception : return "None"
Analysis kappa number with Altman benchmark .
42,252
def get_requires ( ) : requirements = open ( "requirements.txt" , "r" ) . read ( ) return list ( filter ( lambda x : x != "" , requirements . split ( ) ) )
Read requirements . txt .
42,253
def read_description ( ) : try : with open ( "README.md" ) as r : description = "\n" description += r . read ( ) with open ( "CHANGELOG.md" ) as c : description += "\n" description += c . read ( ) return description except Exception : return
Read README . md and CHANGELOG . md .
42,254
def print_matrix ( self , one_vs_all = False , class_name = None ) : classes = self . classes table = self . table if one_vs_all : [ classes , table ] = one_vs_all_func ( classes , table , self . TP , self . TN , self . FP , self . FN , class_name ) print ( table_print ( classes , table ) )
Print confusion matrix .
42,255
def stat ( self , overall_param = None , class_param = None , class_name = None ) : classes = class_filter ( self . classes , class_name ) print ( stat_print ( classes , self . class_stat , self . overall_stat , self . digit , overall_param , class_param ) )
Print statistical measures table .
42,256
def save_html ( self , name , address = True , overall_param = None , class_param = None , class_name = None , color = ( 0 , 0 , 0 ) , normalize = False ) : try : message = None table = self . table if normalize : table = self . normalized_table html_file = open ( name + ".html" , "w" ) html_file . write ( html_init ( name ) ) html_file . write ( html_dataset_type ( self . binary , self . imbalance ) ) html_file . write ( html_table ( self . classes , table , color , normalize ) ) html_file . write ( html_overall_stat ( self . overall_stat , self . digit , overall_param , self . recommended_list ) ) class_stat_classes = class_filter ( self . classes , class_name ) html_file . write ( html_class_stat ( class_stat_classes , self . class_stat , self . digit , class_param , self . recommended_list ) ) html_file . write ( html_end ( VERSION ) ) html_file . close ( ) if address : message = os . path . join ( os . getcwd ( ) , name + ".html" ) return { "Status" : True , "Message" : message } except Exception as e : return { "Status" : False , "Message" : str ( e ) }
Save ConfusionMatrix in HTML file .
42,257
def save_csv ( self , name , address = True , class_param = None , class_name = None , matrix_save = True , normalize = False ) : try : message = None classes = class_filter ( self . classes , class_name ) csv_file = open ( name + ".csv" , "w" ) csv_data = csv_print ( classes , self . class_stat , self . digit , class_param ) csv_file . write ( csv_data ) if matrix_save : matrix = self . table if normalize : matrix = self . normalized_table csv_matrix_file = open ( name + "_matrix" + ".csv" , "w" ) csv_matrix_data = csv_matrix_print ( self . classes , matrix ) csv_matrix_file . write ( csv_matrix_data ) if address : message = os . path . join ( os . getcwd ( ) , name + ".csv" ) return { "Status" : True , "Message" : message } except Exception as e : return { "Status" : False , "Message" : str ( e ) }
Save ConfusionMatrix in CSV file .
42,258
def save_obj ( self , name , address = True ) : try : message = None obj_file = open ( name + ".obj" , "w" ) actual_vector_temp = self . actual_vector predict_vector_temp = self . predict_vector matrix_temp = { k : self . table [ k ] . copy ( ) for k in self . classes } matrix_items = [ ] for i in self . classes : matrix_items . append ( ( i , list ( matrix_temp [ i ] . items ( ) ) ) ) if isinstance ( actual_vector_temp , numpy . ndarray ) : actual_vector_temp = actual_vector_temp . tolist ( ) if isinstance ( predict_vector_temp , numpy . ndarray ) : predict_vector_temp = predict_vector_temp . tolist ( ) json . dump ( { "Actual-Vector" : actual_vector_temp , "Predict-Vector" : predict_vector_temp , "Matrix" : matrix_items , "Digit" : self . digit , "Sample-Weight" : self . weights , "Transpose" : self . transpose } , obj_file ) if address : message = os . path . join ( os . getcwd ( ) , name + ".obj" ) return { "Status" : True , "Message" : message } except Exception as e : return { "Status" : False , "Message" : str ( e ) }
Save ConfusionMatrix in . obj file .
42,259
def F_beta ( self , beta ) : try : F_dict = { } for i in self . TP . keys ( ) : F_dict [ i ] = F_calc ( TP = self . TP [ i ] , FP = self . FP [ i ] , FN = self . FN [ i ] , beta = beta ) return F_dict except Exception : return { }
Calculate FBeta score .
42,260
def IBA_alpha ( self , alpha ) : try : IBA_dict = { } for i in self . classes : IBA_dict [ i ] = IBA_calc ( self . TPR [ i ] , self . TNR [ i ] , alpha = alpha ) return IBA_dict except Exception : return { }
Calculate IBA_alpha score .
42,261
def relabel ( self , mapping ) : if not isinstance ( mapping , dict ) : raise pycmMatrixError ( MAPPING_FORMAT_ERROR ) if self . classes != list ( mapping . keys ( ) ) : raise pycmMatrixError ( MAPPING_CLASS_NAME_ERROR ) for row in self . classes : temp_dict = { } temp_dict_normalized = { } for col in self . classes : temp_dict [ mapping [ col ] ] = self . table [ row ] [ col ] temp_dict_normalized [ mapping [ col ] ] = self . normalized_table [ row ] [ col ] del self . table [ row ] self . table [ mapping [ row ] ] = temp_dict del self . normalized_table [ row ] self . normalized_table [ mapping [ row ] ] = temp_dict_normalized self . matrix = self . table self . normalized_matrix = self . normalized_table for param in self . class_stat . keys ( ) : temp_dict = { } for classname in self . classes : temp_dict [ mapping [ classname ] ] = self . class_stat [ param ] [ classname ] self . class_stat [ param ] = temp_dict self . classes = list ( mapping . values ( ) ) self . TP = self . class_stat [ "TP" ] self . TN = self . class_stat [ "TN" ] self . FP = self . class_stat [ "FP" ] self . FN = self . class_stat [ "FN" ] __class_stat_init__ ( self )
Rename ConfusionMatrix classes .
42,262
def add_tools ( self ) : for data in self . toolbardata : if data [ 0 ] == "T" : _ , msg_type , label , tool_tip = data icon = icons [ label ] self . label2id [ label ] = tool_id = wx . NewId ( ) self . AddSimpleTool ( tool_id , label , icon , short_help_string = tool_tip ) self . ids_msgs [ tool_id ] = msg_type self . parent . Bind ( wx . EVT_TOOL , self . OnTool , id = tool_id ) elif data [ 0 ] == "S" : self . AddSeparator ( ) elif data [ 0 ] == "C" : _ , control , tool_tip = data self . AddControl ( control , label = tool_tip ) elif data [ 0 ] == "O" : _ , label , tool_tip = data icon = icons [ label ] self . label2id [ label ] = tool_id = wx . NewId ( ) self . AddCheckTool ( tool_id , label , icon , icon , tool_tip ) else : raise ValueError ( "Unknown tooltype " + str ( data [ 0 ] ) ) self . SetCustomOverflowItems ( [ ] , [ ] ) self . Realize ( ) self . SetSize ( self . DoGetBestSize ( ) )
Adds tools from self . toolbardata to self
42,263
def OnTool ( self , event ) : msgtype = self . ids_msgs [ event . GetId ( ) ] post_command_event ( self , msgtype )
Toolbar event handler
42,264
def OnToggleTool ( self , event ) : config [ "check_spelling" ] = str ( event . IsChecked ( ) ) toggle_id = self . parent . menubar . FindMenuItem ( _ ( "View" ) , _ ( "Check spelling" ) ) if toggle_id != - 1 : toggle_item = self . parent . menubar . FindItemById ( toggle_id ) toggle_item . Check ( event . IsChecked ( ) ) self . parent . grid . grid_renderer . cell_cache . clear ( ) self . parent . grid . ForceRefresh ( ) event . Skip ( )
Tool event handler
42,265
def _get_button_label ( self ) : dlg = wx . TextEntryDialog ( self , _ ( 'Button label:' ) ) if dlg . ShowModal ( ) == wx . ID_OK : label = dlg . GetValue ( ) else : label = "" dlg . Destroy ( ) return label
Gets Button label from user and returns string
42,266
def OnButtonCell ( self , event ) : if self . button_cell_button_id == event . GetId ( ) : if event . IsChecked ( ) : label = self . _get_button_label ( ) post_command_event ( self , self . ButtonCellMsg , text = label ) else : post_command_event ( self , self . ButtonCellMsg , text = False ) event . Skip ( )
Event handler for cell button toggle button
42,267
def OnVideoCell ( self , event ) : if self . video_cell_button_id == event . GetId ( ) : if event . IsChecked ( ) : wildcard = _ ( "Media files" ) + " (*.*)|*.*" videofile , __ = self . get_filepath_findex_from_user ( wildcard , "Choose video or audio file" , wx . OPEN ) post_command_event ( self , self . VideoCellMsg , videofile = videofile ) else : post_command_event ( self , self . VideoCellMsg , videofile = False ) event . Skip ( )
Event handler for video cell toggle button
42,268
def make_menu ( self ) : menu = wx . Menu ( ) item = menu . Append ( - 1 , "Recent Searches" ) item . Enable ( False ) for __id , txt in enumerate ( self . search_history ) : menu . Append ( __id , txt ) return menu
Creates the search menu
42,269
def OnMenu ( self , event ) : __id = event . GetId ( ) try : menuitem = event . GetEventObject ( ) . FindItemById ( __id ) selected_text = menuitem . GetItemLabel ( ) self . search . SetValue ( selected_text ) except AttributeError : event . Skip ( )
Search history has been selected
42,270
def OnSearch ( self , event ) : search_string = self . search . GetValue ( ) if search_string not in self . search_history : self . search_history . append ( search_string ) if len ( self . search_history ) > 10 : self . search_history . pop ( 0 ) self . menu = self . make_menu ( ) self . search . SetMenu ( self . menu ) search_flags = self . search_options + [ "FIND_NEXT" ] post_command_event ( self , self . FindMsg , text = search_string , flags = search_flags ) self . search . SetFocus ( )
Event handler for starting the search
42,271
def OnSearchDirectionButton ( self , event ) : if "DOWN" in self . search_options : flag_index = self . search_options . index ( "DOWN" ) self . search_options [ flag_index ] = "UP" elif "UP" in self . search_options : flag_index = self . search_options . index ( "UP" ) self . search_options [ flag_index ] = "DOWN" else : raise AttributeError ( _ ( "Neither UP nor DOWN in search_flags" ) ) event . Skip ( )
Event handler for search direction toggle button
42,272
def OnSearchFlag ( self , event ) : for label in self . search_options_buttons : button_id = self . label2id [ label ] if button_id == event . GetId ( ) : if event . IsChecked ( ) : self . search_options . append ( label ) else : flag_index = self . search_options . index ( label ) self . search_options . pop ( flag_index ) event . Skip ( )
Event handler for search flag toggle buttons
42,273
def _create_font_choice_combo ( self ) : self . fonts = get_font_list ( ) self . font_choice_combo = _widgets . FontChoiceCombobox ( self , choices = self . fonts , style = wx . CB_READONLY , size = ( 125 , - 1 ) ) self . font_choice_combo . SetToolTipString ( _ ( u"Text font" ) ) self . AddControl ( self . font_choice_combo ) self . Bind ( wx . EVT_COMBOBOX , self . OnTextFont , self . font_choice_combo ) self . parent . Bind ( self . EVT_CMD_TOOLBAR_UPDATE , self . OnUpdate )
Creates font choice combo box
42,274
def _create_font_size_combo ( self ) : self . std_font_sizes = config [ "font_default_sizes" ] font_size = str ( get_default_font ( ) . GetPointSize ( ) ) self . font_size_combo = wx . ComboBox ( self , - 1 , value = font_size , size = ( 60 , - 1 ) , choices = map ( unicode , self . std_font_sizes ) , style = wx . CB_DROPDOWN | wx . TE_PROCESS_ENTER ) self . font_size_combo . SetToolTipString ( _ ( u"Text size\n(points)" ) ) self . AddControl ( self . font_size_combo ) self . Bind ( wx . EVT_COMBOBOX , self . OnTextSize , self . font_size_combo ) self . Bind ( wx . EVT_TEXT_ENTER , self . OnTextSize , self . font_size_combo )
Creates font size combo box
42,275
def _create_font_face_buttons ( self ) : font_face_buttons = [ ( wx . FONTFLAG_BOLD , "OnBold" , "FormatTextBold" , _ ( "Bold" ) ) , ( wx . FONTFLAG_ITALIC , "OnItalics" , "FormatTextItalic" , _ ( "Italics" ) ) , ( wx . FONTFLAG_UNDERLINED , "OnUnderline" , "FormatTextUnderline" , _ ( "Underline" ) ) , ( wx . FONTFLAG_STRIKETHROUGH , "OnStrikethrough" , "FormatTextStrikethrough" , _ ( "Strikethrough" ) ) , ( wx . FONTFLAG_MASK , "OnFreeze" , "Freeze" , _ ( "Freeze" ) ) , ( wx . FONTFLAG_NOT_ANTIALIASED , "OnLock" , "Lock" , _ ( "Lock cell" ) ) , ( wx . FONTFAMILY_DECORATIVE , "OnMarkup" , "Markup" , _ ( "Markup" ) ) , ] for __id , method , iconname , helpstring in font_face_buttons : bmp = icons [ iconname ] self . AddCheckTool ( __id , iconname , bmp , bmp , short_help_string = helpstring ) self . Bind ( wx . EVT_TOOL , getattr ( self , method ) , id = __id )
Creates font face buttons
42,276
def _create_textrotation_button ( self ) : iconnames = [ "TextRotate270" , "TextRotate0" , "TextRotate90" , "TextRotate180" ] bmplist = [ icons [ iconname ] for iconname in iconnames ] self . rotation_tb = _widgets . BitmapToggleButton ( self , bmplist ) self . rotation_tb . SetToolTipString ( _ ( u"Cell text rotation" ) ) self . Bind ( wx . EVT_BUTTON , self . OnRotate , self . rotation_tb ) self . AddControl ( self . rotation_tb )
Create text rotation toggle button
42,277
def _create_justification_button ( self ) : iconnames = [ "JustifyLeft" , "JustifyCenter" , "JustifyRight" ] bmplist = [ icons [ iconname ] for iconname in iconnames ] self . justify_tb = _widgets . BitmapToggleButton ( self , bmplist ) self . justify_tb . SetToolTipString ( _ ( u"Justification" ) ) self . Bind ( wx . EVT_BUTTON , self . OnJustification , self . justify_tb ) self . AddControl ( self . justify_tb )
Creates horizontal justification button
42,278
def _create_alignment_button ( self ) : iconnames = [ "AlignTop" , "AlignCenter" , "AlignBottom" ] bmplist = [ icons [ iconname ] for iconname in iconnames ] self . alignment_tb = _widgets . BitmapToggleButton ( self , bmplist ) self . alignment_tb . SetToolTipString ( _ ( u"Alignment" ) ) self . Bind ( wx . EVT_BUTTON , self . OnAlignment , self . alignment_tb ) self . AddControl ( self . alignment_tb )
Creates vertical alignment button
42,279
def _create_borderchoice_combo ( self ) : choices = [ c [ 0 ] for c in self . border_toggles ] self . borderchoice_combo = _widgets . BorderEditChoice ( self , choices = choices , style = wx . CB_READONLY , size = ( 50 , - 1 ) ) self . borderchoice_combo . SetToolTipString ( _ ( u"Choose borders for which attributes are changed" ) ) self . borderstate = self . border_toggles [ 0 ] [ 0 ] self . AddControl ( self . borderchoice_combo ) self . Bind ( wx . EVT_COMBOBOX , self . OnBorderChoice , self . borderchoice_combo ) self . borderchoice_combo . SetValue ( "AllBorders" )
Create border choice combo box
42,280
def _create_penwidth_combo ( self ) : choices = map ( unicode , xrange ( 12 ) ) self . pen_width_combo = _widgets . PenWidthComboBox ( self , choices = choices , style = wx . CB_READONLY , size = ( 50 , - 1 ) ) self . pen_width_combo . SetToolTipString ( _ ( u"Border width" ) ) self . AddControl ( self . pen_width_combo ) self . Bind ( wx . EVT_COMBOBOX , self . OnLineWidth , self . pen_width_combo )
Create pen width combo box
42,281
def _create_color_buttons ( self ) : button_size = ( 30 , 30 ) button_style = wx . NO_BORDER try : self . linecolor_choice = csel . ColourSelect ( self , - 1 , unichr ( 0x2500 ) , ( 0 , 0 , 0 ) , size = button_size , style = button_style ) except UnicodeEncodeError : self . linecolor_choice = csel . ColourSelect ( self , - 1 , "-" , ( 0 , 0 , 0 ) , size = button_size , style = button_style ) self . bgcolor_choice = csel . ColourSelect ( self , - 1 , "" , ( 255 , 255 , 255 ) , size = button_size , style = button_style ) self . textcolor_choice = csel . ColourSelect ( self , - 1 , "A" , ( 0 , 0 , 0 ) , size = button_size , style = button_style ) self . linecolor_choice . SetToolTipString ( _ ( u"Border line color" ) ) self . bgcolor_choice . SetToolTipString ( _ ( u"Cell background" ) ) self . textcolor_choice . SetToolTipString ( _ ( u"Text color" ) ) self . AddControl ( self . linecolor_choice ) self . AddControl ( self . bgcolor_choice ) self . AddControl ( self . textcolor_choice ) self . linecolor_choice . Bind ( csel . EVT_COLOURSELECT , self . OnLineColor ) self . bgcolor_choice . Bind ( csel . EVT_COLOURSELECT , self . OnBGColor ) self . textcolor_choice . Bind ( csel . EVT_COLOURSELECT , self . OnTextColor )
Create color choice buttons
42,282
def _create_merge_button ( self ) : bmp = icons [ "Merge" ] self . mergetool_id = wx . NewId ( ) self . AddCheckTool ( self . mergetool_id , "Merge" , bmp , bmp , short_help_string = _ ( "Merge cells" ) ) self . Bind ( wx . EVT_TOOL , self . OnMerge , id = self . mergetool_id )
Create merge button
42,283
def _update_font ( self , textfont ) : try : fontface_id = self . fonts . index ( textfont ) except ValueError : fontface_id = 0 self . font_choice_combo . Select ( fontface_id )
Updates text font widget
42,284
def _update_font_weight ( self , font_weight ) : toggle_state = font_weight & wx . FONTWEIGHT_BOLD == wx . FONTWEIGHT_BOLD self . ToggleTool ( wx . FONTFLAG_BOLD , toggle_state )
Updates font weight widget
42,285
def _update_font_style ( self , font_style ) : toggle_state = font_style & wx . FONTSTYLE_ITALIC == wx . FONTSTYLE_ITALIC self . ToggleTool ( wx . FONTFLAG_ITALIC , toggle_state )
Updates font style widget
42,286
def _update_frozencell ( self , frozen ) : toggle_state = frozen is not False self . ToggleTool ( wx . FONTFLAG_MASK , toggle_state )
Updates frozen cell widget
42,287
def _update_textrotation ( self , angle ) : states = { 0 : 0 , - 90 : 1 , 180 : 2 , 90 : 3 } try : self . rotation_tb . state = states [ round ( angle ) ] except KeyError : self . rotation_tb . state = 0 self . rotation_tb . toggle ( None ) self . rotation_tb . Refresh ( )
Updates text rotation toggle button
42,288
def _update_justification ( self , justification ) : states = { "left" : 2 , "center" : 0 , "right" : 1 } self . justify_tb . state = states [ justification ] self . justify_tb . toggle ( None ) self . justify_tb . Refresh ( )
Updates horizontal text justification button
42,289
def _update_alignment ( self , alignment ) : states = { "top" : 2 , "middle" : 0 , "bottom" : 1 } self . alignment_tb . state = states [ alignment ] self . alignment_tb . toggle ( None ) self . alignment_tb . Refresh ( )
Updates vertical text alignment button
42,290
def _update_fontcolor ( self , fontcolor ) : textcolor = wx . SystemSettings_GetColour ( wx . SYS_COLOUR_WINDOWTEXT ) textcolor . SetRGB ( fontcolor ) self . textcolor_choice . SetColour ( textcolor )
Updates text font color button
42,291
def OnBorderChoice ( self , event ) : choicelist = event . GetEventObject ( ) . GetItems ( ) self . borderstate = choicelist [ event . GetInt ( ) ]
Change the borders that are affected by color and width changes
42,292
def OnLineColor ( self , event ) : color = event . GetValue ( ) . GetRGB ( ) borders = self . bordermap [ self . borderstate ] post_command_event ( self , self . BorderColorMsg , color = color , borders = borders )
Line color choice event handler
42,293
def OnLineWidth ( self , event ) : linewidth_combobox = event . GetEventObject ( ) idx = event . GetInt ( ) width = int ( linewidth_combobox . GetString ( idx ) ) borders = self . bordermap [ self . borderstate ] post_command_event ( self , self . BorderWidthMsg , width = width , borders = borders )
Line width choice event handler
42,294
def OnBGColor ( self , event ) : color = event . GetValue ( ) . GetRGB ( ) post_command_event ( self , self . BackgroundColorMsg , color = color )
Background color choice event handler
42,295
def OnTextColor ( self , event ) : color = event . GetValue ( ) . GetRGB ( ) post_command_event ( self , self . TextColorMsg , color = color )
Text color choice event handler
42,296
def OnTextFont ( self , event ) : fontchoice_combobox = event . GetEventObject ( ) idx = event . GetInt ( ) try : font_string = fontchoice_combobox . GetString ( idx ) except AttributeError : font_string = event . GetString ( ) post_command_event ( self , self . FontMsg , font = font_string )
Text font choice event handler
42,297
def OnTextSize ( self , event ) : try : size = int ( event . GetString ( ) ) except Exception : size = get_default_font ( ) . GetPointSize ( ) post_command_event ( self , self . FontSizeMsg , size = size )
Text size combo text event handler
42,298
def set_code ( self , key , code ) : old_code = self . grid . code_array ( key ) try : old_code = unicode ( old_code , encoding = "utf-8" ) except TypeError : pass if code == old_code : return if not ( old_code is None and not code ) and code != old_code : post_command_event ( self . main_window , self . ContentChangedMsg ) self . grid . code_array . __setitem__ ( key , code )
Sets code of cell key marks grid as changed
42,299
def quote_code ( self , key ) : code = self . grid . code_array ( key ) quoted_code = quote ( code ) if quoted_code is not None : self . set_code ( key , quoted_code )
Returns string quoted code