如何实现T-SNE可视化(python)

1.结果 

如何实现T-SNE可视化(python)_第1张图片

 2.代码

# -*- coding: utf-8 -*-
"""
Created on Sun Sep 19 09:33:20 2021

@author: pony
"""

import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.manifold import TSNE


class FeatureVisualize(object):
    '''
    Visualize features by TSNE
    '''

    def __init__(self, features, labels):
        '''
        features: (m,n)
        labels: (m,)
        '''
        self.features = features
        self.labels = labels

    def plot_tsne(self, save_eps=False):
        ''' Plot TSNE figure. Set save_eps=True if you want to save a .eps file.
        '''

你可能感兴趣的:(轴承故障诊断,python)