pydata / pydata/patsy

coding categorical response variables for use with scikit-learn

Open
#77 10 comments 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

scikit-learn expects the response variable to be a 1d array. For example,

from sklearn.linear_model import LogisticRegression
lr = LogisticRegression()
lr.fit(X, y) # here y is expected to be 1d array, strings or numerical labels

However, if y is an array of strings, patsy will convert it to dummy variables, which scikit-learn will not accept as a valid response y.

Would it be useful perhaps to be able to tell patsy that a given (string-type) variable should remain a string and/or converted to numeric labels?

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 with the LogisticRegression example and its lr.fit(X, y) call, then inspect how patsy currently converts string response variables into dummy variables. Clarify whether the desired behavior is preserving strings or producing numeric labels before identifying the affected response-variable path. Done means defining and testing one agreed behavior that produces a valid one-dimensional scikit-learn response.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, scikit-learn
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.