This file contains hidden or 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 collections import defaultdict | |
| import numpy as np | |
| def api_call(response_ok=True): | |
| if response_ok: | |
| return {'Released': 2010, 'Ratings': [{'Value': 98}]} | |
| else: | |
| return defaultdict(lambda: np.nan) | |
This file contains hidden or 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 warnings | |
| import statsmodels.api as sm | |
| from statsmodels.stats.outliers_influence import variance_inflation_factor | |
| def print_vif(x): | |
| """Utility for checking multicollinearity assumption | |
| :param x: input features to check using VIF. This is assumed to be a pandas.DataFrame | |
| :return: nothing is returned the VIFs are printed as a pandas series |
This file contains hidden or 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
| ("exit" to quit) Question: What market does FitBit compete in? | |
| Search Rank Squad Rank Combined Rank Answer Context | |
| 0 2.0 6.0 1.5 crowded market ... rather crowded ma... | |
| 1 7.0 1.0 1.5 oncology ...te in the oncology ... | |
| 2 8.0 3.0 3.0 streaming services market ...trate the streaming ... | |
| 3 5.0 7.0 4.0 leash ...ck a long leash. Boe... | |
| 4 4.0 9.0 5.0 iPhones ...io of new iPhones - ... | |
| 5 1.0 13.0 6.5 wearables ...hough, is wearables,... | |
| 6 9.0 5.0 6.5 murky ...'re in a "murky" mar... | |
| 7 15.0 2.0 8.0 ad market ...ce in the ad market ... |
This file contains hidden or 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 whoosh.analysis import StandardAnalyzer | |
| >>> | |
| >>> [token.text for token in StandardAnalyzer()("This is an example analysis")] |
This file contains hidden or 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
| # Experimental utility function | |
| message("--------------------------------------------------------------------------------\n") | |
| message("Overwriting `?` function with custom utility to display in memory function help.\n") | |
| message("--------------------------------------------------------------------------------\n\n") | |
| help2 = function(f, ...) { | |
| #' Extend `help()` to show in memory function documentation | |
| #' | |
| #' @details Supports python docstring-esque roxygen documentation. |
This file contains hidden or 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
| class A: | |
| def x(self): | |
| print('x: A') | |
| class B(A): | |
| def x(self): | |
| super().x() | |
| print('x: B') |
This file contains hidden or 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
| library(ggplot2) | |
| library(gganimate) | |
| library(data.table) | |
| gen_heart_y = function(x, a) { | |
| # source: https://i.imgur.com/avE8cxJ.gifv | |
| (x^2)^(1 / 3) + 0.9 * (3.3 - x^2)^(1 / 2) * sin(a * pi * x) | |
| } | |
| heart_dt_list = lapply(seq(1, 15, by = 0.1), function(a) { |
This file contains hidden or 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
| library(R6) | |
| library(ggplot2) | |
| library(uuid) | |
| options(stringsAsFactors = FALSE) | |
| branch_base = R6Class('branch_base', | |
| public = list( | |
| start_x = NA_integer_, | |
| start_y = NA_integer_, | |
| end_x = NA_integer_, |
This file contains hidden or 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
| # Create/animate fractal trees at various angles for branch splits | |
| library(gganimate) | |
| library(ggplot2) | |
| library(uuid) | |
| options(stringsAsFactors = FALSE) | |
| # create line segment from (0, 0) to (0, len) to be trunk of fractal tree | |
| create_trunk = function(len = 1) { | |
| end_point = c(0, len) |
This file contains hidden or 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
| # Create/Draw a Binary Fractal Tree | |
| library(ggplot2) | |
| library(uuid) | |
| options(stringsAsFactors = FALSE) | |
| # create line segment from (0, 0) to (0, len) to be trunk of fractal tree | |
| create_trunk = function(len = 1) { | |
| end_point = c(0, len) | |
| trunk_df = data.frame(x=c(0, 0), |