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
| |/n:+/'1_'(&^n)_n:`I$'0:"i/1" | |
| +/n@3#>n |
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
| using Pipe: @pipe | |
| getdata(file) = open(joinpath(@__DIR__, file)) do f read(f, String) end | |
| part1(data) = @pipe data |> | |
| split(_, "\n\n") |> | |
| map(l -> replace(l, "\n" => ""), _) |> | |
| map(l -> split(l, ""), _) |> | |
| map(l -> unique(l), _) |> | |
| map(l -> length(l), _) |> |
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 turicreate as tc | |
| import os | |
| current_dir = os.path.dirname(__file__) | |
| model = tc.load_model(os.path.join( | |
| current_dir, 'model/v1.model')) | |
| images = tc.load_images(os.path.join(current_dir, 'data/test')) | |
| images['predictions'] = model.predict(images) | |
| images.print_rows(num_rows=10) |
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 turicreate as tc | |
| import os | |
| current_dir = os.path.dirname(__file__) | |
| data = tc.SFrame(os.path.join(current_dir, 'data/processed/beers.sframe')) | |
| train, test = data.random_split(0.8) | |
| model = tc.image_classifier.create(train, target='label', max_iterations=100) |
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 turicreate as tc | |
| import re | |
| import os | |
| def path_as_label(path): | |
| label = re.search('(?<=raw/)(.+)?/.+$', path).group(1) | |
| label = label.replace('_', ' ') | |
| return label.title() |
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 'minitest/autorun' | |
| require 'matrix' | |
| module LinearRegression | |
| def predict(features, theta) | |
| features * theta | |
| end | |
| def cost_function(features, labels, theta) | |
| m = features.row_count |
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 normal_equation(features, labels) | |
| (features.transpose * features).inverse * features.transpose * labels | |
| end |
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
| # features is a Matrix, labels and theta are Vectors | |
| def cost_function(features, labels, theta) | |
| m = features.row_count | |
| predictions = predict(features, theta) | |
| squared_errors = (predictions - labels).map { |error| error**2 } | |
| (1.0 / (2.0 * m)) * squared_errors.reduce { |a, b| a + b } | |
| end |
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 'matrix' | |
| Matrix[[10, 1000, 10], [5, 800, 2], [12, 2500, 3]] * Vector[200,-0.1,-10] # => Vector[1800.0, 900.0, 2120.0] |
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
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| const timeFormat = "2006-01-02 15:04 MST" | |
| func main() { |
NewerOlder