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
""" | |
This is an adjusted version of the following file: https://github.com/outerbounds/dsbook/blob/main/chapter-3/classifier_predict.py | |
""" | |
from metaflow import FlowSpec, step, Flow, Parameter, JSONType, project, conda_base | |
@project(name="dummy_example") | |
@conda_base(python="3.8.13", libraries={"pandas": "1.5", "scikit-learn": "1.1.2"}) | |
class ClassifierPredictFlow(FlowSpec): |
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
""" | |
This is an adjusted version of the following file: https://github.com/outerbounds/dsbook/blob/main/chapter-3/classifier_train.py | |
""" | |
from metaflow import FlowSpec, step, project, conda_base | |
@project(name="dummy_example") | |
@conda_base(python="3.8.13", libraries={"pandas": "1.5", "scikit-learn": "1.1.2"}) | |
class ClassifierTrainFlow(FlowSpec): |
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
[tool.poetry] | |
name = "test" | |
version = "0.1.0" | |
description = "Test" | |
authors = ["Test"] | |
[tool.poetry.dependencies] | |
python = "3.8.x" | |
pandas = "*" |
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
df = data.frame(x = c("Q1", "Q2", "Q3", "Q4", "Q1", "Q2", "Q3", "Q4"), | |
y = c(1000, 2000, 4000, 8000, 500, 1000, 2000, 4000), | |
type = c(rep("revenue", 4), rep("cost", 4))) | |
ggplot(data = df, aes(x = x, y = y, fill = type)) + | |
geom_col(position = "dodge", alpha = 0.8) + | |
scale_fill_manual(values = c("grey", "steelblue4")) + | |
labs(title = "Revenue and Costs by Quarter [in $1M]", y = "Revenue", x = "Quarter") + | |
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) |
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
df = data.frame(x = c("Q1", "Q2", "Q3", "Q4"), | |
y = c(1000, 2000, 4000, 8000)) | |
ggplot(data = df, aes(x = x, y = y)) + | |
geom_col(fill = "steelblue4", alpha = 0.8) + | |
labs(title = "Revenue by Quarter [in $1M]", y = "Revenue", x = "Quarter") + | |
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) |
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
df = ggplot2::diamonds # data frame with 1 character/factor variable | |
ggplot(data = df, aes(x = cut, fill = color)) + | |
geom_bar(position = "stack", alpha = 0.8) + # alternative: position = "dodge" | |
labs(title = "Number of Diamonds by Cut and Color", y = "Count", x = "Cut") + | |
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) |
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
df = ggplot2::diamonds # data frame with 1 character or factor variable | |
ggplot(data = df, aes(x = cut)) + | |
geom_bar(fill = "steelblue4", alpha = 0.8) + | |
labs(title = "Number of Diamonds by Cut", y = "Count", x = "Cut") + | |
theme_bw() + theme(plot.title = element_text(hjust = 0.5)) |
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
par(mfrow=c(5,2), mar=c(2,2,2,2)) | |
curve(sin(x), from = -10, to = 10, main = "sin(x)") | |
curve(sinpi(x), from = -10, to = 10, main = "sin(pi*x)") | |
curve(sinh(x), from = -10, to = 10, main = "sinh(x)") | |
curve(asinh(x), from = -10, to = 10, main = "asinh(x)") | |
curve(cos(x), from = -10, to = 10, main = "cos(x)") | |
curve(cospi(x), from = -10, to = 10, main = "cos(pi*x)") | |
curve(cosh(x), from = -10, to = 10, main = "cosh(x)") | |
curve(acosh(x), from = -10, to = 10, main = "acosh(x)") | |
curve(tan(x), from = -10, to = 10, main = "tan(x)") |
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
par(mfrow=c(5,2), mar=c(2,2,2,2)) | |
curve(1 / (1 + exp(-x)), from = -10, to = 10, main = "sigmoid(x)") | |
curve(10 / (1 + exp(-x)), from = -10, to = 10, main = "10*sigmoid(x)") | |
curve(tanh(x), from = -10, to = 10, main = "tanh(x)") | |
curve(exp(x) / sum(exp(x)), from = -10, to = 10, main = "softmax(x)") | |
curve(pmax(0, x), from = -10, to = 10, main = "rectifier(x)") | |
curve(log(1 + exp(x)), from = -10, to = 10, main = "softplus(x)") | |
curve(sign(x), from = -10, to = 10, main = "sign(x)") | |
curve(floor(x), from = -10, to = 10, main = "floor(x)") | |
curve(round(x), from = -10, to = 10, main = "round(x)") |
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
par(mfrow=c(5,2), mar=c(2,2,2,2)) | |
curve(factorial(x), from = -10, to = 10, main = "x!") | |
curve(2^x, from = -10, to = 10, main = "2^x") | |
curve(1/sqrt(x), from = -10, to = 10, main = "1/x^(1/2)") | |
curve(exp(-x), from = -10, to = 10, main = "e^(-x)") | |
curve(log(x), from = -10, to = 10, main = "ln(x)") | |
curve(exp(x), from = -10, to = 10, main = "e^x") | |
curve(log2(x), from = -10, to = 10, main = "log2(x)") | |
curve(log10(x), from = -10, to = 10, main = "log10(x)") | |
curve(x*log(x), from = -10, to = 10, main = "x*ln(x)") |
NewerOlder