title: beginner OOP question....why is 'self' used in other functions (not just the __init___)
body: <p>I've been reading OOP and trying to grasp the concept of <code>self</code> and <code>__init__</code> and I think I found an explanation that makes sense (to me at least).  this is an article on building a linear regression estimator using OOP concepts.</p>
  
  <p><a href="https://dziganto.github.io/classes/data%20science/linear%20regression/machine%20learning/object-oriented%20programming/python/Understanding-Object-Oriented-Programming-Through-Machine-Learning/" rel="nofollow noreferrer">Article Link</a></p>
  
  <pre><code>class MyLinearRegression:
  
      def __init__(self, fit_intercept=True):
          self.coef_ = None
          self.intercept_ = None
          self._fit_intercept = fit_intercept
  </code></pre>
  
  <p>The layman explanation is as follows:</p>
  
  <blockquote>
    <p>At a high level, <code>__init__</code> provides a recipe for how to build an instance of <code>MyLinearRegression</code> ...
    Since an instance of <code>MyLinearRegression</code> can take on any name a user gives it, 
    we need a way to link the user’s instance name back to the class so we can accomplish certain tasks.
    Think of <code>self</code> as a variable whose sole job is to learn the name of a particular instance</p>
  </blockquote>
  
  <p>so I think this makes sense.  what I dont get is why <code>self</code> is used again in when defining new methods.</p>
  
  <pre><code>def predict(self, X):
      """
      Output model prediction.
  
      Arguments:
      X: 1D or 2D numpy array 
      """
  
      # check if X is 1D or 2D array
      if len(X.shape) == 1:
          X = X.reshape(-1,1) 
      return self.intercept_ + np.dot(X, self.coef_)
  </code></pre>
  
  <p>In this version.  What is <code>self</code> referring to?</p>