Skip to content
ASLبشمهندس عسلAGENT / 101
HomeWorkToolsNotesAboutStart a project

OPEN FOR SELECTED COLLABORATIONS / 101

Bring the system that needs an answer.

Send a project briefEmail Ahmed

اسأل. تعلّم.

ابنِ. اختبر.

© 2026 AHMED IBRAHIM ASLبشمهندس عسلEGYPT / SYSTEMS ENGINEER / AGENT 101
Back to toolsAI / ML guided builder

Model Mission

From problem to Python, one decision at a time.

Active missionPredict a categoryClassification

Answer first

How can I generate a runnable edge-AI project instead of a code snippet?

Choose the task, data source, model direction, execution settings, and deployment target to generate a structured Python project instead of an isolated snippet. Trainable tasks include the relevant data and training workflow; inference-only missions generate prediction code without pretending retraining is required. Every path still needs validation, hardware checks, package review, and measured deployment performance.

Guided mode: safe defaults shown
Classification

What do you want the model to do?

Start with the prediction you need. The technical name stays visible so you learn the vocabulary while building.

Start hereCore ML
Build experienceApplied workflows
Advanced missionsVision and custom networks
Selected missionClassification

Tabular data

Try it with
fault typepass or failspecies
Step 1 of 9
Python mission outputclassification_pipeline.py

Install dependencies

pip install scikit-learn>=1.5,<2 pandas>=2.2,<3 numpy>=1.26,<3 joblib>=1.4,<2

Project summary

Logistic Regression for Breast Cancer Wisconsin, using train validation test and standard scaling.

Generated source

"""Configurable classification workflow generated by the AI Script Generator."""

import joblib
import numpy as np
import pandas as pd

from sklearn.compose import ColumnTransformer, make_column_selector
from sklearn.impute import SimpleImputer
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline as SklearnPipeline
from sklearn.preprocessing import OneHotEncoder
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import (
    accuracy_score, balanced_accuracy_score, classification_report,
    confusion_matrix, f1_score,
)

from sklearn.datasets import load_breast_cancer

dataset = load_breast_cancer(as_frame=True)
X = dataset.data.copy()
y = dataset.target.copy()
y.name = getattr(y, "name", None) or "target"

# Inspect the data before transforming it
print("\nFeature preview:")
print(X.head())
print("\nShapes:", X.shape, y.shape)
print("\nColumn types:")
print(X.dtypes)
print("\nFeature statistics:")
print(X.describe(include="all").T)
print("\nMissing values:")
print(pd.concat([X, y.rename("__target__")], axis=1).isna().sum())
print("\nTarget distribution:")
print(y.value_counts(dropna=False, normalize=True).sort_index())

# Split before fitting imputers, encoders, scalers, or samplers
RANDOM_SEED = 42
TEST_RATIO = 0.15
STRATIFY = True
VALIDATION_RATIO = 0.15
X_development, X_test, y_development, y_test = train_test_split(
    X, y, test_size=TEST_RATIO, random_state=RANDOM_SEED, stratify=y if STRATIFY else None,
)
validation_share = VALIDATION_RATIO / (1.0 - TEST_RATIO)
X_train, X_validation, y_train, y_validation = train_test_split(
    X_development, y_development, test_size=validation_share, random_state=RANDOM_SEED, stratify=y_development if STRATIFY else None,
)

# Learn preprocessing from training data only
numeric_pipeline = SklearnPipeline(steps=[
    ("imputer", SimpleImputer(strategy="median")),
    ("scaler", StandardScaler()),
])
categorical_pipeline = SklearnPipeline(steps=[
    ("imputer", SimpleImputer(strategy="most_frequent")),
    ("encoder", OneHotEncoder(handle_unknown="ignore", sparse_output=False)),
])
preprocessor = ColumnTransformer(
    transformers=[
        ("numeric", numeric_pipeline, make_column_selector(dtype_include=np.number)),
        ("categorical", categorical_pipeline, make_column_selector(dtype_exclude=np.number)),
    ],
    remainder="drop",
)

DECISION_THRESHOLD = None

