Orange, a component-based data mining framework.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Orange3 provides comprehensive supervised learning algorithms for continuous prediction tasks. All regressors follow the same pattern as classifiers: create a learner, then call it with training data to produce a trained model.
Linear regression algorithms with various regularization techniques.
class LinearRegressionLearner:
"""
Ordinary least squares linear regression.
Args:
preprocessors: List of preprocessing steps
"""
def __init__(self, preprocessors=None): ...
def __call__(self, data):
"""Train and return linear regression model."""
class RidgeRegressionLearner:
"""
Ridge regression with L2 regularization.
Args:
alpha: Regularization strength
fit_intercept: Whether to fit intercept
normalize: Whether to normalize features
"""
def __init__(self, alpha=1.0, fit_intercept=True, normalize=False): ...
def __call__(self, data):
"""Train and return ridge regression model."""
class LassoRegressionLearner:
"""
Lasso regression with L1 regularization.
Args:
alpha: Regularization strength
fit_intercept: Whether to fit intercept
normalize: Whether to normalize features
max_iter: Maximum iterations
"""
def __init__(self, alpha=1.0, fit_intercept=True, normalize=False, max_iter=1000): ...
def __call__(self, data):
"""Train and return lasso regression model."""
class ElasticNetLearner:
"""
Elastic net regression combining L1 and L2 penalties.
Args:
alpha: Regularization strength
l1_ratio: Mixing parameter between L1 and L2
fit_intercept: Whether to fit intercept
normalize: Whether to normalize features
"""
def __init__(self, alpha=1.0, l1_ratio=0.5, fit_intercept=True, normalize=False): ...
def __call__(self, data):
"""Train and return elastic net model."""Decision tree algorithms for regression tasks.
class TreeLearner:
"""
Decision tree regressor.
Args:
criterion: Split criterion ('mse', 'friedman_mse', 'mae')
max_depth: Maximum tree depth
min_samples_split: Minimum samples required to split
min_samples_leaf: Minimum samples in leaf nodes
"""
def __init__(self, criterion='mse', max_depth=None,
min_samples_split=2, min_samples_leaf=1): ...
def __call__(self, data):
"""Train and return decision tree regression model."""
class SklTreeRegressionLearner:
"""Scikit-learn decision tree regressor wrapper."""
def __init__(self, criterion='mse', max_depth=None): ...
def __call__(self, data):
"""Train and return sklearn tree regression model."""Ensemble algorithms combining multiple regressors.
class RandomForestRegressionLearner:
"""
Random Forest regressor.
Args:
n_estimators: Number of trees
max_depth: Maximum tree depth
max_features: Number of features per tree
bootstrap: Use bootstrap sampling
random_state: Random seed
"""
def __init__(self, n_estimators=10, max_depth=None,
max_features='auto', bootstrap=True, random_state=None): ...
def __call__(self, data):
"""Train and return random forest regression model."""k-Nearest Neighbors for regression.
class KNNRegressionLearner:
"""
k-Nearest Neighbors regressor.
Args:
n_neighbors: Number of neighbors
weights: Weight function ('uniform', 'distance')
metric: Distance metric
"""
def __init__(self, n_neighbors=5, weights='uniform', metric='euclidean'): ...
def __call__(self, data):
"""Train and return k-NN regression model."""Multi-layer perceptron for regression tasks.
class NNRegressionLearner:
"""
Neural network regressor.
Args:
hidden_layer_sizes: Tuple of hidden layer sizes
activation: Activation function
solver: Optimization solver
learning_rate_init: Initial learning rate
max_iter: Maximum iterations
"""
def __init__(self, hidden_layer_sizes=(100,), activation='relu',
solver='adam', learning_rate_init=0.001, max_iter=200): ...
def __call__(self, data):
"""Train and return neural network regression model."""Stochastic gradient descent for regression.
class SGDRegressionLearner:
"""
Stochastic Gradient Descent regressor.
Args:
loss: Loss function ('squared_loss', 'huber', 'epsilon_insensitive')
penalty: Regularization ('l1', 'l2', 'elasticnet')
alpha: Regularization strength
learning_rate: Learning rate schedule
"""
def __init__(self, loss='squared_loss', penalty='l2', alpha=0.0001,
learning_rate='invscaling'): ...
def __call__(self, data):
"""Train and return SGD regression model."""PLS regression for high-dimensional data.
class PLSRegressionLearner:
"""
Partial Least Squares regression.
Args:
n_components: Number of components
scale: Whether to scale data
max_iter: Maximum iterations
"""
def __init__(self, n_components=2, scale=True, max_iter=500): ...
def __call__(self, data):
"""Train and return PLS regression model."""Simple baseline algorithms for comparison.
class MeanLearner:
"""
Always predicts the mean target value.
"""
def __call__(self, data):
"""Train and return mean prediction model."""Advanced ensemble methods (requires additional dependencies).
class XGBRegressor:
"""
XGBoost regressor (requires xgboost package).
Args:
n_estimators: Number of boosting rounds
max_depth: Maximum tree depth
learning_rate: Boosting learning rate
subsample: Subsample ratio
"""
def __init__(self, n_estimators=100, max_depth=6, learning_rate=0.3, subsample=1): ...
def __call__(self, data):
"""Train and return XGBoost regression model."""
class XGBRFRegressor:
"""XGBoost Random Forest regressor."""
def __init__(self, n_estimators=100, max_depth=6, learning_rate=1, subsample=0.8): ...
def __call__(self, data):
"""Train and return XGBoost RF regression model."""# Basic regression workflow
from Orange.data import Table
from Orange.regression import LinearRegressionLearner, TreeLearner, RandomForestRegressionLearner
from Orange.evaluation import CrossValidation, MSE, RMSE, MAE, R2
# Load regression dataset
data = Table("housing") # or any regression dataset
# Create learners
learners = [
LinearRegressionLearner(),
TreeLearner(max_depth=10),
RandomForestRegressionLearner(n_estimators=50)
]
# Cross-validation evaluation
results = CrossValidation(data, learners, k=10)
# Calculate regression metrics
mse_scores = MSE(results)
rmse_scores = RMSE(results)
mae_scores = MAE(results)
r2_scores = R2(results)
print("Regression Results:")
for i, learner in enumerate(learners):
print(f"{learner.__class__.__name__}:")
print(f" MSE: {mse_scores[i]:.3f}")
print(f" RMSE: {rmse_scores[i]:.3f}")
print(f" MAE: {mae_scores[i]:.3f}")
print(f" R²: {r2_scores[i]:.3f}")
# Train individual models
linear_model = LinearRegressionLearner()(data)
tree_model = TreeLearner(max_depth=5)(data)
# Make predictions
predictions_linear = linear_model(data[:10])
predictions_tree = tree_model(data[:10])
print(f"Linear predictions: {predictions_linear}")
print(f"Tree predictions: {predictions_tree}")
# Regularized linear models
from Orange.regression import RidgeRegressionLearner, LassoRegressionLearner, ElasticNetLearner
ridge = RidgeRegressionLearner(alpha=1.0)
lasso = LassoRegressionLearner(alpha=0.1)
elastic = ElasticNetLearner(alpha=0.1, l1_ratio=0.5)
ridge_model = ridge(data)
lasso_model = lasso(data)
elastic_model = elastic(data)
# Neural network regression
from Orange.regression import NNRegressionLearner
nn = NNRegressionLearner(hidden_layer_sizes=(100, 50), max_iter=500)
nn_model = nn(data)
# k-NN regression
from Orange.regression import KNNRegressionLearner
knn = KNNRegressionLearner(n_neighbors=5, weights='distance')
knn_model = knn(data)Install with Tessl CLI
npx tessl i tessl/pypi-orange3