Scikit-learn
Installation
We should install scikit-learn though the package we used is called sklearn.
Linear regression
Scikit-learn has a gradient descent linear regression model SGDRegressor that performs well with normalized inputs. StandardScaler will perform z-score normalization as we learnt.
1 | # import module |
In addition to linear regression using gradient descent, scikit-learn also implements another linear regression model using normal equation, that is LinearRegression.
1 | # import module |
Logistic regression
The logistic regression model in scikit-learn is LogisticRegression.
1 | # import module |
Datasets and dataset partition
The sklearn.datasets module includes utilities to load datasets. These datasets are useful for the training of model. See more information on sklearn.datasets.
Module train_test_split in sklearn.model_selection can help us split training set into training set and test set, for examples:
1 | X_train, X_, y_train, y_ = train_test_split(X, y, test_size=0.4, random_state=1) |