why does transform from tfidf vectorizer (sklearn) not workPassing TFIDF Feature Vector to a SGDClassifier from sklearnHow does SelectKBest work?Document Categorization ProblemHow to explain the outcome of k-means clustering?TF-IDF vectorizer doesn't work better than countvectorizerMultioutput regression with MLPRegressor - Does it work?What is the difference between a hashing vectorizer and a tfidf vectorizerSklearn tfidf vectorize returns different shape after fit_transform()Why does GridSearchCV (sklearn) change the value of n_samples?Python Sklearn TfidfVectorizer Feature not matching; delete?

Does this article imply that Turing-Computability is not the same as "effectively computable"?

How to give very negative feedback gracefully?

CRT Oscilloscope - part of the plot is missing

How to reply this mail from potential PhD professor?

Summing the values of a sequence using expl3

What is Shri Venkateshwara Mangalasasana stotram recited for?

What property of a transistor makes it an amplifier?

How did Arya get her dagger back from Sansa?

Junior developer struggles: how to communicate with management?

Why do we use caret (^) as the symbol for ctrl/control?

Pressure inside an infinite ocean?

Missed the connecting flight, separate tickets on same airline - who is responsible?

I need a disease

Why was the battle set up *outside* Winterfell?

Ubuntu 19.04 python 3.6 is not working

Why do money exchangers give different rates to different bills?

Why is C# in the D Major Scale?

What happens to the Time Stone?

Moving the subject of the sentence into a dangling participle

If Earth is tilted, why is Polaris always above the same spot?

Would glacier 'trees' be plausible?

Python password manager

Coefficients of linear dependency

How is the law in a case of multiple edim zomemim justified by Chachomim?



why does transform from tfidf vectorizer (sklearn) not work


Passing TFIDF Feature Vector to a SGDClassifier from sklearnHow does SelectKBest work?Document Categorization ProblemHow to explain the outcome of k-means clustering?TF-IDF vectorizer doesn't work better than countvectorizerMultioutput regression with MLPRegressor - Does it work?What is the difference between a hashing vectorizer and a tfidf vectorizerSklearn tfidf vectorize returns different shape after fit_transform()Why does GridSearchCV (sklearn) change the value of n_samples?Python Sklearn TfidfVectorizer Feature not matching; delete?













0












$begingroup$


I'm transforming a text in tf-idf from sklearn. I made the model:



from sklearn.feature_extraction.text import TfidfVectorizer
corpus = words
vectorizer = TfidfVectorizer(min_df = 15)
tf_idf_model = vectorizer.fit_transform(corpus)


And now I'm making vectors for different sets of words (documents), like:



word_set = ['dog', 'cat', 'foo']
v = vectorizer.transform(word_set)


But I want just one vector of these words, to compare to other documents. But when I use transform, the shape of v becomes:



<3x56492 sparse matrix of type '<class 'numpy.float64'>'
with 3 stored elements in Compressed Sparse Row format>


I want a vector with shape 1x56492, and not 3x56492.. I'm certainly missing something here. Maybe you guys have some tips?



Thank you very much in advance.









share









New contributor




