"\u001b[0;32m<ipython-input-6-23b595ae4fed>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# What are the parameter values of the linear boundary equation x_2=a x_1 + b?\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mscoef_\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcoef_\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mintercept_\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcoef_\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'boudary equation x_2={} x_1 + {}'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'RidgeClassifier' object has no attribute 'scoef_'"
"#get the documentation for sklearn RidgeClassification object\n",
"#get the documentation for sklearn RidgeClassification object\n",
"linear_model.RidgeClassifier?"
"linear_model.RidgeClassifier?"
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
This notebook can be run on mybinder: [](https://mybinder.org/v2/git/https%3A%2F%2Fgricad-gitlab.univ-grenoble-alpes.fr%2Fchatelaf%2Fml-sicom3a/master?filepath=notebooks%2F/1_introduction/N1_Linear_Classification.ipynb)
This notebook can be run on mybinder: [](https://mybinder.org/v2/git/https%3A%2F%2Fgricad-gitlab.univ-grenoble-alpes.fr%2Fchatelaf%2Fml-sicom3a/master?filepath=notebooks%2F/1_introduction/N1_Linear_Classification.ipynb)
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
# Import modules
# Import modules
%matplotlibinline
%matplotlibinline
importmatplotlib
importmatplotlib
importnumpyasnp
importnumpyasnp
importscipyassp
importscipyassp
importmatplotlib.pyplotasplt
importmatplotlib.pyplotasplt
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
# Select random seed
# Select random seed
random_state=0
random_state=0
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
We use scikit-learn to generate a toy 2D data set (two features $x_1$ and $x_2$) for binary classification (two classes)
We use scikit-learn to generate a toy 2D data set (two features $x_1$ and $x_2$) for binary classification (two classes)
- each sample $(x_1,x_2)$ in the dataset is plotted as a 2D point where the two features $x_1$ and $x_2$ are displayed along the abscissa and ordinate axes respectively
- each sample $(x_1,x_2)$ in the dataset is plotted as a 2D point where the two features $x_1$ and $x_2$ are displayed along the abscissa and ordinate axes respectively
- the corresponding class label $y$ is displayed as a color mark (e.g., yellow or purple)
- the corresponding class label $y$ is displayed as a color mark (e.g., yellow or purple)
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
fromsklearn.datasetsimportmake_classification
fromsklearn.datasetsimportmake_classification
#X are the features (aka inputs, ...), y the labels (aka responses, targets, output...)
#X are the features (aka inputs, ...), y the labels (aka responses, targets, output...)
AttributeError: 'RidgeClassifier' object has no attribute 'scoef_'
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
### Exercise
### Exercise
Change the number of informative features from `n_informative=2̀` to `n_informative=1` in the `make_classification()` procedure, regenerate the data set and fit the classification rule. Interpret now the new decision boundary: are the two variables of equal importance in predicting the class of the data?
Change the number of informative features from `n_informative=2̀` to `n_informative=1` in the `make_classification()` procedure, regenerate the data set and fit the classification rule. Interpret now the new decision boundary: are the two variables of equal importance in predicting the class of the data?
%% Cell type:code id: tags:
%% Cell type:code id: tags:
``` python
``` python
#get the documentation for sklearn RidgeClassification object
#get the documentation for sklearn RidgeClassification object