titanic-rf
sklearnv1.0.0Predicts 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 oms23model = 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 source1"""Titanic survival prediction with Random Forest."""23import numpy as np4from sklearn.ensemble import RandomForestClassifier5from sklearn.model_selection import cross_val_score67def train(ctx):8 hp = ctx.hyperparameters9 n_estimators = int(hp.get("n_estimators", 100))10 max_depth = hp.get("max_depth", None)1112 model = RandomForestClassifier(13 n_estimators=n_estimators,14 max_depth=max_depth,15 random_state=42,16 n_jobs=-1,17 )1819 # Load dataset or use synthetic data20 from sklearn.datasets import make_classification21 X, y = make_classification(n_samples=891, ...)
Details
- Author
- openmodelstudio
- License
- MIT
- Source
- 80 lines
- Version
- 1.0.0
Dependencies
scikit-learn>=1.3pandas>=2.0numpy>=1.24Hyperparameters
n_estimators100Number of trees in the forest
max_depthNoneMaximum tree depth (None = unlimited)
View on GitHub