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.

Assessment

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

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.

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()?

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

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.

More from pydata/patsy

All issues in pydata/patsy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.