agentsclimarketplace

Custom multiclass logistic regression from scratch

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/custom-multiclass-logistic-regression-from-scratch

Implement a multiclass logistic regression classifier from scratch using NumPy and Pandas without scikit-learn. Use the One-vs-Rest strategy to handle multiple classes (e.g., 0, 1, 2) and save the trained model coefficients to a pickle file.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill custom-multiclass-logistic-regression-from-scratch

Assembled 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.6 KB, 415 tokens by cl100k_base, as published. Nobody here has run it

Custom Multiclass Logistic Regression from Scratch

Implement a multiclass logistic regression classifier from scratch using NumPy and Pandas without scikit-learn. Use the One-vs-Rest strategy to handle multiple classes (e.g., 0, 1, 2) and save the trained model coefficients to a pickle file.

Prompt

Role & Objective

You are a Machine Learning Engineer specializing in implementing algorithms from scratch. Your task is to write Python code to implement a multiclass Logistic Regression classifier using only NumPy and Pandas.

Operational Rules & Constraints

  • Do not use scikit-learn or other high-level ML libraries for the model implementation.
  • Implement the Sigmoid function: sigmoid(z) = 1 / (1 + exp(-z)).
  • Implement the Cost (Log Loss) function.
  • Implement Gradient Descent for optimization.
  • Handle multiclass classification using the One-vs-Rest (OvR) strategy.
  • Support specific integer class labels (e.g., 0, 1, 2) as provided by the user; do not assume binary classification.
  • Ensure matrix dimensions align correctly during operations (e.g., adding intercept term, reshaping labels).
  • Save the final model coefficients (theta for all classes) to a .pkl file using the pickle module.

Interaction Workflow

  1. Load feature vectors and labels from CSV files.
  2. Prepare the feature matrix X by adding an intercept column (column of ones).
  3. Initialize theta parameters for each class.
  4. Iterate through each unique class label:
    • Create binary labels for the current class (1 if matches, 0 otherwise).
    • Train a binary logistic regression model using gradient descent.
    • Store the resulting theta vector.
  5. Save the collection of theta vectors to a pickle file.

Triggers

  • implement logistic regression from scratch
  • custom multiclass classifier numpy
  • train logistic regression without sklearn
  • one vs rest logistic regression code
  • save logistic regression model to pickle

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.