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
RSpec.configure do |config| | |
config.before(:suite) do | |
DatabaseCleaner.clean_with(:truncation) | |
end | |
config.before(:each) do | |
DatabaseCleaner.strategy = :transaction | |
end | |
config.before(:each, js: true) do |
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 | |
X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]) | |
Y = np.array([1, 1, 1, 2, 2, 2]) | |
from sklearn.naive_bayes import GaussianNB | |
clf = GaussianNB() | |
clf.fit(X, Y) | |
print(clf.predict([[-0.8, -1]])) | |
clf_pf = GaussianNB() |
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
# định nghĩa 1 function không nhận đầu vào, luôn trả về True, gán nó cho biến ``f`` | |
In [1]: f = lambda: True | |
# gọi hàm này và nó trả về giá trị True | |
In [2]: f() | |
Out[2]: True | |
# định nghĩa 1 function trả về số lớn hớn số đã cho 1 đơn vị, gán function này cho biến f | |
In [3]: f = lambda x: x + 1 | |
# hàm này cần 1 argument, câu gọi hàm dưới đây bị thiếu argument | |
In [4]: f() | |
--------------------------------------------------------------------------- |
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
>>> def dummy(): | |
... print "You won't see me when created" | |
... yield 1 | |
... print "You didn't see me" | |
... yield 2 | |
... print "Bye bye" | |
... | |
>>> gen = dummy() | |
>>> gen.next() | |
You won't see me when created |
NewerOlder