def predict_labels(model, features):
    if DECISION_THRESHOLD is None:
        return model.predict(features)
    if len(model.classes_) != 2:
        raise ValueError("Decision thresholds require a binary classifier.")
    probabilities = model.predict_proba(features)[:, 1]
    return np.where(
        probabilities >= DECISION_THRESHOLD,
        model.classes_[1],
        model.classes_[0],
    )

def evaluate(model, features, target, split_name):
    predictions = predict_labels(model, features)
    print(f"\n{split_name} accuracy: {accuracy_score(target, predictions):.4f}")
    print(f"{split_name} balanced accuracy: {balanced_accuracy_score(target, predictions):.4f}")
    print(f"{split_name} weighted F1: {f1_score(target, predictions, average='weighted'):.4f}")
    print("\nClassification report:")
    print(classification_report(target, predictions, zero_division=0))
    print("Confusion matrix:")
    print(confusion_matrix(target, predictions))
    return predictions

# Keep preprocessing, optional balancing, and the model in one pipeline
pipeline_steps = [
    ("preprocess", preprocessor),
    ("model", LogisticRegression(C=1, max_iter=1000, class_weight=None)),
]
pipeline = SklearnPipeline(steps=pipeline_steps)

pipeline.fit(X_train, y_train)
evaluate(pipeline, X_validation, y_validation, "Validation")

# After configuration decisions, refit on train + validation
X_development = pd.concat([X_train, X_validation], axis=0)
y_development = pd.concat([y_train, y_validation], axis=0)
pipeline.fit(X_development, y_development)
test_predictions = evaluate(pipeline, X_test, y_test, "Final test")

MODEL_PATH = "classification_pipeline.joblib"
joblib.dump(pipeline, MODEL_PATH)
print(f"\nSaved fitted pipeline to {MODEL_PATH}")

# Run inference with the same fitted preprocessing
sample_prediction = predict_labels(pipeline, X_test.iloc[[0]])
print("Sample prediction:", sample_prediction[0])
print("Sample target:", y_test.iloc[0])

Design guide

Use the result with engineering context

Technical content reviewed September 15, 2026

When this tool is useful

  • Turning an AI experiment into a reproducible project structure
  • Comparing supported detection, segmentation, depth, classification, and sensor-learning paths

What the result includes

  • A runnable project structure with configuration and task-specific code
  • A guided record of data, model, evaluation or inference, and deployment choices

What the model does not guarantee

  • Generated code cannot guarantee dataset quality, model accuracy, fairness, latency, memory use, or compatibility with future package releases
  • Trainable paths still need labeling and split review; inference-only paths still need input, output, failure, and target-device validation

Worked approach

Prove the data and execution path first

Select the task and create the project. For a trainable mission, inspect labels and dataset splits before tuning. For an inference-only mission, verify inputs and outputs on representative samples. In both cases, establish a simple baseline and measure target-device constraints before adding complexity.

Common decisions

Questions engineers ask

Will every generated project train a model?

No. Some missions use pretrained models for inference without a training step. Trainable workflows still depend on valid files, labels, splits, package versions, available memory, and task assumptions.

Should I begin with the largest model available?

Begin with a small baseline that trains and runs on the target. Increase capacity only after error analysis shows that model size, rather than data or labeling, limits the result.

How do I know whether the model is ready for edge deployment?

Measure accuracy on unseen data, latency, memory, power, startup time, thermal behavior, and failures on the actual device. Desktop inference speed is not enough.

Related build evidence

Plant Care AI

Plant Care AI combines sensor inputs, leaf-image analysis, and a Flutter application. It demonstrates the system work required around an AI model.

See the project

Apply it to real hardware

Need an AI model connected to sensors or an application?

Share the task, available data, target hardware, latency limit, expected outputs, and how users will act on the result.

Discuss the system
Ahmed Ibrahim Asl
Behind the workbenchAhmed Ibrahim Asl

Embedded Systems & IoT R&D Engineer

From a calculation to a working prototype.

I build embedded firmware, connected hardware, and the interfaces that make them usable. Explore the projects behind this workbench, or tell me what you need to build.

See embedded & IoT projects ↗Discuss a project ↗Read engineering notes ↗