-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clustering allows match weight args not just match probability #2454
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Possible chart showing how num clusters varies with mw import altair as alt
import pandas as pd
cc = cluster_pairwise_predictions_at_multiple_thresholds(
nodes,
edges,
node_id_column_name="my_id",
db_api=db_api,
# match_probability_thresholds=thresholds,
match_weight_thresholds=thresholds_weights,
output_cluster_summary_stats=True,
)
dc_df = cc.as_duckdbpyrelation().df()
# Define the options for the x-axis
x_axis_options = ['threshold_match_probability', 'threshold_match_weight']
# Create a selection parameter with radio buttons
x_axis_param = alt.param(
name='x_field',
bind=alt.binding_radio(options=x_axis_options, name='X-axis: '),
value='threshold_match_probability'
)
# Base chart with dynamic x-axis based on the parameter
base_chart = (
alt.Chart(dc_df)
.transform_fold(
fold=['threshold_match_probability', 'threshold_match_weight'],
as_=['variable', 'x_value']
)
.transform_filter(
alt.datum.variable == x_axis_param
)
.add_params(x_axis_param)
.encode(
x=alt.X('x_value:Q', title='X-axis')
)
.properties(width=400, height=150)
)
# Define the subcharts
num_clusters = (
base_chart.mark_line()
.encode(
y=alt.Y("num_clusters:Q", title="Number of Clusters")
)
.properties(title="Number of Clusters vs X-axis")
)
max_cluster_size = (
base_chart.mark_line()
.encode(
y=alt.Y("max_cluster_size:Q", title="Max Cluster Size")
)
.properties(title="Maximum Cluster Size vs X-axis")
)
avg_cluster_size = (
base_chart.mark_line()
.encode(
y=alt.Y("avg_cluster_size:Q", title="Average Cluster Size")
)
.properties(title="Average Cluster Size vs X-axis")
)
# Combine the charts
combined_chart = alt.vconcat(
num_clusters, max_cluster_size, avg_cluster_size
).resolve_scale(y="independent")
|
The reason for this is that checkpointing can cause the schema to be lost if there are zero rows. Whereas parquet preserves the schema
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows all clustering functions to take a match weight threshold argument instead of a match probability threshold.
You can now provide either (but not both), which makes the behaviour consistent with e.g.
inference.predict()