Skip to content

Commit

Permalink
Edit the target column name from label to target
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Serafino committed Jul 23, 2022
1 parent 2913711 commit d12f822
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dimensionality_reduction/services/plot_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
LABEL_FONT_SIZE = 12
FIGURE_SIZE = 10

def plot_2d(df: DataFrame, target_column: str = "label", title: str = None) -> None:
def plot_2d(df: DataFrame, target_column: str = "target", title: str = None) -> None:

plt.figure(figsize=((FIGURE_SIZE, FIGURE_SIZE)))

categories = df[target_column].unique()

for category in categories:
plt.scatter(df.loc[df[target_column] == category, df.columns[0]],
plt.scatter(
df.loc[df[target_column] == category, df.columns[0]],
df.loc[df[target_column] == category, df.columns[1]],
marker = 'o',
alpha = 0.5,
label=category)
label=category
)

plt.legend()

Expand All @@ -29,20 +31,22 @@ def plot_2d(df: DataFrame, target_column: str = "label", title: str = None) -> N

return None

def plot_3d(df: DataFrame, target_column: str = "label", title: str = None) -> None:
def plot_3d(df: DataFrame, target_column: str = "target", title: str = None) -> None:

fig = plt.figure(figsize = (FIGURE_SIZE, FIGURE_SIZE))
chart = fig.gca(projection = '3d')

categories = df[target_column].unique()

for category in categories:
chart.scatter(df.loc[df[target_column] == category, df.columns[0]],
chart.scatter(
df.loc[df[target_column] == category, df.columns[0]],
df.loc[df[target_column] == category, df.columns[1]],
df.loc[df[target_column] == category, df.columns[2]],
marker = 'o',
alpha = 0.5,
label=category)
label=category
)

chart.legend()

Expand All @@ -53,7 +57,7 @@ def plot_3d(df: DataFrame, target_column: str = "label", title: str = None) -> N

return None

def matrix_plot(df: DataFrame, target_column: str = "label", title: str = None) -> None:
def matrix_plot(df: DataFrame, target_column: str = "target", title: str = None) -> None:

pairplot(df, hue=target_column, height=2.5, palette="tab10")
plt.grid(b=True)
Expand Down

0 comments on commit d12f822

Please sign in to comment.