Orange Data Mining Documentation

repository·master·Indexed 26 days ago

https://github.com/biolab/orange3

A workflow-based data science toolbox for data mining and visualization. Includes guides on installation via Conda, pip, and winget, as well as API references for the Orange library, covering classification learners (Naive Bayes, TreeLearner), hierarchical clustering, and data domain management using Orange.data.Domain.

Tokens
22.2K
Snippets
45
Records
161
Agent score
90%

What's inside Orange Data Mining

  1. Understand Variable Descriptors in Orange.data

    master

    In Orange.data, every variable is associated with a descriptor that stores its name and properties. Descriptors are used for:

    • Converting values between textual formats (files) and internal representations.
    • Identifying variables (variables with the same descriptor are considered identical across datasets).
    • Converting values between domains (e.g., continuous to discrete) using pre-computed transformations.

    Descriptors are typically created automatically when loading data via Table.

  2. Understand distance computation logic in Orange 3

    master

    Orange 3 computes distances between data rows (instances) or columns (features) using methods that handle both numeric and discrete (nominal) features, including missing values.

    Key behaviors:

    • Normalization: Numeric features are normalized to ensure they are on the same scale as discrete features. This allows missing values to have a consistent effect across different feature types.
    • Missing Values: Orange uses the probability distribution of the feature (estimated from the data) to compute the expected difference for missing values.
    • Discrete Features: Two nominal values are treated as either the same (difference 0) or different (difference 1).
    • Column-wise Distance Limitation: Orange will report an error if you attempt to compute column-wise distances on data containing non-numeric features, as the difference between values of two distinct nominal features is not mathematically defined in this context.
  3. Understand the Orange data model

    master

    Orange organizes data using a hierarchical structure centered around Orange.data.Storage classes.

    • Orange.data.Table: The most common storage class. It stores data in two-dimensional numpy arrays where each row is a data instance.
    • Orange.data.Instance: Represents an individual row. When accessing a row from a Table (e.g., table[0]), it returns a Orange.data.RowInstance.
    • Orange.data.Domain: Every storage class and instance has an associated domain that describes the columns (variables).
    • Orange.data.Variable: Column descriptors. Common subclasses include:
      • Orange.data.ContinuousVariable (continuous values)
      • Orange.data.DiscreteVariable (discrete/categorical values)
      • Orange.data.StringVariable (string values)

    Data is categorized into three types:

    1. Attributes: Features or independent variables used in modeling.
    2. Class variables: Targets, outcomes, or dependent variables used in modeling.
    3. Meta attributes: Additional data (currently supporting strings, continuous, and numeric values).
  4. Implement a responsive GUI using ThreadExecutor

    master

    To prevent the GUI from freezing during long-running computations (like learner evaluations), offload tasks to a separate thread.

    Use Orange.widgets.utils.concurrent.ThreadExecutor for thread management. The recommended pattern involves:

    1. Defining a Task class to track the progress and state of the operation.
    2. Using a FutureWatcher to notify the GUI thread when the task completes via a slot (e.g., _task_finished).
    3. Implementing 'cooperative cancellation': the GUI thread sets a task.cancelled flag, and the worker thread periodically checks this flag to exit early by raising an exception.
    4. Communicating progress from the worker thread back to the GUI (e.g., via a percent value).
  5. Convert data between Domains

    master

    Domains facilitate the conversion of data instances between different descriptor sets (e.g., during preprocessing like discretization).

    Conversion Logic:

    1. Target attribute in source: The value is copied if descriptors match.
    2. Transformation: If the target descriptor defines a transformation function (e.g., a discretizer), the value is transformed.
    3. Missing values: If neither condition is met, the value is marked as missing.

    Anonymous Domains: If either the source or target domain has the anonymous flag set to True, they match based solely on the number and types of variables. In this case, data is copied without checking specific attribute descriptors.

  6. Access UI controls via attribute names

    master

    When building a user interface using Orange.widgets.gui functions, the resulting Qt widgets are automatically registered under the self.controls attribute using the name provided during creation. This allows you to manipulate the widget (e.g., disabling it) without storing a local reference to the Qt object.

    Example: gui.checkBox(box, self, "my_option", "Label") makes the checkbox accessible via self.controls.my_option.

  7. Use the single-line header format for CSV, TSV, and Excel files

    master

    A condensed single-line header format uses feature names prefixed by an optional string of flags followed by a hash (#) sign.

    Available Flags:

    • c: Class feature (target/dependent variable).
    • i: Ignore the feature.
    • m: Meta attribute (not used in learning).
    • C: Continuous (numeric) feature.
    • D: Discrete (categorical) feature.
    • T: Time/Date feature (ISO 8601 format).
    • S: String feature.

    If flags or names are omitted, Orange attempts to discern the types and flags automatically.

  8. Run a widget as a standalone script for debugging

    master
    To debug a widget or inspect its GUI without the Orange canvas, use Orange.widgets.utils.widgetpreview.WidgetPreview. The widget module must be executable as a script. You can pass data to the widget via the .run() method. If the widget requires multiple signals, pass them as keyword arguments where the keys match the signal handler names.
  9. Fit distance metrics to training data for normalization and missing values

    master

    Most distance metrics support a fit workflow. This allows you to compute statistics (like mean, variance, or medians) on a training dataset to normalize values and handle missing data consistently when evaluating new data.

    1. Initialize the distance object with parameters like normalize=True.
    2. Call .fit(training_data).
    3. Call the resulting object with the new data to compute distances.