Implementation:Online ml River Misc Skyline
| Knowledge Sources | |
|---|---|
| Domains | Online_Learning, Multi_Objective_Optimization, Pareto_Optimal |
| Last Updated | 2026-02-08 16:00 GMT |
Overview
Maintains a skyline (Pareto frontier) of non-dominated points in a data stream.
Description
Implements skyline computation using block nested loop algorithm. A point is in the skyline if no other point dominates it on all specified dimensions. Supports mixed optimization objectives (some minimized, others maximized). Automatically removes dominated points when better ones arrive. Handles identical observations correctly.
Usage
Use for multi-criteria optimization, finding Pareto-optimal solutions, or filtering to best alternatives based on multiple objectives. Essential for decision support systems, product recommendations, or any scenario with competing quality metrics.
Code Reference
Source Location
- Repository: Online_ml_River
- File: river/misc/skyline.py
Signature
class Skyline(collections.UserList[dict[base.typing.FeatureName, Any]], base.Base):
def __init__(
self,
minimize: list[base.typing.FeatureName] | None = None,
maximize: list[base.typing.FeatureName] | None = None,
):
...
def update(self, x: dict[base.typing.FeatureName, Any]) -> None:
...
Import
from river import misc
Usage Examples
import random
from river import misc
# Example: Finding best houses (maximize size, minimize price)
random.seed(42)
city_prices = {
'Bordeaux': 4045,
'Lyon': 4547,
'Toulouse': 3278
}
def random_house():
city = random.choice(['Bordeaux', 'Lyon', 'Toulouse'])
size = round(random.gauss(200, 50))
price = round(random.uniform(0.8, 1.2) * city_prices[city] * size)
return {'city': city, 'size': size, 'price': price}
skyline = misc.Skyline(minimize=['price'], maximize=['size'])
for _ in range(100):
house = random_house()
skyline.update(house)
print(f"Pareto-optimal houses: {len(skyline)}")
print(f"Best house: {skyline[0]}")
# Mario Kart example: Find best karts
karts_data = [
{'name': 'Red Fire', 'speed': 5, 'acceleration': 4, 'weight': 5},
{'name': 'Green Fire', 'speed': 7, 'acceleration': 3, 'weight': 4},
{'name': 'Goo-Goo Buggy', 'speed': 1, 'acceleration': 9, 'weight': 2},
]
kart_skyline = misc.Skyline(
maximize=['speed', 'acceleration'],
minimize=['weight']
)
for kart in karts_data:
kart_skyline.update(kart)
print(f"\nBest karts: {[k['name'] for k in kart_skyline]}")