Skip to content

Commit

Permalink
Merge branch 'mainline' into drift-categories
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeAdachi committed May 20, 2022
2 parents 5142081 + d092535 commit f6b8938
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,12 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
const minY = Math.abs(d3.min(data));
let positiveY = Math.ceil(maxY) % 1 ? maxY + 2*(maxY/(maxY*10)) : maxY + 2*(maxY/(maxY/10)),
negativeY = Math.ceil(minY) % 1 ? minY + 2*(minY/(minY*10)) : minY + 2*(minY/(minY/10));

const yScale = d3.scaleLinear()
.domain([-negativeY, positiveY || 0])
.range([CHART_HEIGHT,0])

.domain([-negativeY*1.2, positiveY*1.2 || 0])
.nice()
const xAxis = d3.axisBottom(xScale).ticks(SVG_WIDTH / 80, xFormat).tickSizeOuter(0);
const yAxis = d3.axisLeft(yScale).ticks(CHART_HEIGHT / 30, yFormat);
yFormat = yScale.tickFormat(100, yFormat);

svgEl.append("g")
.attr("transform", `translate(${MARGIN.LEFT}, 0)`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,19 @@ <h1 class="no-responsive__title">Hold on! :)</h1>

this.xScale = d3
.scaleLinear()
.domain([d3.min(this.charts2, function(d) { return parseFloat(d.axisX); }),(this.maxTargetXValue+this.targetBinWidth >= this.maxReferenceXValue+this.referenceBinWidth) ? this.maxTargetXValue+this.targetBinWidth:this.maxReferenceXValue+this.referenceBinWidth]) // I was too lazy to do basic math of max(bin_start + width for each distribution)
.domain([d3.min(this.charts2, function(d) { return parseFloat(d.axisX); }),(this.maxTargetXValue+this.targetBinWidth >= this.maxReferenceXValue+this.referenceBinWidth) ? this.maxTargetXValue+this.targetBinWidth:this.maxReferenceXValue+this.referenceBinWidth])
.range([0, this.CHART_WIDTH ]);

this.svgEl.append("g")
.attr("transform", "translate("+ this.MARGIN.LEFT +"," + this.SVG_HEIGHT + ")")
.call(d3.axisBottom(this.xScale));
this.yScale = d3.scaleLinear()
.range([this.CHART_HEIGHT , 0])
this.yScale.domain([d3.min(this.charts2, function(d) { return parseFloat(d.axisY); }), d3.max(this.charts2, function(d) { return parseFloat(d.axisY); })]);
.domain([d3.min(this.charts2, function(d) { return parseFloat(d.axisY); }), d3.max(this.charts2, function(d) { return parseFloat(d.axisY); })*1.2])
.nice();
}
}

function chartData(column) {
const data = [];
if (column.numberSummary?.histogram) {
Expand Down Expand Up @@ -300,8 +301,7 @@ <h1 class="no-responsive__title">Hold on! :)</h1>
} = sizes

const rectColors = ["#44C0E7", "#F5843C"]
const yAxis = d3.axisLeft(yScale).ticks(SVG_HEIGHT / 40, yFormat);
yFormat = yScale.tickFormat(100, yFormat);
const yAxis = d3.axisLeft(yScale).ticks(SVG_HEIGHT / 40);

svgEl.append("g")
.attr("transform", `translate(${MARGIN.LEFT}, ${MARGIN.BOTTOM})`)
Expand Down
9 changes: 6 additions & 3 deletions src/whylogs/viz/utils/profile_viz_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)
from whylogs.proto import InferredType, ReferenceDistributionDiscreteMessage

categorical_types = (InferredType.Type.INTEGRAL, InferredType.Type.STRING, InferredType.Type.BOOLEAN)
categorical_types = (InferredType.Type.STRING, InferredType.Type.BOOLEAN)


def __calculate_variance(profile_jsons, feature_name):
Expand Down Expand Up @@ -124,8 +124,9 @@ def add_drift_val_to_ref_profile_json(target_profile, reference_profile, referen
if target_col_name in reference_profile.columns:
ref_col = reference_profile.columns[target_col_name]
target_type = target_col.schema_tracker.to_summary().inferred_type.type
unique_count = target_col.to_summary().unique_count
ref_type = ref_col.schema_tracker.to_summary().inferred_type.type
if all([type == InferredType.FRACTIONAL for type in (ref_type, target_type)]):
if all([type == InferredType.FRACTIONAL or type == InferredType.INTEGRAL for type in (ref_type, target_type)]):
target_kll_sketch = target_col.number_tracker.histogram
reference_kll_sketch = ref_col.number_tracker.histogram
ks_p_value = ks_test_compute_p_value(target_kll_sketch, reference_kll_sketch)
Expand All @@ -136,7 +137,9 @@ def add_drift_val_to_ref_profile_json(target_profile, reference_profile, referen
if any([msg.to_summary() is None for msg in (target_frequent_items_sketch, reference_frequent_items_sketch)]):
continue
target_total_count = target_col.counters.count
target_message = ReferenceDistributionDiscreteMessage(frequent_items=target_frequent_items_sketch.to_summary(), total_count=target_total_count)
target_message = ReferenceDistributionDiscreteMessage(
frequent_items=target_frequent_items_sketch.to_summary(), unique_count=unique_count, total_count=target_total_count
)
ref_total_count = ref_col.counters.count

reference_message = ReferenceDistributionDiscreteMessage(
Expand Down

0 comments on commit f6b8938

Please sign in to comment.