Git Product home page Git Product logo

Comments (2)

matthewwardrop avatar matthewwardrop commented on July 19, 2024

Hi @xjing76 ! Thanks for reporting.

There was a bug in formulaic 0.3.0 that would lead to this, but it should have been fixed in 0.3.1. Was it?

Your minimal example doesn't work for me (likely a different bug caused by the interaction of a structured formula with an unstructured model spec, looking into it now), but this code works fine against 0.3.1:

import pandas as pd
import formulaic
from formulaic.model_spec import ModelSpec
import scipy

data = [[1,10],[2,12],[1,13]]
df = pd.DataFrame(data,columns=['a','b'])
formula = 'b ~ 1+C(a)'
y, X_ = formulaic.Formula(formula).get_model_matrix(df.head(1))

kwargs = {'output':'sparse'}
spec = copy.deepcopy(X_.model_spec)
spec.output = 'sparse'
#spec = ModelSpec(formula=formula, structure=X_.model_spec.structure,  **kwargs)
X = spec.get_model_matrix(df)
X
<3x1 sparse matrix of type '<class 'numpy.int64'>'
	with 3 stored elements in Compressed Sparse Column format>

from formulaic.

matthewwardrop avatar matthewwardrop commented on July 19, 2024

Currently, ModelSpec's spanning left/right hand sides are not supported. ModelSpecs only describe single ModelMatrix objects. There are ways around this, but they're not elegant... I'll try to think about this for future releases.

This bug, however, does seem to be resolved, so I will close this out. Feel free to reopen of 0.3.1 doesn't work for you. I'll create a separate issue for the improvement of the user experience re-direct ModelSpec creation.

from formulaic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.