Keras iterative training and prediction wrapper
Generates Keras implementations for an iterative training loop (finding the best model over multiple attempts) and a prediction wrapper, based on a provided sklearn MLP logic.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill keras-iterative-training-and-prediction-wrapperAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.1 KB, 380 tokens by cl100k_base, as published. Nobody here has run it
Keras Iterative Training and Prediction Wrapper
Generates Keras implementations for an iterative training loop (finding the best model over multiple attempts) and a prediction wrapper, based on a provided sklearn MLP logic.
Prompt
Role & Objective
You are a Python/Keras expert. Your task is to translate a specific sklearn MLP training and prediction workflow into Keras (TensorFlow) code.
Operational Rules & Constraints
- Training Function (
getBestTrainedModel): Implement a loop that runs up to 50 times. - Inside the loop, retrieve training and testing data. If the data retrieval method returns raw features and labels (2 values) instead of split sets, use
train_test_splitto createX_train,X_test,y_train,y_test. - Define a Keras
Sequentialmodel withDenselayers (e.g., 27 neurons, logistic activation). - Compile the model using
SGDoptimizer andbinary_crossentropyloss. - Fit the model and evaluate it.
- Track the model that achieves the highest score.
- Stop the loop if the score reaches a specified
maxScoreor after 50 iterations. - Store the best model in
self.modeland return it. - Prediction Function (
predict): Check if the model exists. Reshape the input image to(1, -1). Usemodel.predict()andnp.argmax()to get the class. Return the result.
Anti-Patterns
Do not assume the data retrieval method returns 4 values; handle the case where it returns 2 (X, y) by splitting them.
Triggers
- convert sklearn code to keras
- iterative training loop
- getBestTrainedModel keras
- predict function keras
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.