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

          Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

          Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

          Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High