bhylu.com

Advertisements

AI Classification Project

Package preprocessing and classification into one reproducible local experiment.

How it works

This local project predicts a synthetic review label from tray and station counts. The label comes from an author-defined toy rule so the data can be audited. It is not a recommendation about real people, food safety or staffing. A pipeline fits preprocessing on training rows and makes four held-out extreme-point predictions.

Run the code

This is a local Python example, not supported by Bhylu’s plain Python browser editor. In a separate virtual environment use Python 3.12.14 with the pinned requirements: NumPy 2.5.4 and scikit-learn 1.9.1. Run python -m pip install -r requirements-local.txt in that environment, then run this complete downloaded source. These are reviewed versions, not a newest-release promise. No external dataset, provider account, database or PHP setting is needed.

Download the complete classification-project.py

Example

classification-project.py

import numpy as np
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression

train = np.array([[1,1],[2,1],[3,1],[4,1],[6,1],[7,1],[1,2],[3,2],[5,2],[6,2],[8,2],[9,2]],dtype=float)
labels = (train[:,0] > 2*train[:,1]+2).astype(int)
model = make_pipeline(StandardScaler(),LogisticRegression(C=10,class_weight="balanced",random_state=2))
model.fit(train,labels)
test = np.array([[1,1],[9,1],[2,2],[10,2]],dtype=float)
predicted = model.predict(test)
print("held-out predictions:",predicted.tolist())
print("test rows:",len(test))
print("training rows:",len(train))

Expected result

held-out predictions: [0, 1, 0, 1]
test rows: 4
training rows: 12

The held-out rows include a tray count beyond the largest training count, which is reported as an extrapolation risk rather than silently claimed safe. A deployment wrapper would need validated ranges, calibrated operating thresholds, monitoring and a human review policy. The test only establishes behaviour on this named fixture.

Technical references