0
# Visual Programming Widgets
1
2
Orange3 provides a comprehensive widget-based graphical interface for building data analysis workflows through drag-and-drop operations. Widgets are organized into categories and can be connected to create complex data processing pipelines.
3
4
## Capabilities
5
6
### Widget Categories
7
8
Orange3 widgets are organized into functional categories for different aspects of data analysis.
9
10
```python { .api }
11
# Widget categories available through Orange Canvas:
12
# Orange.widgets.data - Data input/output and manipulation
13
# Orange.widgets.visualize - Data visualization
14
# Orange.widgets.model - Machine learning models
15
# Orange.widgets.evaluate - Model evaluation
16
# Orange.widgets.unsupervised - Clustering and unsupervised learning
17
```
18
19
### Data Widgets
20
21
Widgets for data input, output, and basic manipulation.
22
23
```python { .api }
24
# Key data widgets (accessed through Orange Canvas GUI):
25
# - File: Load data from various file formats
26
# - Save Data: Export data to files
27
# - Data Table: View and edit data in tabular format
28
# - Select Columns: Choose which attributes to use
29
# - Select Rows: Filter data based on conditions
30
# - Data Sampler: Create random samples of data
31
# - Transpose: Transpose data matrix
32
# - Merge Data: Combine multiple datasets
33
# - Concatenate: Stack datasets vertically
34
# - Python Script: Custom Python code for data processing
35
```
36
37
### Visualization Widgets
38
39
Widgets for creating various types of data visualizations.
40
41
```python { .api }
42
# Key visualization widgets:
43
# - Scatter Plot: 2D scatter plots with various encodings
44
# - Box Plot: Box plots for continuous variables
45
# - Histogram: Distribution histograms
46
# - Bar Plot: Bar charts for categorical data
47
# - Line Plot: Time series and line charts
48
# - Heat Map: Correlation and confusion matrices
49
# - Mosaic Display: Categorical variable relationships
50
# - Silhouette Plot: Clustering quality visualization
51
# - Tree Viewer: Decision tree visualization
52
# - CN2 Rule Viewer: Rule visualization
53
# - Nomogram: Linear model visualization
54
# - Linear Projection: 2D projections (PCA, LDA, etc.)
55
# - FreeViz: Interactive projection optimization
56
# - RadViz: Radial visualization
57
# - Distributions: Variable distribution plots
58
# - Statistics: Descriptive statistics tables
59
```
60
61
### Model Widgets
62
63
Widgets for machine learning algorithms and model building.
64
65
```python { .api }
66
# Classification widgets:
67
# - Tree: Decision tree classifier
68
# - Random Forest: Random forest classifier
69
# - SVM: Support vector machine
70
# - Naive Bayes: Naive Bayes classifier
71
# - Logistic Regression: Logistic regression
72
# - k-NN: k-nearest neighbors
73
# - Neural Network: Multi-layer perceptron
74
# - AdaBoost: AdaBoost ensemble
75
# - CN2 Rule Induction: Rule learning
76
77
# Regression widgets:
78
# - Linear Regression: Linear regression models
79
# - Tree: Decision tree regressor
80
# - Random Forest: Random forest regressor
81
# - SVM: Support vector regression
82
# - Neural Network: Neural network regression
83
# - Mean: Mean baseline regressor
84
85
# Model utilities:
86
# - Load Model: Load saved models
87
# - Save Model: Save trained models
88
# - Predictions: Apply models to make predictions
89
```
90
91
### Evaluation Widgets
92
93
Widgets for model evaluation and performance assessment.
94
95
```python { .api }
96
# Evaluation widgets:
97
# - Test and Score: Cross-validation and performance metrics
98
# - Predictions: Model predictions comparison
99
# - Confusion Matrix: Classification performance matrix
100
# - ROC Analysis: ROC curves and AUC scores
101
# - Lift Curve: Lift analysis for binary classification
102
# - Calibration Plot: Probability calibration assessment
103
# - Learning Curve: Performance vs. training size
104
# - Feature Importance: Feature importance scores
105
```
106
107
### Unsupervised Learning Widgets
108
109
Widgets for clustering and other unsupervised learning tasks.
110
111
```python { .api }
112
# Clustering widgets:
113
# - k-Means: k-means clustering
114
# - Hierarchical Clustering: Dendrogram-based clustering
115
# - DBSCAN: Density-based clustering
116
# - Louvain Clustering: Community detection
117
118
# Dimensionality reduction widgets:
119
# - PCA: Principal component analysis
120
# - Correspondence Analysis: Correspondence analysis
121
# - MDS: Multidimensional scaling
122
# - t-SNE: t-distributed stochastic neighbor embedding
123
# - Linear Projection: Various linear projections
124
125
# Association rules:
126
# - Associate: Frequent itemset mining
127
```
128
129
### Data Preprocessing Widgets
130
131
Widgets for data transformation and preparation.
132
133
```python { .api }
134
# Preprocessing widgets:
135
# - Preprocess: Multiple preprocessing options
136
# - Discretize: Convert continuous to discrete
137
# - Continuize: Convert discrete to continuous
138
# - Normalize: Feature scaling and normalization
139
# - Randomize: Shuffle data randomly
140
# - Feature Constructor: Create new features
141
# - Select Attributes: Feature selection methods
142
# - Rank: Rank features by importance
143
# - Impute: Handle missing values
144
```
145
146
### Widget Infrastructure
147
148
Core classes and utilities for widget development.
149
150
```python { .api }
151
class OWWidget:
152
"""Base class for all Orange widgets."""
153
name = ""
154
description = ""
155
category = ""
156
icon = ""
157
158
def __init__(self): ...
159
160
def set_data(self, data):
161
"""Set input data for the widget."""
162
163
def commit(self):
164
"""Process data and send outputs."""
165
166
class Input:
167
"""Widget input definition."""
168
def __init__(self, name, type, handler, **kwargs): ...
169
170
class Output:
171
"""Widget output definition."""
172
def __init__(self, name, type, **kwargs): ...
173
174
def widget_discovery():
175
"""Entry point for widget discovery system."""
176
```
177
178
### Widget Settings Management
179
180
Persistent storage for widget configurations.
181
182
```python { .api }
183
# Settings are managed automatically for widgets
184
# Key setting types:
185
# - Setting: Basic persistent setting
186
# - ContextSetting: Setting that depends on data context
187
# - DomainContextHandler: Handler for domain-dependent settings
188
# - PerfectDomainContextHandler: Handler for exact domain matches
189
```
190
191
### Usage Examples
192
193
```python
194
# Orange3 widgets are primarily used through the Orange Canvas GUI
195
# However, widgets can be instantiated programmatically:
196
197
# Example of using a widget programmatically (not typical usage):
198
from Orange.widgets.data.owfile import OWFile
199
from Orange.widgets.model.owtree import OWTreeLearner
200
201
# Create file widget (normally done through GUI)
202
file_widget = OWFile()
203
204
# Load data (normally done by connecting widgets)
205
# file_widget.load_data("iris.tab")
206
207
# Create tree learner widget
208
tree_widget = OWTreeLearner()
209
210
# Set parameters (normally done through widget interface)
211
# tree_widget.max_depth = 5
212
213
# In the Orange Canvas GUI workflow:
214
# 1. Drag widgets from toolbox to canvas
215
# 2. Connect widgets by drawing lines between compatible inputs/outputs
216
# 3. Configure widget parameters through their interfaces
217
# 4. Data flows automatically through connections
218
# 5. Results update in real-time as parameters change
219
220
# Typical widget workflow in Orange Canvas:
221
# File → Data Table → [Preprocess] → [Feature Selection] →
222
# [Split Data] → [Learner] → [Predictions] → [Test & Score]
223
224
# Widget connections example:
225
# - File.Data → Data Table.Data (view loaded data)
226
# - File.Data → Tree.Data (train decision tree)
227
# - Tree.Model → Predictions.Model (make predictions)
228
# - File.Data → Predictions.Data (data for predictions)
229
# - Predictions.Predictions → Confusion Matrix.Data (evaluate results)
230
231
# Custom widget example structure:
232
"""
233
from Orange.widgets import widget, gui
234
from Orange.widgets.settings import Setting
235
236
class MyCustomWidget(widget.OWWidget):
237
name = "My Custom Widget"
238
description = "Custom data processing widget"
239
category = "Custom"
240
241
# Widget inputs/outputs
242
class Inputs:
243
data = Input("Data", Table)
244
245
class Outputs:
246
processed_data = Output("Processed Data", Table)
247
248
# Settings
249
parameter = Setting(default_value=1.0)
250
251
def __init__(self):
252
super().__init__()
253
254
# GUI elements
255
box = gui.widgetBox(self.controlArea, "Parameters")
256
gui.doubleSpin(box, self, "parameter", 0, 100, step=0.1,
257
label="Parameter:", callback=self.commit)
258
259
@Inputs.data
260
def set_data(self, data):
261
self.data = data
262
self.commit()
263
264
def commit(self):
265
if self.data is not None:
266
# Process data based on parameter
267
processed = self.process_data(self.data)
268
self.Outputs.processed_data.send(processed)
269
270
def process_data(self, data):
271
# Custom processing logic
272
return data
273
"""
274
275
print("Orange3 widgets are best used through the Orange Canvas GUI")
276
print("Launch Orange Canvas with: python -m Orange.canvas")
277
print("Widget categories: Data, Visualize, Model, Evaluate, Unsupervised")
278
```