1

In the implementation of Linear Regression using Python and other libraries (sklearn) the usual declarations we deploy are

from sklearn import linear_model
.......
..
regr = linear_model.LinearRegression()
...
..

I know that LinearRegresssion is a class in the library sklearn, then what exactly linear_model signifies? and how class and libraries are usually linked/related? can you please give a light in this or share relevant pages for my understanding of core concept.

Bhanu Chander
  • 390
  • 1
  • 6
  • 16
  • 1
    It's simply a directory in the sklearn library that Python iterprets as a package. If you look in their [GitHub repo](https://github.com/scikit-learn/scikit-learn/tree/master/sklearnl), you'll see a folder called `linear_model` and in that folder is a `base.py` that defines the `LinearRegression` class. Of course, in order for Python to know that the directory is a package, it has to have the `__init__.py` file, which the folder also contains... [documentation here](https://docs.python.org/3/tutorial/modules.html#packages) – Scratch'N'Purr Mar 07 '17 at 13:13
  • I now got the clear picture. That GitHub Repo link that you shared is broke. It has an additional 'L' at the end. The correct link is here - https://github.com/scikit-learn/scikit-learn/tree/master/sklearn from Kewl answer. – Bhanu Chander Mar 07 '17 at 16:13
  • Ah, thanks for catching that! – Scratch'N'Purr Mar 07 '17 at 22:35

1 Answers1

1

sklearn is a package. It contains the subpackage linear_model, which contains some modules and the class LinearRegression.

You can read more about this structure here: https://stackoverflow.com/a/18555203/5952674

And explore the structure of sklearn here: https://github.com/scikit-learn/scikit-learn/tree/master/sklearn

Community
  • 1
  • 1
Kewl
  • 3,327
  • 5
  • 26
  • 45