pydata / pydata/patsy

Question: Programmatically creating splines and applying knots to new data

Open
#121 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
990
Forks
106
Avg merge
7d 34m
Merged PRs (30d)
1

Description

I have found that I can create a spline on training data and then apply to test data like this:

#create
x1= dmatrix("cr(x, df=3) - 1", {"x":TRAIN_DATA.VARIABLE.values})
#apply
xx1=build_design_matrices([x1.design_info], {"x":TEST_DATA.VARIABLE.values })

This works but of course requires manually creating variables or trying to programatically creating strings.

Is there anyway to do something like this
patsy.cr(x, df=5)

and grab the knots to apply to new data using the same function cr()?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the dmatrix and build_design_matrices workflow described in the issue, along with the cr() transformation behavior. Determine whether a public API for creating a spline and reusing its knots is specified or supported; the issue is done only when the intended reuse workflow and its scope are defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.