What's the difference between instantiate a class with () and without () ?
Here is the code I am working with:
import numpy as np
from sklearn.datasets.samples_generator import make_regression
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
X, y = make_regression(n_samples=100, n_features=10, n_informative=2,
noise=3.0, random_state=1)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
Here comes my question. I need to instantiate the class LinearRegression and when I do it like it follows, everything works fine.
model = LinearRegression()
model.fit(X_train, y_train)
Instead if I do it in this other way:
model = LinearRegression
model.fit(X_train, y_train)
I get the following error:
TypeError: fit() missing 1 required positional argument: 'y'
So I guess the problem is the missing (). What's happening exactly when I omit the () ? Is it equivalent to what follows ?
from sklearn.linear_model import LinearRegression as model