[scikit-learn] scikit-learn Digest, Vol 9, Issue 42

Graham Arthur Mackenzie graham.arthur.mackenzie at gmail.com
Tue Dec 13 17:02:29 EST 2016


Thanks for the speedy and helpful responses!

Actually, the thrust of my question was, "I'm assuming the fit() method for
all three modules work the same way, so how come the example code for DTs
differs from NB, SVMs?" Since you seem to be saying that it'll work either
way, I'm assuming there's no real reason behind it, which was my suspicion,
but just wanted to have it confirmed, as the inconsistency was conspicuous.

Thanks!
GAM

ps, My apologies if this is the improper way to respond to responses. I am
receiving the Digest rather than individual messages, so this was the best
I could think to do...

On Tue, Dec 13, 2016 at 12:38 PM, <scikit-learn-request at python.org> wrote:

> Send scikit-learn mailing list submissions to
>         scikit-learn at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/scikit-learn
> or, via email, send a message with subject or body 'help' to
>         scikit-learn-request at python.org
>
> You can reach the person managing the list at
>         scikit-learn-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of scikit-learn digest..."
>
>
> Today's Topics:
>
>    1. Why do DTs have a different fit protocol than NB and SVMs?
>       (Graham Arthur Mackenzie)
>    2. Re: Why do DTs have a different fit protocol than NB and
>       SVMs? (Jacob Schreiber)
>    3. Re: Why do DTs have a different fit protocol than NB and
>       SVMs? (Stuart Reynolds)
>    4. Re: Why do DTs have a different fit protocol than NB and
>       SVMs? (Vlad Niculae)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 13 Dec 2016 12:14:43 -0800
> From: Graham Arthur Mackenzie <graham.arthur.mackenzie at gmail.com>
> To: scikit-learn at python.org
> Subject: [scikit-learn] Why do DTs have a different fit protocol than
>         NB and SVMs?
> Message-ID:
>         <CAGUvBb72XoZgcuiUAxucmZ9FckirZLLnv3Zm4aw5tCSF-6GHtw at mail.gm
> ail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hello All,
>
> I hope this is the right way to ask a question about documentation.
>
> In the doc for Decision Trees
> <http://scikit-learn.org/stable/modules/tree.html#tree>, the fit statement
> is assigned back to the classifier:
>
> clf = clf.fit(X, Y)
>
> Whereas, for Naive Bayes
> <http://scikit-learn.org/stable/modules/generated/sklearn.
> naive_bayes.GaussianNB.html>
>  and Support Vector Machines
> <http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html>,
> it's just:
>
> clf.fit(X, Y)
>
> I assumed this was a typo, but thought I should try and verify such before
> proceeding under that assumption. I appreciate any feedback you can
> provide.
>
> Thank You and Be Well,
> Graham
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/scikit-learn/attachments/
> 20161213/8bbeacdb/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 13 Dec 2016 12:23:00 -0800
> From: Jacob Schreiber <jmschreiber91 at gmail.com>
> To: Scikit-learn user and developer mailing list
>         <scikit-learn at python.org>
> Subject: Re: [scikit-learn] Why do DTs have a different fit protocol
>         than NB and SVMs?
> Message-ID:
>         <CA+ad8Ev87kFsDfkX8xUsoLFpa9x=W3Kr_wG3ue47WosO=JoZtw at mail.gm
> ail.com>
> Content-Type: text/plain; charset="utf-8"
>
> The fit method returns the object itself, so regardless of which way you do
> it, it will work. The reason the fit method returns itself is so that you
> can chain methods, like "preds = clf.fit(X, y).predict(X)"
>
> On Tue, Dec 13, 2016 at 12:14 PM, Graham Arthur Mackenzie <
> graham.arthur.mackenzie at gmail.com> wrote:
>
> > Hello All,
> >
> > I hope this is the right way to ask a question about documentation.
> >
> > In the doc for Decision Trees
> > <http://scikit-learn.org/stable/modules/tree.html#tree>, the fit
> > statement is assigned back to the classifier:
> >
> > clf = clf.fit(X, Y)
> >
> > Whereas, for Naive Bayes
> > <http://scikit-learn.org/stable/modules/generated/sklearn.
> naive_bayes.GaussianNB.html>
> >  and Support Vector Machines
> > <http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html>,
> > it's just:
> >
> > clf.fit(X, Y)
> >
> > I assumed this was a typo, but thought I should try and verify such
> before
> > proceeding under that assumption. I appreciate any feedback you can
> provide.
> >
> > Thank You and Be Well,
> > Graham
> >
> > _______________________________________________
> > scikit-learn mailing list
> > scikit-learn at python.org
> > https://mail.python.org/mailman/listinfo/scikit-learn
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/scikit-learn/attachments/
> 20161213/08e2e7c2/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 13 Dec 2016 12:33:48 -0800
> From: Stuart Reynolds <stuart at stuartreynolds.net>
> To: Scikit-learn user and developer mailing list
>         <scikit-learn at python.org>
> Subject: Re: [scikit-learn] Why do DTs have a different fit protocol
>         than NB and SVMs?
> Message-ID:
>         <CAAy-kdnQ3t3gH=BbjwD_n7Zr+9gnV-X34Eke=fc=ysiW6zidrw at mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I think he's asking whether returning the model is part of the API (i.e. is
> it a bug that SVM and NB don't return self?).
>
> On Tue, Dec 13, 2016 at 12:23 PM, Jacob Schreiber <jmschreiber91 at gmail.com
> >
> wrote:
>
> > The fit method returns the object itself, so regardless of which way you
> > do it, it will work. The reason the fit method returns itself is so that
> > you can chain methods, like "preds = clf.fit(X, y).predict(X)"
> >
> > On Tue, Dec 13, 2016 at 12:14 PM, Graham Arthur Mackenzie <
> > graham.arthur.mackenzie at gmail.com> wrote:
> >
> >> Hello All,
> >>
> >> I hope this is the right way to ask a question about documentation.
> >>
> >> In the doc for Decision Trees
> >> <http://scikit-learn.org/stable/modules/tree.html#tree>, the fit
> >> statement is assigned back to the classifier:
> >>
> >> clf = clf.fit(X, Y)
> >>
> >> Whereas, for Naive Bayes
> >> <http://scikit-learn.org/stable/modules/generated/sklearn.
> naive_bayes.GaussianNB.html>
> >>  and Support Vector Machines
> >> <http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html
> >,
> >> it's just:
> >>
> >> clf.fit(X, Y)
> >>
> >> I assumed this was a typo, but thought I should try and verify such
> >> before proceeding under that assumption. I appreciate any feedback you
> can
> >> provide.
> >>
> >> Thank You and Be Well,
> >> Graham
> >>
> >> _______________________________________________
> >> scikit-learn mailing list
> >> scikit-learn at python.org
> >> https://mail.python.org/mailman/listinfo/scikit-learn
> >>
> >>
> >
> > _______________________________________________
> > scikit-learn mailing list
> > scikit-learn at python.org
> > https://mail.python.org/mailman/listinfo/scikit-learn
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/scikit-learn/attachments/
> 20161213/2d6dd8e7/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 13 Dec 2016 15:38:42 -0500
> From: Vlad Niculae <zephyr14 at gmail.com>
> To: Scikit-learn user and developer mailing list
>         <scikit-learn at python.org>, Stuart Reynolds <
> stuart at stuartreynolds.net>
> Subject: Re: [scikit-learn] Why do DTs have a different fit protocol
>         than NB and SVMs?
> Message-ID: <94FAD0C4-CE95-4A1E-9079-418962D2B9C0 at gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> It is part of the API and enforced with tests, if I'm not mistaken. So you
> could use either form with all sklearn estimators.
>
> Vlad
>
> On December 13, 2016 3:33:48 PM EST, Stuart Reynolds <
> stuart at stuartreynolds.net> wrote:
> >I think he's asking whether returning the model is part of the API
> >(i.e. is
> >it a bug that SVM and NB don't return self?).
> >
> >On Tue, Dec 13, 2016 at 12:23 PM, Jacob Schreiber
> ><jmschreiber91 at gmail.com>
> >wrote:
> >
> >> The fit method returns the object itself, so regardless of which way
> >you
> >> do it, it will work. The reason the fit method returns itself is so
> >that
> >> you can chain methods, like "preds = clf.fit(X, y).predict(X)"
> >>
> >> On Tue, Dec 13, 2016 at 12:14 PM, Graham Arthur Mackenzie <
> >> graham.arthur.mackenzie at gmail.com> wrote:
> >>
> >>> Hello All,
> >>>
> >>> I hope this is the right way to ask a question about documentation.
> >>>
> >>> In the doc for Decision Trees
> >>> <http://scikit-learn.org/stable/modules/tree.html#tree>, the fit
> >>> statement is assigned back to the classifier:
> >>>
> >>> clf = clf.fit(X, Y)
> >>>
> >>> Whereas, for Naive Bayes
> >>>
> ><http://scikit-learn.org/stable/modules/generated/sklearn.
> naive_bayes.GaussianNB.html>
> >>>  and Support Vector Machines
> >>>
> ><http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html>,
> >>> it's just:
> >>>
> >>> clf.fit(X, Y)
> >>>
> >>> I assumed this was a typo, but thought I should try and verify such
> >>> before proceeding under that assumption. I appreciate any feedback
> >you can
> >>> provide.
> >>>
> >>> Thank You and Be Well,
> >>> Graham
> >>>
> >>> _______________________________________________
> >>> scikit-learn mailing list
> >>> scikit-learn at python.org
> >>> https://mail.python.org/mailman/listinfo/scikit-learn
> >>>
> >>>
> >>
> >> _______________________________________________
> >> scikit-learn mailing list
> >> scikit-learn at python.org
> >> https://mail.python.org/mailman/listinfo/scikit-learn
> >>
> >>
> >
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >scikit-learn mailing list
> >scikit-learn at python.org
> >https://mail.python.org/mailman/listinfo/scikit-learn
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mail.python.org/pipermail/scikit-learn/attachments/
> 20161213/45217ea3/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
>
> ------------------------------
>
> End of scikit-learn Digest, Vol 9, Issue 42
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-learn/attachments/20161213/c6c34750/attachment-0001.html>


More information about the scikit-learn mailing list