Skip to main content

Predict house prices

Load a dataset, split it, and get predictions. The model figures out the pattern from your training rows — no configuration needed.
import pandas as pd
from sklearn.datasets import fetch_california_housing
from synthefy_nori import NoriRegressor

X, y = fetch_california_housing(return_X_y=True, as_frame=True)
df = X.copy()
df["price"] = y

target_col = "price"
feature_cols = [c for c in df.columns if c != target_col]

train = df.sample(frac=0.8, random_state=42)
test  = df.drop(train.index)

model = NoriRegressor()
model.fit(train[feature_cols].values, train[target_col].values)

predictions = model.predict(test[feature_cols].values)
test["predicted_price"] = predictions
print(test[["price", "predicted_price"]].head())
    price  predicted_price
9   2.611         2.721
11  2.418         2.735
13  1.913         1.794
16  1.525         2.057
24  1.326         1.782