Elbow Curve¶
General¶
VerticaPy’s Elbow Curve tool is a valuable asset for optimizing clustering models,
particularly those employing algorithms like K-Means. This tool allows users
to assess the performance of the clustering algorithm by plotting the distortion
(inertia) against varying numbers of clusters (k values). Analyzing the Elbow
Curve helps data analysts pinpoint the optimal number of clusters where the rate
of decrease in distortion slows down, resembling the bend in an “elbow”.
This information is crucial for selecting an appropriate value for the number
of clusters in a dataset. By leveraging the insights gained from the Elbow Curve,
data analysts can enhance the efficiency of their clustering models, avoid
overfitting or underfitting, and make informed decisions to achieve optimal model performance.
Let’s begin by importing VerticaPy.
Let’s use the iris dataset from verticapy.datasets for this example.
from verticapy.datasets import load_iris
data = load_iris()
In the context of data visualization, we have the flexibility to harness multiple plotting libraries to craft a wide range of graphical representations. VerticaPy, as a versatile tool, provides support for several graphic libraries, such as Matplotlib, Highcharts, and Plotly. Each of these libraries offers unique features and capabilities, allowing us to choose the most suitable one for our specific data visualization needs.
Note
To select the desired plotting library, we simply need to use the set_option
function. VerticaPy offers the flexibility to smoothly transition between
different plotting libraries. In instances where a particular graphic is
not supported by the chosen library or is not supported within the VerticaPy
framework, the tool will automatically generate a warning and then switch
to an alternative library where the graphic can be created.
Please click on the tabs to view the various graphics generated by the different plotting libraries.
We can switch to using the plotly module.
vp.set_option("plotting_lib", "plotly")
Let’s generate the Validation Curve.
elbow(
input_relation = data,
X = ["PetalLengthCm", "PetalWidthCm"]
)
We can switch to using the highcharts module.
vp.set_option("plotting_lib", "highcharts")
Let’s generate the Validation Curve.
elbow(
input_relation = data,
X = ["PetalLengthCm", "PetalWidthCm"]
)
We can switch to using the matplotlib module.
vp.set_option("plotting_lib", "matplotlib")
Let’s generate the Validation Curve.
elbow(
input_relation = data,
X = ["PetalLengthCm", "PetalWidthCm"]
)
Out[1]: <Axes: title={'center': 'Elbow Curve'}, xlabel='Number of Clusters', ylabel='Elbow Score (Between-Cluster SS / Total SS)'>
Chart Customization¶
VerticaPy empowers users with a high degree of flexibility when it comes to tailoring the visual aspects of their plots. This customization extends to essential elements such as color schemes, text labels, and plot sizes, as well as a wide range of other attributes that can be fine-tuned to align with specific design preferences and analytical requirements. Whether you want to make your visualizations more visually appealing or need to convey specific insights with precision, VerticaPy’s customization options enable you to craft graphics that suit your exact needs.