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.cross_validation import train_test_split | |
df = pd.DataFrame(np.random.randn(100, 2), columns=['x1', 'x2']) | |
df['y'] = np.random.choice([0, 1], size=len(df), p=[0.1, 0.9]) | |
train, test = train_test_split(df, test_size=0.2, stratify=df.y) | |
train.y.value_counts() | |
test.y.value_counts() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
for file in *.json | |
do | |
cat "$file" | python -m json.tool > "$file.new" | |
mv -f "$file.new" "$file" | |
done |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 bokeh.charts | |
from bokeh.models import HoverTool, ColumnDataSource | |
from bokeh.plotting import figure | |
def plot_interactive_timeseries(df, col): | |
# https://github.com/bokeh/bokeh/pull/3883 | |
hover = HoverTool(tooltips=[ | |
("y (%s)" % col, "$y{1.11}"), |
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
""" | |
Example for a colourised logging output. | |
This example uses "blessings" to handle console escape sequences. ``blessings`` | |
itself is a very harmless package in that it does not have any external | |
dependencies. And it's code-base is very clean and small. | |
The example extends the core logging formatter (logging.Formatter) and | |
colourises the complete line. This takes advantage of any upstream updates | |
related to logging. When writing this against Python 2.7, the parent code |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
{"gold_medal_winners": [{"player": "Victoria Azarenka"}], "silver_medal_winners": [{"player": "Maria Kirilenko"}], "medal": "Bronze", "discipline": "Tennis", "event": "Women's Singles Bronze Medal Match"} | |
{"gold_medal_winners": [{"player": "Serena Williams"}], "silver_medal_winners": [{"player": "Maria Sharapova"}], "medal": "Gold", "discipline": "Tennis", "event": "Women's Singles Gold Medal Match"} | |
{"gold_medal_winners": [{"country": "France"}], "silver_medal_winners": [{"country": "Spain"}], "medal": "Bronze", "discipline": "Tennis", "event": "Men's Doubles Bronze Medal Match"} | |
{"gold_medal_winners": [{"country": "United States"}], "silver_medal_winners": [{"country": "France"}], "medal": "Gold", "discipline": "Tennis", "event": "Men's Doubles Gold Medal Match"} | |
{"gold_medal_winners": [{"player": "Juan Martin del Potro"}], "silver_medal_winners": [{"player": "Novak Djokovic"}], "medal": "Bronze", "discipline": "Tennis", "event": "Men's Singles Bronze Medal Match"} | |
{"gold_medal_winners": [{"country": "Unite |