This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import preprocessing | |
from sklearn.linear_model import LogisticRegression | |
# Label encoding | |
label_encoder = preprocessing.LabelEncoder() | |
train_Y = label_encoder.fit_transform(train_Y) | |
# Model training | |
clf = LogisticRegression() | |
clf.fit(train_X, train_Y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import utils | |
>>> print(utils.multiclass.type_of_target(train_Y)) | |
'multiclass' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn import preprocessing | |
label_encoder = preprocessing.LabelEncoder() | |
train_Y = label_encoder.fit_transform(train_Y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import utils | |
>>> print(utils.multiclass.type_of_target(train_Y)) | |
'continuous' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.linear_model import LogisticRegression | |
train_X = np.array([ | |
[100, 1.1, 0.8], | |
[200, 1.0, 6.5], | |
[150, 1.3, 7.1], | |
[120, 1.2, 3.0], | |
[100, 1.1, 4.0], | |
[150, 1.2, 6.8], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "test.py", line 14, in <module> | |
clf.fit(train_X, train_Y) | |
File "/usr/local/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py", line 1347, in fit | |
check_classification_targets(y) | |
File "/usr/local/lib/python3.7/site-packages/sklearn/utils/multiclass.py", line 183, in check_classification_targets | |
raise ValueError("Unknown label type: %r" % y_type) | |
ValueError: Unknown label type: 'continuous' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT ON (customer_id) customer_id, store_id | |
FROM rental_example | |
ORDER BY customer_id, amount; | |
/* | |
|customer_id|store_id| | |
|-----------|--------| | |
| 58 | 2 | | |
| 100 | 6 | | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT ON (customer_id) customer_id, store_id | |
FROM rental; | |
/* | |
|customer_id|store_id| | |
|-----------|--------| | |
| 58 | 2 | | |
| 100 | 4 | | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT(customer_id), store_id | |
FROM rental_example; | |
/* | |
|customer_id|store_id| | |
|-----------|--------| | |
| 100 | 4 | | |
| 100 | 6 | | |
| 58 | 2 | | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT customer_id, store_id | |
FROM rental_example; | |
/* | |
|customer_id|store_id| | |
|-----------|--------| | |
| 100 | 4 | | |
| 100 | 6 | | |
| 58 | 2 | | |
*/ |
NewerOlder