why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$
















    0












    $begingroup$


    I'm transforming a text in tf-idf from sklearn. I made the model:



    from sklearn.feature_extraction.text import TfidfVectorizer
    corpus = words
    vectorizer = TfidfVectorizer(min_df = 15)
    tf_idf_model = vectorizer.fit_transform(corpus)


    And now I'm making vectors for different sets of words (documents), like:



    word_set = ['dog', 'cat', 'foo']
    v = vectorizer.transform(word_set)


    But I want just one vector of these words, to compare to other documents. But when I use transform, the shape of v becomes:



    <3x56492 sparse matrix of type '<class 'numpy.float64'>'
    with 3 stored elements in Compressed Sparse Row format>


    I want a vector with shape 1x56492, and not 3x56492.. I'm certainly missing something here. Maybe you guys have some tips?



    Thank you very much in advance.









    share









    New contributor




    why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $endgroup$














      0












      0








      0





      $begingroup$


      I'm transforming a text in tf-idf from sklearn. I made the model:



      from sklearn.feature_extraction.text import TfidfVectorizer
      corpus = words
      vectorizer = TfidfVectorizer(min_df = 15)
      tf_idf_model = vectorizer.fit_transform(corpus)


      And now I'm making vectors for different sets of words (documents), like:



      word_set = ['dog', 'cat', 'foo']
      v = vectorizer.transform(word_set)


      But I want just one vector of these words, to compare to other documents. But when I use transform, the shape of v becomes:



      <3x56492 sparse matrix of type '<class 'numpy.float64'>'
      with 3 stored elements in Compressed Sparse Row format>


      I want a vector with shape 1x56492, and not 3x56492.. I'm certainly missing something here. Maybe you guys have some tips?



      Thank you very much in advance.









      share









      New contributor




      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $endgroup$




      I'm transforming a text in tf-idf from sklearn. I made the model:



      from sklearn.feature_extraction.text import TfidfVectorizer
      corpus = words
      vectorizer = TfidfVectorizer(min_df = 15)
      tf_idf_model = vectorizer.fit_transform(corpus)


      And now I'm making vectors for different sets of words (documents), like:



      word_set = ['dog', 'cat', 'foo']
      v = vectorizer.transform(word_set)


      But I want just one vector of these words, to compare to other documents. But when I use transform, the shape of v becomes:



      <3x56492 sparse matrix of type '<class 'numpy.float64'>'
      with 3 stored elements in Compressed Sparse Row format>


      I want a vector with shape 1x56492, and not 3x56492.. I'm certainly missing something here. Maybe you guys have some tips?



      Thank you very much in advance.







      scikit-learn tfidf





      share









      New contributor




      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share









      New contributor




      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share








      edited 1 min ago









      Simon Larsson

      1,195217




      1,195217






      New contributor




      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 7 mins ago









      why_notwhy_not

      1




      1




      New contributor




      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      why_not is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "557"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          why_not is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f51224%2fwhy-does-transform-from-tfidf-vectorizer-sklearn-not-work%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          why_not is a new contributor. Be nice, and check out our Code of Conduct.









          draft saved

          draft discarded


















          why_not is a new contributor. Be nice, and check out our Code of Conduct.












          why_not is a new contributor. Be nice, and check out our Code of Conduct.











          why_not is a new contributor. Be nice, and check out our Code of Conduct.














          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f51224%2fwhy-does-transform-from-tfidf-vectorizer-sklearn-not-work%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Marja Vauras Lähteet | Aiheesta muualla | NavigointivalikkoMarja Vauras Turun yliopiston tutkimusportaalissaInfobox OKSuomalaisen Tiedeakatemian varsinaiset jäsenetKasvatustieteiden tiedekunnan dekaanit ja muu johtoMarja VaurasKoulutusvienti on kestävyys- ja ketteryyslaji (2.5.2017)laajentamallaWorldCat Identities0000 0001 0855 9405n86069603utb201588738523620927

          Which is better: GPT or RelGAN for text generation?2019 Community Moderator ElectionWhat is the difference between TextGAN and LM for text generation?GANs (generative adversarial networks) possible for text as well?Generator loss not decreasing- text to image synthesisChoosing a right algorithm for template-based text generationHow should I format input and output for text generation with LSTMsGumbel Softmax vs Vanilla Softmax for GAN trainingWhich neural network to choose for classification from text/speech?NLP text autoencoder that generates text in poetic meterWhat is the interpretation of the expectation notation in the GAN formulation?What is the difference between TextGAN and LM for text generation?How to prepare the data for text generation task

          Is this part of the description of the Archfey warlock's Misty Escape feature redundant?When is entropic ward considered “used”?How does the reaction timing work for Wrath of the Storm? Can it potentially prevent the damage from the triggering attack?Does the Dark Arts Archlich warlock patrons's Arcane Invisibility activate every time you cast a level 1+ spell?When attacking while invisible, when exactly does invisibility break?Can I cast Hellish Rebuke on my turn?Do I have to “pre-cast” a reaction spell in order for it to be triggered?What happens if a Player Misty Escapes into an Invisible CreatureCan a reaction interrupt multiattack?Does the Fiend-patron warlock's Hurl Through Hell feature dispel effects that require the target to be on the same plane as the caster?What are you allowed to do while using the Warlock's Eldritch Master feature?