PeptideVectorizer.transform returns zeros after fitting with training_already_reduced=True
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python, scikit-learn
- Ambito
- data
Direzione di ricerca
Start by reading PeptideVectorizer.make_count_vectorizer and the fit_transform and transform paths in the implementation, then reproduce the example with training_already_reduced=True. Check how each vectorizer handles letter case and how changing it affects pickled vocabularies. Done means transform(seqs) returns the expected nonzero counts and the compatibility choice is addressed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
With training_already_reduced=True, PeptideVectorizer.transform returns all zeros.
from pepdata import PeptideVectorizer
from pepdata.reduced_alphabet import hp2
seqs = ["SIINFEKL", "GILGFVFTL"]
reduced = ["".join(hp2[r] for r in s) for s in seqs] # ['ACCACAAC', 'ACCACCCAC']
v = PeptideVectorizer(reduced_alphabet=hp2, training_already_reduced=True, normalize_row=False)
v.fit_transform(reduced) # [[4, 4], [3, 6]]; vocabulary_ == {'a': 0, 'c': 1}
v.transform(seqs) # [[0, 0], [0, 0]]
fit_transform fits a second CountVectorizer without a preprocessor, which lowercases by default (lowercase=True), so the copied vocabulary is lowercase ({'a', 'c'}). transform then uses self.count_vectorizer, whose custom preprocessor maps residues to the uppercase group letters, and scikit-learn skips lowercasing when a preprocessor is given. No n-gram matches. Without training_already_reduced, the vocabulary is uppercase ({'A', 'C'}) and transform works.
Checked with scikit-learn 1.9.1 on the branch of #68 (which fixes #62; the same happens on master with normalize_row=False).
Possible fix
Build both vectorizers with lowercase=False in make_count_vectorizer (sequences are uppercase amino acids), or lowercase inside the reduced-alphabet preprocessor. Either changes the vocabulary's letter case, which pickled vectorizers keep, so it needs a decision on compatibility; it was left out of #68.
- Lingua principale
- Python
- Stelle
- 58
- Fork
- 16
- Merge medio
- 1g 8h
- PR unite (30g)
- 6
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openvax/pepdata
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Tutte le issue di openvax/pepdata
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
marimo-team/marimo#11768 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
btclib-org/btclib-node#2358 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 7 giorni
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MTSWebServices/RecTools#330 ·