titanic-rf

sklearnv1.0.0

Predicts Titanic passenger survival using a Random Forest classifier with engineered features. Demonstrates tabular binary classification with feature engineering (age groups, family size, title extraction), cross-validation evaluation, and feature importance analysis. Falls back to synthetic data when real Titanic data is unavailable.

Classificationtabularbinary-classificationrandom-forestbeginner

Install

1openmodelstudio install titanic-rf

SDK Usage

1import openmodelstudio as oms
2
3model = oms.use_model("titanic-rf")
4handle = oms.register_model("my-titanic-rf", model=model)
5job = oms.start_training(handle.model_id, wait=True)

Source Preview(80 lines)

View full source
1"""Titanic survival prediction with Random Forest."""
2
3import numpy as np
4from sklearn.ensemble import RandomForestClassifier
5from sklearn.model_selection import cross_val_score
6
7def train(ctx):
8 hp = ctx.hyperparameters
9 n_estimators = int(hp.get("n_estimators", 100))
10 max_depth = hp.get("max_depth", None)
11
12 model = RandomForestClassifier(
13 n_estimators=n_estimators,
14 max_depth=max_depth,
15 random_state=42,
16 n_jobs=-1,
17 )
18
19 # Load dataset or use synthetic data
20 from sklearn.datasets import make_classification
21 X, y = make_classification(n_samples=891, ...)

Details

Author
openmodelstudio
License
MIT
Source
80 lines
Version
1.0.0

Dependencies

scikit-learn>=1.3
pandas>=2.0
numpy>=1.24

Hyperparameters

n_estimators100

Number of trees in the forest

max_depthNone

Maximum tree depth (None = unlimited)

View on GitHub