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 progress_bar(current, total, what): | |
print('\r', current, "out of", total, what, end="", flush=True) |
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 decisionTreeLearning(examples, attributes, parent_examples): | |
if len(examples) == 0: | |
return pluralityValue(parent_examples) | |
# return most probable answer as there is no training data left | |
elif len(attributes) == 0: | |
return pluralityValue(examples) | |
elif (all examples classify the same): | |
return their classification | |
A = max(attributes, key(a)=importance(a, examples) |
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
zapsmall(matrix) |
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
matplot(x, y_matrix_of_columns) |
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
graphWithDensity <- function(no_vertices, dens){ | |
erdos.renyi.game(no_vertices, as.integer(no_vertices * dens), type="gnm", | |
directed = T) # Create a graph with given number of vertices and edges | |
} | |
g3 <- graphWithDensity(15, 2) | |
plot(g3) |
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
library(fitdistrplus) | |
library(lattice) | |
in_geom_fit <- fitdist(in_deg, "geom") | |
summary(in_geom_fit) | |
plot(in_geom_fit) | |
quantiles <- seq(0, 1, 0.05) | |
qqmath(~in_deg, distribution=function(p){ qgeom(p, prob = in_geom_fit$estimate)}, main="Q-Q plot against geometric distribution", xlab = "geometirc from estimate") |
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
{plot(density(in_deg), col=2) # where in_deg is a list of degrees - one obs. per verticle | |
lines(density(out_deg), col=3)} |
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
which_mutual(g5) %>% table | |
which_multiple(g5) %>% table | |
which_loop(g5) %>% table |
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
AssignAddin <- function() { | |
rstudioapi::insertText(" <- ") | |
} |
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
```{r} | |
plot(degree(g5, mode = "in"), degree(n5, mode = "out"), type = "p") | |
cor.test(degree(g5, mode = "in"), degree(g5, mode = "out")) | |
``` |
OlderNewer