wizata-dsapi 2.0.0.dev21__tar.gz → 2.0.0.dev22__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {wizata_dsapi-2.0.0.dev21/wizata_dsapi.egg-info → wizata_dsapi-2.0.0.dev22}/PKG-INFO +1 -1
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/models/common.py +4 -17
- wizata_dsapi-2.0.0.dev22/wizata_dsapi/plots/__init__.py +2 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/plots/common.py +111 -41
- wizata_dsapi-2.0.0.dev22/wizata_dsapi/plots/theme.py +104 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/scripts/common.py +5 -25
- wizata_dsapi-2.0.0.dev22/wizata_dsapi/version.py +1 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22/wizata_dsapi.egg-info}/PKG-INFO +1 -1
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi.egg-info/SOURCES.txt +1 -0
- wizata_dsapi-2.0.0.dev21/wizata_dsapi/plots/__init__.py +0 -1
- wizata_dsapi-2.0.0.dev21/wizata_dsapi/version.py +0 -1
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/LICENSE.txt +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/README.rst +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/setup.cfg +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/setup.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/__init__.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/api_config.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/api_dto.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/api_interface.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/bucket.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/business_label.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/context.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/dashboard.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/dataframe_toolkit.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/datapoint.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/datastore.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/ds_dataframe.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/dsapi_json_encoder.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/edge_config.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/edge_device.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/edge_module.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/evaluation.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/execution.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/execution_log.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/experiment.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/graylog_log.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/group_system.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/ilogger.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/insight.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/mlmodel.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/mobile_asset.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/model_toolkit.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/models/__init__.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/notification.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/paged_query_result.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/pipeline.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/pipeline_image.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/plot.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/request.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/script.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/scripts/__init__.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/search.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/solution_component.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/streamlit_utils.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/template.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/template_config.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/trigger.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/twin.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/twinregistration.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/user.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/wizard_function.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/wizard_request.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/wizata_dsapi_client.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi/words.py +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi.egg-info/dependency_links.txt +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi.egg-info/requires.txt +0 -0
- {wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi.egg-info/top_level.txt +0 -0
|
@@ -36,10 +36,7 @@ def extract_target_feat(context: wizata_dsapi.Context, single: bool = True):
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
def linear_regression(context: wizata_dsapi.Context):
|
|
39
|
-
"""
|
|
40
|
-
generic linear regression
|
|
41
|
-
- expects a valid single value target_feat
|
|
42
|
-
"""
|
|
39
|
+
"""Train a linear regression model on all features to predict a single target column."""
|
|
43
40
|
df = context.dataframe
|
|
44
41
|
|
|
45
42
|
model_config = context.get_model_config()
|
|
@@ -57,10 +54,7 @@ def linear_regression(context: wizata_dsapi.Context):
|
|
|
57
54
|
|
|
58
55
|
|
|
59
56
|
def logistic_regression(context: wizata_dsapi.Context):
|
|
60
|
-
"""
|
|
61
|
-
generic linear regression
|
|
62
|
-
- expects a valid single value target_feat
|
|
63
|
-
"""
|
|
57
|
+
"""Train a logistic regression classifier on all features to predict a binary target column."""
|
|
64
58
|
df = context.dataframe
|
|
65
59
|
|
|
66
60
|
model_config = context.get_model_config()
|
|
@@ -78,10 +72,7 @@ def logistic_regression(context: wizata_dsapi.Context):
|
|
|
78
72
|
|
|
79
73
|
|
|
80
74
|
def isolation_forest(context: wizata_dsapi.Context):
|
|
81
|
-
"""
|
|
82
|
-
isolation forest anomaly detection
|
|
83
|
-
- expects a no target feat model step
|
|
84
|
-
"""
|
|
75
|
+
"""Train an Isolation Forest for unsupervised anomaly detection using a sensitivity level (1-5)."""
|
|
85
76
|
|
|
86
77
|
model_config = context.get_model_config()
|
|
87
78
|
if model_config.has_target_feat():
|
|
@@ -104,11 +95,7 @@ def isolation_forest(context: wizata_dsapi.Context):
|
|
|
104
95
|
|
|
105
96
|
|
|
106
97
|
def gradiant_boost_classifier(context: wizata_dsapi.Context):
|
|
107
|
-
"""
|
|
108
|
-
gradiant_boost_classifier
|
|
109
|
-
:param context:
|
|
110
|
-
:return:
|
|
111
|
-
"""
|
|
98
|
+
"""Train a Gradient Boosting classifier on all features to predict a target column."""
|
|
112
99
|
df = context.dataframe
|
|
113
100
|
|
|
114
101
|
model_config = context.get_model_config()
|
|
@@ -6,6 +6,12 @@ import plotly.graph_objects as go
|
|
|
6
6
|
import plotly.express as px
|
|
7
7
|
import sklearn.metrics
|
|
8
8
|
|
|
9
|
+
from .theme import (
|
|
10
|
+
apply_theme, SERIES_COLORS, ANOMALY_COLOR, TEXT_MUTED, WHITE,
|
|
11
|
+
TABLE_HEADER_BG, TABLE_HEADER_TEXT, TABLE_CELL_BG, TABLE_CELL_TEXT,
|
|
12
|
+
TABLE_LINE_COLOR, FONT_FAMILY, FONT_SIZE,
|
|
13
|
+
)
|
|
14
|
+
|
|
9
15
|
|
|
10
16
|
def check_single_column_and_target_feat(context: wizata_dsapi.Context):
|
|
11
17
|
"""
|
|
@@ -45,11 +51,7 @@ def check_single_column_and_target_feat(context: wizata_dsapi.Context):
|
|
|
45
51
|
|
|
46
52
|
|
|
47
53
|
def confusion_matrix(context: wizata_dsapi.Context):
|
|
48
|
-
"""
|
|
49
|
-
confusion_matrix
|
|
50
|
-
:param context:
|
|
51
|
-
:return:
|
|
52
|
-
"""
|
|
54
|
+
"""Plot a confusion matrix heatmap comparing predicted vs actual binary classes."""
|
|
53
55
|
predict_df, ref_df = check_single_column_and_target_feat(context)
|
|
54
56
|
cm = sklearn.metrics.confusion_matrix(ref_df, predict_df)
|
|
55
57
|
inverted_cm = np.flip(cm, axis=1)
|
|
@@ -58,8 +60,8 @@ def confusion_matrix(context: wizata_dsapi.Context):
|
|
|
58
60
|
z=inverted_cm,
|
|
59
61
|
x=['Positive', 'Negative'],
|
|
60
62
|
y=['Negative', 'Positive'],
|
|
61
|
-
colorscale='
|
|
62
|
-
colorbar=dict(title='Count')
|
|
63
|
+
colorscale=[[0, '#062B56'], [1, '#E64600']],
|
|
64
|
+
colorbar=dict(title='Count', tickfont=dict(color=TEXT_MUTED)),
|
|
63
65
|
))
|
|
64
66
|
|
|
65
67
|
for i in range(len(inverted_cm)):
|
|
@@ -69,7 +71,7 @@ def confusion_matrix(context: wizata_dsapi.Context):
|
|
|
69
71
|
y=i,
|
|
70
72
|
text=str(inverted_cm[i][j]),
|
|
71
73
|
showarrow=False,
|
|
72
|
-
font=dict(color=
|
|
74
|
+
font=dict(color=WHITE if inverted_cm[i][j] > np.max(inverted_cm) / 2 else TEXT_MUTED)
|
|
73
75
|
)
|
|
74
76
|
|
|
75
77
|
fig.update_layout(
|
|
@@ -77,6 +79,8 @@ def confusion_matrix(context: wizata_dsapi.Context):
|
|
|
77
79
|
yaxis=dict(title='Actual')
|
|
78
80
|
)
|
|
79
81
|
|
|
82
|
+
apply_theme(fig)
|
|
83
|
+
|
|
80
84
|
context.set_plot(
|
|
81
85
|
figure=fig,
|
|
82
86
|
name="confusion_matrix"
|
|
@@ -84,34 +88,41 @@ def confusion_matrix(context: wizata_dsapi.Context):
|
|
|
84
88
|
|
|
85
89
|
|
|
86
90
|
def r_squared(context: wizata_dsapi.Context):
|
|
87
|
-
"""
|
|
88
|
-
In statistics, the coefficient of determination, denoted R2 or r2 and pronounced "R squared", is the proportion of
|
|
89
|
-
the variation in the dependent variable that is predictable from the independent variable(s).
|
|
90
|
-
"""
|
|
91
|
+
"""Plot actual vs predicted scatter with R-squared coefficient and reference diagonal."""
|
|
91
92
|
predict_df, ref_df = check_single_column_and_target_feat(context)
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
r2 = sklearn.metrics.r2_score(ref_df, predict_df)
|
|
94
95
|
|
|
95
96
|
fig = go.Figure()
|
|
96
|
-
fig.add_trace(go.Scatter(
|
|
97
|
-
|
|
97
|
+
fig.add_trace(go.Scatter(
|
|
98
|
+
x=ref_df.values.flatten(),
|
|
99
|
+
y=predict_df.values.flatten(),
|
|
100
|
+
mode='markers',
|
|
101
|
+
name='Data Points',
|
|
102
|
+
marker=dict(color=SERIES_COLORS[0], size=5, opacity=0.7),
|
|
103
|
+
))
|
|
98
104
|
|
|
99
105
|
min_value = min(ref_df.values.min(), predict_df.values.min())
|
|
100
106
|
max_value = max(ref_df.values.max(), predict_df.values.max())
|
|
101
|
-
fig.add_trace(go.Scatter(
|
|
102
|
-
|
|
107
|
+
fig.add_trace(go.Scatter(
|
|
108
|
+
x=[min_value, max_value],
|
|
109
|
+
y=[min_value, max_value],
|
|
110
|
+
mode='lines',
|
|
111
|
+
line=dict(color=TEXT_MUTED, dash='dash'),
|
|
112
|
+
showlegend=False,
|
|
113
|
+
))
|
|
103
114
|
|
|
104
115
|
fig.add_annotation(
|
|
105
116
|
x=min_value,
|
|
106
117
|
y=max_value,
|
|
107
|
-
text=f'R
|
|
118
|
+
text=f'R\u00b2 = {r2:.4f}',
|
|
108
119
|
showarrow=False,
|
|
109
|
-
font=dict(color=
|
|
110
|
-
bgcolor='
|
|
111
|
-
bordercolor='
|
|
120
|
+
font=dict(color=WHITE, size=12),
|
|
121
|
+
bgcolor='#184980',
|
|
122
|
+
bordercolor='rgba(255,255,255,0.2)',
|
|
112
123
|
borderwidth=1,
|
|
113
124
|
borderpad=4,
|
|
114
|
-
opacity=0.
|
|
125
|
+
opacity=0.9,
|
|
115
126
|
)
|
|
116
127
|
|
|
117
128
|
fig.update_layout(
|
|
@@ -119,6 +130,8 @@ def r_squared(context: wizata_dsapi.Context):
|
|
|
119
130
|
yaxis=dict(title='Predicted')
|
|
120
131
|
)
|
|
121
132
|
|
|
133
|
+
apply_theme(fig)
|
|
134
|
+
|
|
122
135
|
context.set_plot(
|
|
123
136
|
figure=fig,
|
|
124
137
|
name="r_squared"
|
|
@@ -126,18 +139,22 @@ def r_squared(context: wizata_dsapi.Context):
|
|
|
126
139
|
|
|
127
140
|
|
|
128
141
|
def ts_chart(context: wizata_dsapi.Context):
|
|
129
|
-
"""
|
|
130
|
-
ts_chart
|
|
131
|
-
:param context:
|
|
132
|
-
:return:
|
|
133
|
-
"""
|
|
142
|
+
"""Plot all dataframe columns as time-series lines over the index."""
|
|
134
143
|
df = context.dataframe
|
|
135
144
|
traces = []
|
|
136
|
-
for column in df.columns:
|
|
137
|
-
trace = go.Scatter(
|
|
145
|
+
for i, column in enumerate(df.columns):
|
|
146
|
+
trace = go.Scatter(
|
|
147
|
+
x=df.index,
|
|
148
|
+
y=df[column],
|
|
149
|
+
mode='lines',
|
|
150
|
+
name=column,
|
|
151
|
+
line=dict(color=SERIES_COLORS[i % len(SERIES_COLORS)]),
|
|
152
|
+
)
|
|
138
153
|
traces.append(trace)
|
|
139
154
|
|
|
140
155
|
fig = go.Figure(traces)
|
|
156
|
+
apply_theme(fig)
|
|
157
|
+
|
|
141
158
|
context.set_plot(
|
|
142
159
|
figure=fig,
|
|
143
160
|
name="ts_chart"
|
|
@@ -145,19 +162,23 @@ def ts_chart(context: wizata_dsapi.Context):
|
|
|
145
162
|
|
|
146
163
|
|
|
147
164
|
def anomalies_chart(context: wizata_dsapi.Context):
|
|
148
|
-
"""
|
|
149
|
-
anomalies_chart
|
|
150
|
-
:param context:
|
|
151
|
-
:return:
|
|
152
|
-
"""
|
|
165
|
+
"""Plot time-series signals with detected anomaly regions highlighted in red."""
|
|
153
166
|
df = context.dataframe
|
|
154
167
|
|
|
155
168
|
# Add Signals
|
|
156
169
|
traces = []
|
|
170
|
+
color_idx = 0
|
|
157
171
|
for column in df.columns:
|
|
158
172
|
if column != "anomalies_type":
|
|
159
|
-
trace = go.Scatter(
|
|
173
|
+
trace = go.Scatter(
|
|
174
|
+
x=df.index,
|
|
175
|
+
y=df[column],
|
|
176
|
+
mode='lines',
|
|
177
|
+
name=column,
|
|
178
|
+
line=dict(color=SERIES_COLORS[color_idx % len(SERIES_COLORS)]),
|
|
179
|
+
)
|
|
160
180
|
traces.append(trace)
|
|
181
|
+
color_idx += 1
|
|
161
182
|
fig = go.Figure(traces)
|
|
162
183
|
|
|
163
184
|
# Add Anomalies as Highlighted
|
|
@@ -173,7 +194,9 @@ def anomalies_chart(context: wizata_dsapi.Context):
|
|
|
173
194
|
anomalies_occurrences.columns = ['from', 'to', 'anomaly_group']
|
|
174
195
|
for i in anomalies_occurrences.index:
|
|
175
196
|
fig.add_vrect(x0=anomalies_occurrences['from'][i], x1=anomalies_occurrences['to'][i], line_width=0,
|
|
176
|
-
fillcolor=
|
|
197
|
+
fillcolor=ANOMALY_COLOR, opacity=1)
|
|
198
|
+
|
|
199
|
+
apply_theme(fig)
|
|
177
200
|
|
|
178
201
|
context.set_plot(
|
|
179
202
|
figure=fig,
|
|
@@ -182,19 +205,66 @@ def anomalies_chart(context: wizata_dsapi.Context):
|
|
|
182
205
|
|
|
183
206
|
|
|
184
207
|
def parallel_coordinates(context: wizata_dsapi.Context):
|
|
185
|
-
"""
|
|
186
|
-
parallel_coordinates
|
|
187
|
-
:param context:
|
|
188
|
-
:return:
|
|
189
|
-
"""
|
|
208
|
+
"""Plot parallel coordinates colored by anomaly type for multi-dimensional analysis."""
|
|
190
209
|
df = context.dataframe
|
|
191
210
|
|
|
192
211
|
fig = px.parallel_coordinates(df,
|
|
193
212
|
color='anomalies_type',
|
|
194
213
|
dimensions=df,
|
|
195
214
|
color_continuous_scale=px.colors.diverging.Portland)
|
|
215
|
+
apply_theme(fig)
|
|
216
|
+
|
|
196
217
|
context.set_plot(
|
|
197
218
|
figure=fig,
|
|
198
219
|
name="parallel_coordinates"
|
|
199
220
|
)
|
|
200
221
|
|
|
222
|
+
|
|
223
|
+
def data_table(context: wizata_dsapi.Context):
|
|
224
|
+
"""Render the dataframe as a styled table with Wizata theme colors."""
|
|
225
|
+
df = context.dataframe.copy()
|
|
226
|
+
|
|
227
|
+
# Format the index as a column if it has a name or is a DatetimeIndex
|
|
228
|
+
if isinstance(df.index, pd.DatetimeIndex):
|
|
229
|
+
df.insert(0, df.index.name or "Timestamp", df.index.strftime("%Y-%m-%d %H:%M:%S"))
|
|
230
|
+
df = df.reset_index(drop=True)
|
|
231
|
+
elif df.index.name is not None:
|
|
232
|
+
df = df.reset_index()
|
|
233
|
+
|
|
234
|
+
# Round numeric columns
|
|
235
|
+
precision = int(context.properties.get("precision", 4)) if "precision" in context.properties else 4
|
|
236
|
+
for col in df.select_dtypes(include="number").columns:
|
|
237
|
+
df[col] = df[col].round(precision)
|
|
238
|
+
|
|
239
|
+
# Build alternating row colors
|
|
240
|
+
n_rows = len(df)
|
|
241
|
+
cell_bg = [TABLE_CELL_BG[i % 2] for i in range(n_rows)]
|
|
242
|
+
|
|
243
|
+
fig = go.Figure(data=[go.Table(
|
|
244
|
+
header=dict(
|
|
245
|
+
values=[f"<b>{c}</b>" for c in df.columns],
|
|
246
|
+
fill_color=TABLE_HEADER_BG,
|
|
247
|
+
font=dict(family=FONT_FAMILY, size=FONT_SIZE, color=TABLE_HEADER_TEXT),
|
|
248
|
+
align="left",
|
|
249
|
+
line_color=TABLE_LINE_COLOR,
|
|
250
|
+
height=32,
|
|
251
|
+
),
|
|
252
|
+
cells=dict(
|
|
253
|
+
values=[df[c].tolist() for c in df.columns],
|
|
254
|
+
fill_color=[cell_bg],
|
|
255
|
+
font=dict(family=FONT_FAMILY, size=FONT_SIZE, color=TABLE_CELL_TEXT),
|
|
256
|
+
align="left",
|
|
257
|
+
line_color=TABLE_LINE_COLOR,
|
|
258
|
+
height=28,
|
|
259
|
+
),
|
|
260
|
+
)])
|
|
261
|
+
|
|
262
|
+
fig.update_layout(
|
|
263
|
+
margin=dict(l=0, r=0, t=0, b=0),
|
|
264
|
+
)
|
|
265
|
+
apply_theme(fig)
|
|
266
|
+
|
|
267
|
+
context.set_plot(
|
|
268
|
+
figure=fig,
|
|
269
|
+
name="data_table"
|
|
270
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Wizata chart theme for Plotly figures.
|
|
3
|
+
|
|
4
|
+
Provides consistent colors, fonts, and layout defaults
|
|
5
|
+
designed for rendering on the Wizata platform dark background.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# -- Brand --------------------------------------------------------------------
|
|
9
|
+
MAIN_COLOR = "#E64600"
|
|
10
|
+
|
|
11
|
+
# Blue shades
|
|
12
|
+
SECONDARY = "#184980"
|
|
13
|
+
TERTIARY = "#031E37"
|
|
14
|
+
FOURTH = "#062B56"
|
|
15
|
+
|
|
16
|
+
WHITE = "#FFFFFF"
|
|
17
|
+
TEXT_MUTED = "#B8C4D0"
|
|
18
|
+
BACKGROUND = "#01101D"
|
|
19
|
+
|
|
20
|
+
# -- Status -------------------------------------------------------------------
|
|
21
|
+
STATUS_SUCCESS = "#7CFFB2"
|
|
22
|
+
STATUS_WARNING = "#FDDD60"
|
|
23
|
+
STATUS_ERROR = "#FF6E76"
|
|
24
|
+
STATUS_INFO = "#4992FF"
|
|
25
|
+
STATUS_ABORTED = "#9B9BA2"
|
|
26
|
+
|
|
27
|
+
# -- Data series (ordered cycle) ----------------------------------------------
|
|
28
|
+
SERIES_COLORS = [
|
|
29
|
+
"#7CFFB2",
|
|
30
|
+
"#9E7CFF",
|
|
31
|
+
"#FDDD60",
|
|
32
|
+
"#4992FF",
|
|
33
|
+
"#6FE7F7",
|
|
34
|
+
"#E992FF",
|
|
35
|
+
"#FF6E76",
|
|
36
|
+
"#FFA686",
|
|
37
|
+
"#D1E2EE",
|
|
38
|
+
"#FFF0B5",
|
|
39
|
+
"#91C778",
|
|
40
|
+
"#7B7D88",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
# -- Semantic -----------------------------------------------------------------
|
|
44
|
+
ANOMALY_COLOR = "rgba(255,110,118,0.25)" # STATUS_ERROR at 25%
|
|
45
|
+
POSITIVE_COLOR = STATUS_SUCCESS
|
|
46
|
+
NEGATIVE_COLOR = STATUS_ERROR
|
|
47
|
+
NEUTRAL_COLOR = STATUS_INFO
|
|
48
|
+
|
|
49
|
+
# -- Table --------------------------------------------------------------------
|
|
50
|
+
TABLE_HEADER_BG = SECONDARY
|
|
51
|
+
TABLE_HEADER_TEXT = WHITE
|
|
52
|
+
TABLE_CELL_BG = [TERTIARY, FOURTH]
|
|
53
|
+
TABLE_CELL_TEXT = TEXT_MUTED
|
|
54
|
+
TABLE_LINE_COLOR = "rgba(255,255,255,0.12)"
|
|
55
|
+
|
|
56
|
+
# -- Font ---------------------------------------------------------------------
|
|
57
|
+
FONT_FAMILY = "Inter, -apple-system, BlinkMacSystemFont, sans-serif"
|
|
58
|
+
FONT_SIZE = 12
|
|
59
|
+
TITLE_SIZE = 14
|
|
60
|
+
|
|
61
|
+
# -- Layout defaults ----------------------------------------------------------
|
|
62
|
+
TRANSPARENT = "rgba(0,0,0,0)"
|
|
63
|
+
|
|
64
|
+
LAYOUT_DEFAULTS = dict(
|
|
65
|
+
paper_bgcolor=TRANSPARENT,
|
|
66
|
+
plot_bgcolor=TRANSPARENT,
|
|
67
|
+
font=dict(
|
|
68
|
+
family=FONT_FAMILY,
|
|
69
|
+
size=FONT_SIZE,
|
|
70
|
+
color=TEXT_MUTED,
|
|
71
|
+
),
|
|
72
|
+
title=dict(
|
|
73
|
+
font=dict(size=TITLE_SIZE, color=WHITE),
|
|
74
|
+
),
|
|
75
|
+
legend=dict(
|
|
76
|
+
bgcolor=TRANSPARENT,
|
|
77
|
+
font=dict(color=TEXT_MUTED),
|
|
78
|
+
),
|
|
79
|
+
xaxis=dict(
|
|
80
|
+
gridcolor="rgba(255,255,255,0.08)",
|
|
81
|
+
linecolor="rgba(255,255,255,0.2)",
|
|
82
|
+
zerolinecolor="rgba(255,255,255,0.08)",
|
|
83
|
+
tickfont=dict(color=TEXT_MUTED),
|
|
84
|
+
title_font=dict(color=TEXT_MUTED),
|
|
85
|
+
),
|
|
86
|
+
yaxis=dict(
|
|
87
|
+
gridcolor="rgba(255,255,255,0.08)",
|
|
88
|
+
linecolor="rgba(255,255,255,0.2)",
|
|
89
|
+
zerolinecolor="rgba(255,255,255,0.08)",
|
|
90
|
+
tickfont=dict(color=TEXT_MUTED),
|
|
91
|
+
title_font=dict(color=TEXT_MUTED),
|
|
92
|
+
),
|
|
93
|
+
colorway=SERIES_COLORS,
|
|
94
|
+
margin=dict(l=50, r=20, t=40, b=40),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def apply_theme(fig):
|
|
99
|
+
"""
|
|
100
|
+
Apply Wizata theme to an existing Plotly figure.
|
|
101
|
+
Returns the figure for chaining.
|
|
102
|
+
"""
|
|
103
|
+
fig.update_layout(**LAYOUT_DEFAULTS)
|
|
104
|
+
return fig
|
|
@@ -10,11 +10,7 @@ import sklearn.ensemble
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def filter_df(context: wizata_dsapi.Context):
|
|
13
|
-
"""
|
|
14
|
-
filter a dataframe
|
|
15
|
-
:param context:
|
|
16
|
-
:return:
|
|
17
|
-
"""
|
|
13
|
+
"""Filter dataframe rows using pandas query strings from the 'filters' property list."""
|
|
18
14
|
|
|
19
15
|
if "filters" not in context.properties or not isinstance(context.properties['filters'], list):
|
|
20
16
|
raise ValueError(f'there is no list *filters* in properties - please set them on context or config')
|
|
@@ -32,11 +28,7 @@ def filter_df(context: wizata_dsapi.Context):
|
|
|
32
28
|
|
|
33
29
|
|
|
34
30
|
def clustering(context: wizata_dsapi.Context):
|
|
35
|
-
"""
|
|
36
|
-
clustering
|
|
37
|
-
:param context:
|
|
38
|
-
:return:
|
|
39
|
-
"""
|
|
31
|
+
"""K-means clustering with automatic cluster count selection via silhouette score."""
|
|
40
32
|
df = context.dataframe.copy()
|
|
41
33
|
scaler = sklearn.preprocessing.StandardScaler()
|
|
42
34
|
df_clustering_scaler = scaler.fit_transform(df)
|
|
@@ -68,11 +60,7 @@ def clustering(context: wizata_dsapi.Context):
|
|
|
68
60
|
|
|
69
61
|
|
|
70
62
|
def merge(context: wizata_dsapi.Context):
|
|
71
|
-
"""
|
|
72
|
-
merge
|
|
73
|
-
:param context:
|
|
74
|
-
:return:
|
|
75
|
-
"""
|
|
63
|
+
"""Merge multiple dataframes by index using outer join (configurable via 'how' property)."""
|
|
76
64
|
dataframes = context.current_dataframes()
|
|
77
65
|
if len(dataframes) <= 1:
|
|
78
66
|
raise ValueError(f'there is not enough dataframes to concat')
|
|
@@ -91,11 +79,7 @@ def merge(context: wizata_dsapi.Context):
|
|
|
91
79
|
|
|
92
80
|
|
|
93
81
|
def fillna(context: wizata_dsapi.Context):
|
|
94
|
-
"""
|
|
95
|
-
fillna
|
|
96
|
-
:param context:
|
|
97
|
-
:return:
|
|
98
|
-
"""
|
|
82
|
+
"""Fill missing values per column using the 'fillna' property dict mapping column names to fill values."""
|
|
99
83
|
df = context.dataframe
|
|
100
84
|
|
|
101
85
|
if "fillna" not in context.properties:
|
|
@@ -108,11 +92,7 @@ def fillna(context: wizata_dsapi.Context):
|
|
|
108
92
|
|
|
109
93
|
|
|
110
94
|
def target_feat_to_binary(context: wizata_dsapi.Context):
|
|
111
|
-
"""
|
|
112
|
-
target_feat_to_binary
|
|
113
|
-
:param context:
|
|
114
|
-
:return:
|
|
115
|
-
"""
|
|
95
|
+
"""Convert a target feature column to binary (0/1) using a threshold operator (lt, lte, gt, gte)."""
|
|
116
96
|
df = context.dataframe
|
|
117
97
|
|
|
118
98
|
if "target_feat" not in context.properties:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.0.0.dev22"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .common import ts_chart, confusion_matrix, r_squared, anomalies_chart, parallel_coordinates
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.0.0.dev21"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{wizata_dsapi-2.0.0.dev21 → wizata_dsapi-2.0.0.dev22}/wizata_dsapi.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|