import pandas as pd #=====================META-FEATURE EXTRACTION================================== with open(str(p.parents[5]) + '/actual/wine_metafeatures_202.pickle', 'rb') as handle: meta_features = pickle.load(handle) #============Load the meta-dataset and model performance of each dataset======= df_results = pd.read_pickle(str(p.parents[7]) + '/test/df_results.plk') #nested_results is a nested dictionary with all the AUC-ROC performances for each dataset and all models with open(str(p.parents[6]) + '/nested_results_prc.pickle', 'rb') as handle: nested_results_prc = pickle.load(handle) #========================META-LEARNING: RANKING================================ #KNN Ranking Method top1, top2, top3 = KNN_ranking(df_results, meta_features, nested_results_prc) print("==========================================") print(" AUC-PRC ") print("==========================================") print("Top 1 predicted model: " + top1) print("Top 2 predicted model: " + top2) print("Top 3 predicted model: " + top3) #Actual results with open(str(p.parents[5]) + '/actual/wine_top_3_prc.pickle', 'rb') as handle: actual_results = pickle.load(handle) print("==========================================") print("Top 1 ACTUAL model: " + actual_results[0]) print("Top 2 ACTUAL model: " + actual_results[1]) print("Top 3 ACTUAL model: " + actual_results[2])
Remove the meta-features which are not in the meta-dataset (i.e. the features which have not been selected in the feature selection process) """ metafeatures_to_be_removed = [] for metafeature in meta_features.keys(): if metafeature in metadataset_feature_selected.columns: pass else: metafeatures_to_be_removed.append(metafeature) [meta_features.pop(key) for key in metafeatures_to_be_removed] #========================META-LEARNING: RANKING================================ #KNN Ranking Method top1, top2, top3 = KNN_ranking(metadataset_feature_selected, meta_features, nested_results_prc) print("==========================================") print(" AUC-PRC ") print("==========================================") print("Top 1 predicted model: " + top1) print("Top 2 predicted model: " + top2) print("Top 3 predicted model: " + top3) #Actual results with open(str(p.parents[5]) + '/actual/wine_top_3_prc.pickle', 'rb') as handle: actual_results = pickle.load(handle) print("==========================================") print("Top 1 ACTUAL model: " + actual_results[0]) print("Top 2 ACTUAL model: " + actual_results[1]) print("Top 3 ACTUAL model: " + actual_results[2])
for metafeature in wine_meta_features.keys(): if metafeature in metadataset_feature_selected.columns: pass else: metafeatures_to_be_removed.append(metafeature) [wine_meta_features.pop(key) for key in metafeatures_to_be_removed] times = [] for i in range(3, 203): start_time = time.time() temp_metadaset = metadataset_feature_selected.iloc[:i, :] top1, top2, top3 = KNN_ranking(temp_metadaset, wine_meta_features, nested_results_roc) times.append((time.time() - start_time)) training_datasets = list(range(3, 203)) plt.figure(dpi=1200) plt.plot(training_datasets, times, color='blue', label='Cylindrical bands dataset') plt.legend(loc="upper left", fontsize=12) plt.xlabel('Number of training datasets', fontsize=14) plt.ylabel('Execution time of meta-learning [s]', fontsize=14) plt.xticks(fontsize=12) plt.yticks(fontsize=12) plt.show()