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
| def calculate_decimal_values(header_present) | |
| first = true | |
| field_values = Array.new | |
| CSV.foreach(@file, :col_sep => ',') do |row| | |
| #first time through, create an array with the correct | |
| #number of columns to hold all the possible values for | |
| #each column | |
| if first | |
| row.size.times do | |
| field_values << Array.new |
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
| def similarity | |
| @similarity = @person1.keys & @person2.keys | |
| if @similarity.empty? | |
| return 0 | |
| end | |
| @sim = 0 | |
| @similarity.each do |movie| | |
| dif_squared = (@person1[movie] - @person2[movie])**2 | |
| @sim += dif_squared |
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
| def similarity | |
| @similarity = @person1.keys & @person2.keys | |
| if @similarity.empty? | |
| return 0 | |
| end | |
| sum1, sum2, sum1Sq, sum2Sq, productSum = 0, 0, 0, 0, 0 | |
| @similarity.each do |movie| | |
| sum1 += @person1[movie] | |
| sum2 += @person2[movie] |
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
| def similarity | |
| similarity = 0.0 | |
| n = 0.0 | |
| @person1.each_index do |index| | |
| if @person1[index] == 0 && @person2[index] == 1 | |
| n += 1 | |
| elsif @person1[index] == 1 && @person2[index] == 0 | |
| n += 1 | |
| elsif @person1[index] == 1 && @person2[index] == 1 | |
| similarity += 1 |
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
| def buildClusters(num_clusters) | |
| @num_clusters = num_clusters | |
| num_attributes = @data[0].length | |
| #find bounds of data | |
| data_boundaries = {} | |
| for i in 0...num_attributes | |
| boundaries = [] | |
| boundaries[0] = @data[0][i] | |
| boundaries[1] = @data[0][i] |
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
| require 'rubygems' | |
| require 'pry' | |
| require_relative 'layer.rb' | |
| class ArtificialNeuralNetwork | |
| attr_reader :output, :input | |
| #initialize with an array containing number of neurons | |
| #in each layer, including input and output | |
| def initialize(layers) |
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
| require 'rubygems' | |
| require 'yaml' | |
| require 'active_record' | |
| require 'csv' | |
| require 'pry' | |
| #require the models | |
| Dir['model/*.rb'].each {|file| require_relative file} | |
| class Compare |
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
| require 'rubygems' | |
| require 'yaml' | |
| require 'active_record' | |
| require 'csv' | |
| require 'pry' | |
| #require the models | |
| Dir['model/*.rb'].each {|file| require_relative file} | |
| class Populate |
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
| var gulp = require('gulp'), | |
| spawn = require('child_process').spawn, | |
| path = require('path'), | |
| request = require('request'), | |
| connect = require('gulp-connect'), | |
| Promise = require('promise'); | |
| var serverPort = 8080, | |
| liveReloadPort = 35729; |
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
| sealed class Either<out A, out B> | |
| class Left<out A>(val value: A): Either<A, Nothing>() | |
| class Right<out B>(val value: B): Either<Nothing, B>() |
OlderNewer