def visualize_data(self):
"""
Transform the DataFrame to the 2-dimensional case and visualizes the data. The first tags are used as labels.
:return:
"""
logging.debug("Preparing visualization of DataFrame")
# Reduce dimensionality to 2 features for visualization purposes
X_visualization = self.reduce_dimensionality(self.X, n_features=2)
df = self.prepare_dataframe(X_visualization)
# Set X and Y coordinate for each articles
df['X coordinate'] = df['coordinates'].apply(lambda x: x[0])
df['Y coordinate'] = df['coordinates'].apply(lambda x: x[1])
# Create a list of markers, each tag has its own marker
n_tags_first = len(self.df['tags_first'].unique())
markers_choice_list = ['o', 's', '^', '.', 'v', '<', '>', 'D']
markers_list = [markers_choice_list[i % 8] for i in range(n_tags_first)]
# Create scatter plot
sns.lmplot("X coordinate",
"Y coordinate",
hue="tags_first",
data=df,
fit_reg=False,
markers=markers_list,
scatter_kws={"s": 150})
# Adjust borders and add title
sns.set(font_scale=2)
sns.plt.title('Visualization of TMT articles in a 2-dimensional space')
sns.plt.subplots_adjust(right=0.80, top=0.90, left=0.12, bottom=0.12)
# Show plot
sns.plt.show()
# Train recommender
评论列表
文章目录