def plot_IsoMap(objectives, n_neighbors, ax, name): class_dummy = np.zeros(len(objectives)) visualizer = Manifold(manifold='isomap', n_neighbors=n_neighbors, classes=[name], ax=ax) visualizer.fit_transform(objectives, class_dummy) visualizer.show()
def manifold_embeding(data, name=name, location=location, target=target, manifold=manifold, n_neighbors=n_neighbors): classes = data[target].unique() data[target].replace(0, "0", inplace=True) le = preprocessing.LabelEncoder() le.fit(data[target]) y = le.transform(data[target]) data_test = data.drop([target], axis=1) ax = plt.axes() vizualisation = Manifold(classes=classes, manifold=manifold, n_neighbors=n_neighbors, ax=ax) vizualisation.fit_transform(data_test, y) plot_name = f"Manifold_{manifold}_{name}.png" vizualisation.show(outpath=os.path.join(location, plot_name)) plt.close()
def plot_MDS(objectives, ax, name): class_dummy = np.zeros(len(objectives)) visualizer = Manifold(manifold='mds', classes=[name], ax=ax) visualizer.fit_transform(objectives, class_dummy) visualizer.show()
visualizer.transform(dfrad.iloc[:, :50]) # Transform the data visualizer.show() # Finalize and render the figure #MANIFOLD - No balanced from yellowbrick.features import Manifold classes = [1, 0] from sklearn import preprocessing label_encoder = preprocessing.LabelEncoder( ) #label_encoder object knows how to understand word labels. dfrad['activities'] = label_encoder.fit_transform( dfrad['activities']) #Encode labels dfrad['activities'].unique() viz = Manifold(manifold="tsne", classes=classes) # Instantiate the visualizer viz.fit_transform(dfrad.iloc[:, :100], dfrad['activities']) # Fit the data to the visualizer viz.show() # Finalize and render the figure # ============================================================================= # #CLASS BALANCE - Balanced (DO NOT USE. Draft) # ============================================================================= #m2_train_s_bk_bal #dataframe #m2_test_s_bk_bal #dataframe #ai_train_rav_bal = np.ravel(y_rus) #ai_test_rav_bal = np.ravel(y_rus2) y_rus_df = pd.DataFrame(y_rus) frames_bal = [m2_train_s_bk_bal, y_rus_df] import pandas as pd dfrad_bal = pd.concat(frames_bal, axis=1) dfrad_bal = dfrad.dropna()