Sobes.tech
Middle — Senior

Kuidas visualiseerida tunnuse sõltuvust sihtmärgest diagrammil?

sobes.tech AI

Vastus AI-lt

To visualize the dependence of a feature on the target, different types of graphs are used depending on the feature and target types:

  • For numerical feature and numerical target:

    • Scatter plot — displays each pair (feature, target).
    • Line or average plot (e.g., moving average) to identify trends.
    • Boxplot or violin plot for grouping by feature ranges.
  • For categorical feature and numerical target:

    • Boxplot by categories — shows the distribution of the target for each category.
    • Bar chart with the mean value of the target per category.
  • For categorical target:

    • Histograms or bar charts of frequency by feature values for each target category.

Example in Python using matplotlib and seaborn:

import seaborn as sns
import matplotlib.pyplot as plt

# df — DataFrame with features and target
sns.scatterplot(data=df, x='feature', y='target')
plt.show()

# For categorical feature
sns.boxplot(data=df, x='categorical_feature', y='target')
plt.show()

This visualization helps to understand if there is a dependency, its shape and strength, as well as to identify outliers and anomalies.