synapse 0.2.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/.mailmap +3 -0
- data/LICENSE.txt +2 -2
- data/Makefile +6 -0
- data/README.md +42 -13
- data/bin/synapse +29 -21
- data/config/hostheader_test.json +71 -0
- data/config/svcdir_test.json +46 -0
- data/config/synapse.conf.json +26 -32
- data/config/synapse_services/service1.json +24 -0
- data/config/synapse_services/service2.json +24 -0
- data/lib/synapse.rb +39 -24
- data/lib/synapse/base.rb +1 -1
- data/lib/synapse/haproxy.rb +579 -22
- data/lib/synapse/log.rb +24 -0
- data/lib/synapse/service_watcher.rb +10 -6
- data/lib/synapse/service_watcher/base.rb +33 -11
- data/lib/synapse/service_watcher/dns.rb +28 -20
- data/lib/synapse/service_watcher/docker.rb +108 -0
- data/lib/synapse/service_watcher/ec2tag.rb +1 -1
- data/lib/synapse/service_watcher/zookeeper.rb +25 -28
- data/lib/synapse/version.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/synapse.gemspec +2 -3
- metadata +15 -25
- data/Vagrantfile +0 -112
- data/chef/converge +0 -4
- data/chef/cookbooks/lxc/recipes/default.rb +0 -2
- data/chef/cookbooks/synapse/attributes/default.rb +0 -1
- data/chef/cookbooks/synapse/recipes/default.rb +0 -6
- data/chef/run.json +0 -8
- data/chef/run.rb +0 -2
- data/client/.RData +0 -0
- data/client/.Rhistory +0 -294
- data/client/bench_rewrite_config.dat +0 -2013
- data/client/benchmark-client.iml +0 -20
- data/client/pom.xml +0 -45
- data/client/src/main/java/ClientArsch.java +0 -68
- data/client/src/main/java/META-INF/MANIFEST.MF +0 -3
- data/haproxy.pid +0 -1
- data/lib/gen-rb/endpoint_types.rb +0 -65
- data/lib/gen-rb/thrift.rb +0 -65
- data/test.sh +0 -3
data/synapse.gemspec
CHANGED
@@ -15,10 +15,9 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = ["lib"]
|
19
18
|
|
20
|
-
gem.add_runtime_dependency "zk", "~> 1.
|
21
|
-
gem.add_runtime_dependency "
|
19
|
+
gem.add_runtime_dependency "zk", "~> 1.9.2"
|
20
|
+
gem.add_runtime_dependency "docker-api", "~> 1.7.2"
|
22
21
|
|
23
22
|
gem.add_development_dependency "rspec"
|
24
23
|
gem.add_development_dependency "pry"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zk
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.9.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,15 +26,15 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.9.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: docker-api
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 1.7.2
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 1.7.2
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rspec
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,37 +100,28 @@ extensions: []
|
|
100
100
|
extra_rdoc_files: []
|
101
101
|
files:
|
102
102
|
- .gitignore
|
103
|
+
- .mailmap
|
103
104
|
- .rspec
|
104
105
|
- Gemfile
|
105
106
|
- Gemfile.lock
|
106
107
|
- LICENSE.txt
|
108
|
+
- Makefile
|
107
109
|
- README.md
|
108
110
|
- Rakefile
|
109
|
-
- Vagrantfile
|
110
111
|
- bin/synapse
|
111
|
-
-
|
112
|
-
-
|
113
|
-
- chef/cookbooks/synapse/attributes/default.rb
|
114
|
-
- chef/cookbooks/synapse/recipes/default.rb
|
115
|
-
- chef/run.json
|
116
|
-
- chef/run.rb
|
117
|
-
- client/.RData
|
118
|
-
- client/.Rhistory
|
119
|
-
- client/bench_rewrite_config.dat
|
120
|
-
- client/benchmark-client.iml
|
121
|
-
- client/pom.xml
|
122
|
-
- client/src/main/java/ClientArsch.java
|
123
|
-
- client/src/main/java/META-INF/MANIFEST.MF
|
112
|
+
- config/hostheader_test.json
|
113
|
+
- config/svcdir_test.json
|
124
114
|
- config/synapse.conf.json
|
125
|
-
-
|
126
|
-
-
|
127
|
-
- lib/gen-rb/thrift.rb
|
115
|
+
- config/synapse_services/service1.json
|
116
|
+
- config/synapse_services/service2.json
|
128
117
|
- lib/synapse.rb
|
129
118
|
- lib/synapse/base.rb
|
130
119
|
- lib/synapse/haproxy.rb
|
120
|
+
- lib/synapse/log.rb
|
131
121
|
- lib/synapse/service_watcher.rb
|
132
122
|
- lib/synapse/service_watcher/base.rb
|
133
123
|
- lib/synapse/service_watcher/dns.rb
|
124
|
+
- lib/synapse/service_watcher/docker.rb
|
134
125
|
- lib/synapse/service_watcher/ec2tag.rb
|
135
126
|
- lib/synapse/service_watcher/zookeeper.rb
|
136
127
|
- lib/synapse/version.rb
|
@@ -139,7 +130,6 @@ files:
|
|
139
130
|
- spec/support/config.rb
|
140
131
|
- spec/support/minimum.conf.yaml
|
141
132
|
- synapse.gemspec
|
142
|
-
- test.sh
|
143
133
|
homepage: ''
|
144
134
|
licenses: []
|
145
135
|
post_install_message:
|
data/Vagrantfile
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
this_dir = File.dirname(File.expand_path __FILE__)
|
5
|
-
|
6
|
-
Vagrant::Config.run do |config|
|
7
|
-
# All Vagrant configuration is done here. The most common configuration
|
8
|
-
# options are documented and commented below. For a complete reference,
|
9
|
-
# please see the online documentation at vagrantup.com.
|
10
|
-
|
11
|
-
# Every Vagrant virtual environment requires a box to build off of.
|
12
|
-
config.vm.box = "precise64"
|
13
|
-
|
14
|
-
# The url from where the 'config.vm.box' box will be fetched if it
|
15
|
-
# doesn't already exist on the user's system.
|
16
|
-
# config.vm.box_url = "http://domain.com/path/to/above.box"
|
17
|
-
|
18
|
-
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
19
|
-
|
20
|
-
# Boot with a GUI so you can see the screen. (Default is headless)
|
21
|
-
# config.vm.boot_mode = :gui
|
22
|
-
|
23
|
-
# Assign this VM to a host-only network IP, allowing you to access it
|
24
|
-
# via the IP. Host-only networks can talk to the host machine as well as
|
25
|
-
# any other machines on the same network, but cannot be accessed (through this
|
26
|
-
# network interface) by any external networks.
|
27
|
-
# config.vm.network :hostonly, "192.168.33.10"
|
28
|
-
|
29
|
-
# Assign this VM to a bridged network, allowing you to connect directly to a
|
30
|
-
# network using the host's network device. This makes the VM appear as another
|
31
|
-
# physical device on your network.
|
32
|
-
# config.vm.network :bridged
|
33
|
-
|
34
|
-
# Forward a port from the guest to the host, which allows for outside
|
35
|
-
# computers to access the VM, whereas host only networking does not.
|
36
|
-
# config.vm.forward_port 80, 8080
|
37
|
-
|
38
|
-
# Share an additional folder to the guest VM. The first argument is
|
39
|
-
# an identifier, the second is the path on the guest to mount the
|
40
|
-
# folder, and the third is the path on the host to the actual folder.
|
41
|
-
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
|
42
|
-
|
43
|
-
config.vm.share_folder 'this_dir', '/this_dir', this_dir
|
44
|
-
|
45
|
-
# Enable provisioning with Puppet stand alone. Puppet manifests
|
46
|
-
# are contained in a directory path relative to this Vagrantfile.
|
47
|
-
# You will need to create the manifests directory and a manifest in
|
48
|
-
# the file base.pp in the manifests_path directory.
|
49
|
-
#
|
50
|
-
# An example Puppet manifest to provision the message of the day:
|
51
|
-
#
|
52
|
-
# # group { "puppet":
|
53
|
-
# # ensure => "present",
|
54
|
-
# # }
|
55
|
-
# #
|
56
|
-
# # File { owner => 0, group => 0, mode => 0644 }
|
57
|
-
# #
|
58
|
-
# # file { '/etc/motd':
|
59
|
-
# # content => "Welcome to your Vagrant-built virtual machine!
|
60
|
-
# # Managed by Puppet.\n"
|
61
|
-
# # }
|
62
|
-
#
|
63
|
-
# config.vm.provision :puppet do |puppet|
|
64
|
-
# puppet.manifests_path = "manifests"
|
65
|
-
# puppet.manifest_file = "base.pp"
|
66
|
-
# end
|
67
|
-
|
68
|
-
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
69
|
-
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
70
|
-
# some recipes and/or roles.
|
71
|
-
#
|
72
|
-
config.vm.provision :chef_solo do |chef|
|
73
|
-
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
74
|
-
# chef.roles_path = "../my-recipes/roles"
|
75
|
-
# chef.data_bags_path = "../my-recipes/data_bags"
|
76
|
-
# chef.add_recipe "mysql"
|
77
|
-
# chef.add_role "web"
|
78
|
-
|
79
|
-
# You may also specify custom JSON attributes:
|
80
|
-
# chef.json = { :mysql_password => "foo" }
|
81
|
-
|
82
|
-
chef.cookbooks_path = File.join(this_dir, "chef/cookbooks")
|
83
|
-
chef.add_recipe "synapse"
|
84
|
-
end
|
85
|
-
|
86
|
-
# Enable provisioning with chef server, specifying the chef server URL,
|
87
|
-
# and the path to the validation key (relative to this Vagrantfile).
|
88
|
-
#
|
89
|
-
# The Opscode Platform uses HTTPS. Substitute your organization for
|
90
|
-
# ORGNAME in the URL and validation key.
|
91
|
-
#
|
92
|
-
# If you have your own Chef Server, use the appropriate URL, which may be
|
93
|
-
# HTTP instead of HTTPS depending on your configuration. Also change the
|
94
|
-
# validation key to validation.pem.
|
95
|
-
#
|
96
|
-
# config.vm.provision :chef_client do |chef|
|
97
|
-
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
98
|
-
# chef.validation_key_path = "ORGNAME-validator.pem"
|
99
|
-
# end
|
100
|
-
#
|
101
|
-
# If you're using the Opscode platform, your validator client is
|
102
|
-
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
103
|
-
#
|
104
|
-
# IF you have your own Chef Server, the default validation client name is
|
105
|
-
# chef-validator, unless you changed the configuration.
|
106
|
-
#
|
107
|
-
# chef.validation_client_name = "ORGNAME-validator"
|
108
|
-
|
109
|
-
Vagrant::Config.run do |config|
|
110
|
-
config.vm.provision :shell, :path => "test.sh"
|
111
|
-
end
|
112
|
-
end
|
data/chef/converge
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
default.synapse.dir = '/opt/synapse'
|
data/chef/run.json
DELETED
data/chef/run.rb
DELETED
data/client/.RData
DELETED
Binary file
|
data/client/.Rhistory
DELETED
@@ -1,294 +0,0 @@
|
|
1
|
-
plot(accepted_denied$x, accepted_denied$y.y / (accepted_denied$y.x + accepted_denied$y.y), type="l", col="blue", xlab="Impressions", ylab="N_denied / N_accepted", main="Denied / accepted ratio")
|
2
|
-
library(ggplot2)
|
3
|
-
# Search radius (25mi is the default)
|
4
|
-
R <- 25.0
|
5
|
-
# Blended sort radius, based on bbox
|
6
|
-
BLENDED_R <- 16.39
|
7
|
-
# Distance is counted in increments of 0.1mi (old code)
|
8
|
-
MILES_INCR <- 0.1
|
9
|
-
# Take n samples
|
10
|
-
RESO_SAMPLES <- 50
|
11
|
-
# Or top n by rank
|
12
|
-
RANK_TOP_N <- 50
|
13
|
-
sf <- subset(read.table("in/sf_points_rank.2012-03-06.csv", sep="\t", header=TRUE), !duplicated(rank))
|
14
|
-
resos <- read.table("in/resos_3months_out.2012-03-07.csv", sep=",", header=TRUE)
|
15
|
-
sf_resos <- merge(sf, resos, by="hosting_id")
|
16
|
-
# Take random samples
|
17
|
-
sf_resos <- sf_resos[sample(1:nrow(sf_resos), RESO_SAMPLES, replace=FALSE),]
|
18
|
-
# Take top n
|
19
|
-
# sf_resos <- subset(sf_resos, rank > 0 & rank <= RANK_TOP_N)
|
20
|
-
## Additonal values
|
21
|
-
sf_resos$d_R <- sf_resos$distance / R
|
22
|
-
sf_resos$o_1 <- sf_resos$nights_1month / 31
|
23
|
-
sf_resos$o_2 <- sf_resos$nights_2month / 62
|
24
|
-
sf_resos$o_3 <- sf_resos$nights_3month / 93
|
25
|
-
for (i in 1:nrow(sf_resos)) {
|
26
|
-
# Make log work. < 1 point are all treated as equally bad
|
27
|
-
if (sf_resos$points[i] < 1) {
|
28
|
-
sf_resos$log_p[i] = 0.0
|
29
|
-
}
|
30
|
-
else {
|
31
|
-
sf_resos$log_p[i] <- log10(sf_resos$points[i])
|
32
|
-
}
|
33
|
-
}
|
34
|
-
# Weights
|
35
|
-
W_p <- 0.3 # Note: points aren't normalized. The max is around 2000, so 0.3 * log10() gives just under 1.0
|
36
|
-
W_d <- -0.6
|
37
|
-
W_o <- -0.2
|
38
|
-
sf_resos$weighted_points <- W_p * sf_resos$log_p
|
39
|
-
sf_resos$weighted_distance <- W_d * sf_resos$d_R
|
40
|
-
sf_resos$weighted_occupancy <- W_o * sf_resos$o_1
|
41
|
-
sf_resos$rank2 <- sf_resos$weighted_points + sf_resos$weighted_distance + sf_resos$weighted_occupancy
|
42
|
-
# min <- min(sf_resos$rank2)
|
43
|
-
# sf_resos$rank2 <- sf_resos$rank2 - min
|
44
|
-
MAX_POINTS <- max(sf$points)
|
45
|
-
## normalize
|
46
|
-
graph_rank <- sf_resos$rank2
|
47
|
-
d_R <- data.frame(metric=factor("d_R"), rank=factor(graph_rank), value=sf_resos$distance / R)
|
48
|
-
o_1 <- data.frame(metric=factor("o_1"), rank=factor(graph_rank), value=sf_resos$nights_1month / 31)
|
49
|
-
o_2 <- data.frame(metric=factor("o_2"), rank=factor(graph_rank), value=sf_resos$nights_2month / 62)
|
50
|
-
o_3 <- data.frame(metric=factor("o_3"), rank=factor(graph_rank), value=sf_resos$nights_3month / 93)
|
51
|
-
weighted_points <- data.frame(metric=factor("weighted_points"), rank=factor(graph_rank), value=sf_resos$weighted_points)
|
52
|
-
weighted_distance <- data.frame(metric=factor("weighted_distance"), rank=factor(graph_rank), value=sf_resos$weighted_distance)
|
53
|
-
weighted_occupancy <- data.frame(metric=factor("weighted_occupancy"), rank=factor(graph_rank), value=sf_resos$weighted_occupancy)
|
54
|
-
# TODO there should be a better way
|
55
|
-
old_points <- data.frame(metric=factor("old_points"), rank=factor(graph_rank), value=sf_resos$points)
|
56
|
-
old_blended <- data.frame(metric=factor("old_blended"), rank=factor(graph_rank), value=sf_resos$points)
|
57
|
-
old_distance <- data.frame(metric=factor("old_distance"), rank=factor(graph_rank), value=sf_resos$distance * 500)
|
58
|
-
log_p <- data.frame(metric=factor("log_p"), rank=factor(graph_rank), value=sf_resos$points)
|
59
|
-
for (i in 1:nrow(log_p)) {
|
60
|
-
# Make log work. < 1 point are all treated as equally bad
|
61
|
-
if (log_p$value[i] < 1) {
|
62
|
-
log_p$value[i] = 0.0
|
63
|
-
}
|
64
|
-
else {
|
65
|
-
log_p$value[i] <- log10(log_p$value[i])
|
66
|
-
}
|
67
|
-
# Old blended
|
68
|
-
if (sf_resos$distance[i] < BLENDED_R) {
|
69
|
-
old_blended$value[i] = sf_resos$points[i]
|
70
|
-
}
|
71
|
-
else {
|
72
|
-
old_blended$value[i] = log10(sf_resos$points[i] / sf_resos$distance[i])
|
73
|
-
}
|
74
|
-
}
|
75
|
-
rank_data <- rbind(d_R, log_p, o_1, o_2, o_3)
|
76
|
-
## end normalize
|
77
|
-
old_rank_data <- rbind(old_blended, old_distance)
|
78
|
-
# ggplot(data=old_rank_data, aes(x=rank, y=value, fill=metric)) + geom_bar(position=position_dodge())
|
79
|
-
new_rank_data <- rbind(weighted_points, weighted_distance, weighted_occupancy)
|
80
|
-
filename <- sprintf("out/weighted_blend_components_W_p=%f_W_d=%f_W_o=%f.pdf", W_p, W_d, W_o)
|
81
|
-
pdf(filename)
|
82
|
-
ggplot(data=new_rank_data, aes(x=rank, y=value, fill=metric)) + geom_bar(position=position_dodge())
|
83
|
-
# ggplot(data=rank_data, aes(x=rank, y=value, fill=metric)) + geom_bar()
|
84
|
-
library(ggplot2)
|
85
|
-
# Search radius (25mi is the default)
|
86
|
-
R <- 25.0
|
87
|
-
# Blended sort radius, based on bbox
|
88
|
-
BLENDED_R <- 16.39
|
89
|
-
# Distance is counted in increments of 0.1mi (old code)
|
90
|
-
MILES_INCR <- 0.1
|
91
|
-
# Take n samples
|
92
|
-
RESO_SAMPLES <- 50
|
93
|
-
# Or top n by rank
|
94
|
-
RANK_TOP_N <- 50
|
95
|
-
sf <- subset(read.table("in/sf_points_rank.2012-03-06.csv", sep="\t", header=TRUE), !duplicated(rank))
|
96
|
-
resos <- read.table("in/resos_3months_out.2012-03-07.csv", sep=",", header=TRUE)
|
97
|
-
sf_resos <- merge(sf, resos, by="hosting_id")
|
98
|
-
# Take random samples
|
99
|
-
sf_resos <- sf_resos[sample(1:nrow(sf_resos), RESO_SAMPLES, replace=FALSE),]
|
100
|
-
# Take top n
|
101
|
-
# sf_resos <- subset(sf_resos, rank > 0 & rank <= RANK_TOP_N)
|
102
|
-
## Additonal values
|
103
|
-
sf_resos$d_R <- sf_resos$distance / R
|
104
|
-
sf_resos$o_1 <- sf_resos$nights_1month / 31
|
105
|
-
sf_resos$o_2 <- sf_resos$nights_2month / 62
|
106
|
-
sf_resos$o_3 <- sf_resos$nights_3month / 93
|
107
|
-
for (i in 1:nrow(sf_resos)) {
|
108
|
-
# Make log work. < 1 point are all treated as equally bad
|
109
|
-
if (sf_resos$points[i] < 1) {
|
110
|
-
sf_resos$log_p[i] = 0.0
|
111
|
-
}
|
112
|
-
else {
|
113
|
-
sf_resos$log_p[i] <- log10(sf_resos$points[i])
|
114
|
-
}
|
115
|
-
}
|
116
|
-
# Weights
|
117
|
-
W_p <- 0.3 # Note: points aren't normalized. The max is around 2000, so 0.3 * log10() gives just under 1.0
|
118
|
-
W_d <- -0.6
|
119
|
-
W_o <- -0.2
|
120
|
-
sf_resos$weighted_points <- W_p * sf_resos$log_p
|
121
|
-
sf_resos$weighted_distance <- W_d * sf_resos$d_R
|
122
|
-
sf_resos$weighted_occupancy <- W_o * sf_resos$o_1
|
123
|
-
sf_resos$rank2 <- sf_resos$weighted_points + sf_resos$weighted_distance + sf_resos$weighted_occupancy
|
124
|
-
# min <- min(sf_resos$rank2)
|
125
|
-
# sf_resos$rank2 <- sf_resos$rank2 - min
|
126
|
-
MAX_POINTS <- max(sf$points)
|
127
|
-
## normalize
|
128
|
-
graph_rank <- sf_resos$rank2
|
129
|
-
d_R <- data.frame(metric=factor("d_R"), rank=factor(graph_rank), value=sf_resos$distance / R)
|
130
|
-
o_1 <- data.frame(metric=factor("o_1"), rank=factor(graph_rank), value=sf_resos$nights_1month / 31)
|
131
|
-
o_2 <- data.frame(metric=factor("o_2"), rank=factor(graph_rank), value=sf_resos$nights_2month / 62)
|
132
|
-
o_3 <- data.frame(metric=factor("o_3"), rank=factor(graph_rank), value=sf_resos$nights_3month / 93)
|
133
|
-
weighted_points <- data.frame(metric=factor("weighted_points"), rank=factor(graph_rank), value=sf_resos$weighted_points)
|
134
|
-
weighted_distance <- data.frame(metric=factor("weighted_distance"), rank=factor(graph_rank), value=sf_resos$weighted_distance)
|
135
|
-
weighted_occupancy <- data.frame(metric=factor("weighted_occupancy"), rank=factor(graph_rank), value=sf_resos$weighted_occupancy)
|
136
|
-
# TODO there should be a better way
|
137
|
-
old_points <- data.frame(metric=factor("old_points"), rank=factor(graph_rank), value=sf_resos$points)
|
138
|
-
old_blended <- data.frame(metric=factor("old_blended"), rank=factor(graph_rank), value=sf_resos$points)
|
139
|
-
old_distance <- data.frame(metric=factor("old_distance"), rank=factor(graph_rank), value=sf_resos$distance * 500)
|
140
|
-
log_p <- data.frame(metric=factor("log_p"), rank=factor(graph_rank), value=sf_resos$points)
|
141
|
-
for (i in 1:nrow(log_p)) {
|
142
|
-
# Make log work. < 1 point are all treated as equally bad
|
143
|
-
if (log_p$value[i] < 1) {
|
144
|
-
log_p$value[i] = 0.0
|
145
|
-
}
|
146
|
-
else {
|
147
|
-
log_p$value[i] <- log10(log_p$value[i])
|
148
|
-
}
|
149
|
-
# Old blended
|
150
|
-
if (sf_resos$distance[i] < BLENDED_R) {
|
151
|
-
old_blended$value[i] = sf_resos$points[i]
|
152
|
-
}
|
153
|
-
else {
|
154
|
-
old_blended$value[i] = log10(sf_resos$points[i] / sf_resos$distance[i])
|
155
|
-
}
|
156
|
-
}
|
157
|
-
rank_data <- rbind(d_R, log_p, o_1, o_2, o_3)
|
158
|
-
## end normalize
|
159
|
-
old_rank_data <- rbind(old_blended, old_distance)
|
160
|
-
# ggplot(data=old_rank_data, aes(x=rank, y=value, fill=metric)) + geom_bar(position=position_dodge())
|
161
|
-
new_rank_data <- rbind(weighted_points, weighted_distance, weighted_occupancy)
|
162
|
-
filename <- sprintf("out/weighted_blend_components_W_p=%f_W_d=%f_W_o=%f.pdf", W_p, W_d, W_o)
|
163
|
-
pdf(filename)
|
164
|
-
ggplot(data=new_rank_data, aes(x=rank, y=value, fill=metric)) + geom_bar(position=position_dodge())
|
165
|
-
# ggplot(data=rank_data, aes(x=rank, y=value, fill=metric)) + geom_bar()
|
166
|
-
install.packages('e1071')
|
167
|
-
library("e1071")
|
168
|
-
?svm
|
169
|
-
data <- read.table("/Users/tobi/Projects/auto_pricing/data.csv")
|
170
|
-
data <- read.table("/Users/tobi/Projects/auto_pricing/data.csv", sep=",")
|
171
|
-
View(data)
|
172
|
-
m <- svm(data$V7, data$V1)
|
173
|
-
data <- read.table("/Users/tobi/Projects/auto_pricing/data.csv", sep=",", header=TRUE)
|
174
|
-
View(data)
|
175
|
-
m <- svm(data$country_state_city_neighborhood, data$price)
|
176
|
-
m <- svm(as.factor(data$country_state_city_neighborhood), data$price)
|
177
|
-
data_clean <- subset(data, !is.na(country_state_city_neighborhood))
|
178
|
-
m <- svm(as.factor(data$square_feet, data$price)
|
179
|
-
)
|
180
|
-
m <- svm(data$square_feet, data$price)
|
181
|
-
x <- seq(0.1, 5, by = 0.05)
|
182
|
-
y <- log(x) + rnorm(x, sd = 0.2)
|
183
|
-
fix(x)
|
184
|
-
m <- svm(x, y)
|
185
|
-
new <- predict(m, x)
|
186
|
-
plot(x, y)
|
187
|
-
points(x, log(x), col = 2)
|
188
|
-
points(x, new, col = 4)
|
189
|
-
X <- data.frame(a = rnorm(1000), b = rnorm(1000))
|
190
|
-
attach(X)
|
191
|
-
m <- svm(X)
|
192
|
-
View(X)
|
193
|
-
m <- svm(~a + b)
|
194
|
-
predict(m, t(c(0, 0)))
|
195
|
-
data <- read.table("/Users/tobi/Desktop/data.csv")
|
196
|
-
data <- read.table("/Users/tobi/Desktop/data.csv", sep="\t")
|
197
|
-
View(data)
|
198
|
-
data <- read.table("/Users/tobi/Desktop/data.csv", sep=",")
|
199
|
-
View(data)
|
200
|
-
data <- read.table("/Users/tobi/Desktop/data.csv", sep=",", header=TRUE)
|
201
|
-
View(data)
|
202
|
-
data$0
|
203
|
-
data$1
|
204
|
-
data[1]
|
205
|
-
data[0]
|
206
|
-
data[2]
|
207
|
-
plot(data[1], data[2])
|
208
|
-
plot(data[2])
|
209
|
-
plot(data[1], data[2])
|
210
|
-
plot(data[1], data[3])
|
211
|
-
library("ggplot2")
|
212
|
-
qplot
|
213
|
-
qplot(data[1], data[2])
|
214
|
-
qplot(x=data[1], y=data[2])
|
215
|
-
data <- read.table("/Users/tobi/Desktop/data.csv", sep=",", header=TRUE)
|
216
|
-
plot(data)
|
217
|
-
data <- read.table("/Users/tobi/Desktop/data.csv", sep=",", header=TRUE)
|
218
|
-
library("ggplot2")
|
219
|
-
qplot(date, fees, data=data)
|
220
|
-
qplot(date, fees, data=data, geom=c("point", "smooth"))
|
221
|
-
qplot(date, fees, data=data, geom=c("point", "smooth"), group=1)
|
222
|
-
data2011 <- read.table("/Users/tobi/Desktop/data_2011.csv", sep=",", header=TRUE)
|
223
|
-
View(data2011)
|
224
|
-
qplot(date, fees, data=data2011, geom=c("point", "smooth"), group=1)
|
225
|
-
qplot(date, fees, data=data, geom=c("point", "smooth"), group=1)
|
226
|
-
qplot(date, fees, data=data2011, geom=c("point", "smooth"), group=1)
|
227
|
-
qplot(date, fees, data=data, geom=c("point", "smooth"), group=1)
|
228
|
-
data_all <- read.table("/Users/tobi/Desktop/data_all.csv", sep=",", header=TRUE)
|
229
|
-
qplot(date, fees, data=data_all, geom=c("point", "smooth"), group=1)
|
230
|
-
data_all <- read.table("/Users/tobi/Desktop/data_2011_present.csv", sep=",", header=TRUE)
|
231
|
-
qplot(date, fees, data=data_all, geom=c("point", "smooth"), group=1)
|
232
|
-
View(data_all)
|
233
|
-
data_all <- read.table("/Users/tobi/Desktop/data_all.csv", sep=",", header=TRUE)
|
234
|
-
qplot(date, fees, data=data_all, geom=c("point", "smooth"), group=1)
|
235
|
-
library("ggplot2")
|
236
|
-
data <- read.table("~/all_posts.csv")
|
237
|
-
d <- read.tabl('statsd_data.txt')
|
238
|
-
d <- read.table('statsd_data.txt')
|
239
|
-
View(d)
|
240
|
-
r <- signif(d, 2)
|
241
|
-
View(r)
|
242
|
-
f <- fft(r)
|
243
|
-
f <- fft(r$V1)
|
244
|
-
fix(f)
|
245
|
-
plot(f)
|
246
|
-
plot(r)
|
247
|
-
describe(r)
|
248
|
-
describe(r)
|
249
|
-
summary(r)
|
250
|
-
stddev(r)
|
251
|
-
std(r)
|
252
|
-
hist(r)
|
253
|
-
hist(r$V1)
|
254
|
-
hist(d$V1)
|
255
|
-
hist(d$V1, breaks=10)
|
256
|
-
hist(d$V1, breaks=30)
|
257
|
-
hist(d$V1, breaks=20)
|
258
|
-
hist(d$V1, breaks=50)
|
259
|
-
hist(d$V1, breaks=60)
|
260
|
-
hist(d$V1, breaks=100)
|
261
|
-
hist(d$V1, breaks=50)
|
262
|
-
summary(d$V1)
|
263
|
-
setwd("~/Projects/service_router/client")
|
264
|
-
data <- read.table("bench_rewrite_config.dat")
|
265
|
-
View(data)
|
266
|
-
library("ggplot2")
|
267
|
-
qplot(data)
|
268
|
-
qplot(data, V3, geom="line")
|
269
|
-
qplot(V2, V3, data=data, geom="line")
|
270
|
-
qplot(V2, V3, data=data, geom="line", facets=V1)
|
271
|
-
qplot(V2, V3, data=data, geom="line", facets=data$V1)
|
272
|
-
qplot(V2, V3, data=data, geom="line", facets=as.factor(V1))
|
273
|
-
qplot(V2, V3, data=data, geom="line", facets=as.factor(data$V1))
|
274
|
-
qplot(V2, V3, data=data, geom="line", facets=as.factor(V1) ~ .)
|
275
|
-
qplot(V2, V3, data=data, geom="line", facets=V1 ~ .)
|
276
|
-
qplot(V2, V3, data=data, geom="line", colour=V1 ~ .)
|
277
|
-
qplot(V2, V3, data=data, geom="line", colour=V1)
|
278
|
-
qplot(V2, V3, data=data, geom="line", colour=V1, ylim=c(0, 9999))
|
279
|
-
qplot(V2, V3, data=data, geom="line", colour=V1, ylim=c(999, 9999))
|
280
|
-
qplot(V2, V3, data=data, geom="line", colour=V1, ylim=c(1000, 6000))
|
281
|
-
qplot(V2, V3, data=data, geom="line", colour=V1, ylim=c(1000, 5000))
|
282
|
-
qplot(V2, V3, data=data, geom="line", colour=as.factor(V1), ylim=c(1000, 5000))
|
283
|
-
qplot(V2, V3, data=data, colour=as.factor(V1), ylim=c(1000, 5000))
|
284
|
-
data <- read.table("bench_rewrite_config.dat")
|
285
|
-
qplot(V2, V3, data=data, colour=as.factor(V1), ylim=c(1000, 5000))
|
286
|
-
qplot(V2, V3, data=data, colour=as.factor(V1))
|
287
|
-
qplot(V2, V3, data=data[10:], colour=as.factor(V1))
|
288
|
-
qplot(V2, V3, data=data[10], colour=as.factor(V1))
|
289
|
-
qplot(V2, V3, data=data[10], colour=as.factor(V1))
|
290
|
-
qplot(V2, V3, data=data, colour=as.factor(V1), ylim=c(1000, 25000))
|
291
|
-
qplot(V2, V3, data=data, colour=as.factor(V1), ylim=c(1000, 20000))
|
292
|
-
data <- read.table("bench_rewrite_config.dat")
|
293
|
-
qplot(V2, V3, data=data, colour=as.factor(V1), ylim=c(1000, 20000))
|
294
|
-
qplot(V2, V3, data=data, colour=as.factor(V1), ylim=c(1000, 20000))
|