Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101442

What use of these _ prefix members?

X-Received by 10.66.165.39 with SMTP id yv7mr62908770pab.28.1452448535408; Sun, 10 Jan 2016 09:55:35 -0800 (PST)
X-Received by 10.50.114.105 with SMTP id jf9mr187254igb.1.1452448535378; Sun, 10 Jan 2016 09:55:35 -0800 (PST)
Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!h5no2667039igh.0!news-out.google.com!l1ni9575igd.0!nntp.google.com!o2no1753954iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Sun, 10 Jan 2016 09:55:34 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=70.55.121.141; posting-account=SZ_svQkAAACWRFG2bDA-zgq8ILyl4-vo
NNTP-Posting-Host 70.55.121.141
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <4ee5810e-abe9-4c4b-9ebd-d989b5c2b341@googlegroups.com> (permalink)
Subject What use of these _ prefix members?
From Robert <rxjwg98@gmail.com>
Injection-Date Sun, 10 Jan 2016 17:55:35 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:101442

Show key headers only | View raw


Hi,

When I read a sample file from hmm learn package, which is on top of 
scikit-learn package, I see there are many member functions (prefix with 
'_') have no caller. That is, I don't see anything uses those functions.
Below is a sample part from class GMMHMM(_BaseHMM):





//////////
    def __init__(self, n_components=1, n_mix=1,........
                 params="stmcw", init_params="stmcw"):
        _BaseHMM.__init__(self, n_components,.........
                          params=params, init_params=init_params)

        # XXX: Hotfit for n_mix that is incompatible with the scikit's
        # BaseEstimator API
        self.n_mix = n_mix
        self.covariance_type = covariance_type
        self.covars_prior = covars_prior
        self.gmms_ = []
        for x in range(self.n_components):
            if covariance_type is None:
                gmm = GMM(n_mix)
            else:
                gmm = GMM(n_mix, covariance_type=covariance_type)
            self.gmms_.append(gmm)

    def _init(self, X, lengths=None):
        super(GMMHMM, self)._init(X, lengths=lengths)

        for g in self.gmms_:
            g.set_params(init_params=self.init_params, n_iter=0)
            g.fit(X)

    def _compute_log_likelihood(self, X):
        return np.array([g.score(X) for g in self.gmms_]).T

    def _generate_sample_from_state(self, state, random_state=None):
        return self.gmms_[state].sample(1, random_state=random_state).flatten()
////////////

Some online tutorials tell me '_' prefix is a kind of convention of private 
members. hmm is not a formal package. Do these '_' member functions are
unfinished? Or, they may be used in some way I don't know yet?

Thanks,

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

What use of these _ prefix members? Robert <rxjwg98@gmail.com> - 2016-01-10 09:55 -0800
  Re: What use of these _ prefix members? Steven D'Aprano <steve@pearwood.info> - 2016-01-11 05:03 +1100
  Re: What use of these _ prefix members? Peter Otten <__peter__@web.de> - 2016-01-10 19:34 +0100
    Re: What use of these _ prefix members? me <self@example.org> - 2016-01-12 14:12 +0000
      Re: What use of these _ prefix members? Peter Otten <__peter__@web.de> - 2016-01-12 15:52 +0100
      Re: What use of these _ prefix members? Jason Swails <jason.swails@gmail.com> - 2016-01-12 10:01 -0500

csiph-web