Skip to content

Instantly share code, notes, and snippets.

View Thomascountz's full-sized avatar
💃
LGTM!

Thomas Countz Thomascountz

💃
LGTM!
View GitHub Profile
@Thomascountz
Thomascountz / CODE_OF_CONDUCT.md
Created November 30, 2018 02:22
Code of Conduct for Commons Labs

Commons Labs Code of Conduct

1. Purpose

A primary goal of Commons Labs is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).

This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior.

We invite all those who participate in Commons Labs to help us create safe and positive experiences for everyone.

@Thomascountz
Thomascountz / 2dtransformations.ipynb
Created November 19, 2018 01:14
2DTransformations.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Thomascountz
Thomascountz / keybase.md
Created November 13, 2018 20:48
Keybase Proof

Keybase proof

I hereby claim:

  • I am thomascountz on github.
  • I am thomascountz (https://keybase.io/thomascountz) on keybase.
  • I have a public key ASC8Ou3Vfx6fn6eZBfQaeqzDbC6ob2qkyJi9Qjxa6P7IPgo

To claim this, I am signing this object:

@Thomascountz
Thomascountz / ruby_linear_model.rb
Last active October 27, 2018 17:21
Simple Linear Model ML
class LinearModel
attr_reader :slope, :y_intercept
def initialize(learning_rate = 0.1, epoch = 100000)
# Initialize y_intercept & slope
@y_intercept = 0
@slope = 1
# How much will the error affect the change in parameters
@learning_rate = learning_rate
errors = dataset.map do |data_point|
prediction = string_length_predictor.predict(data_point[:input])
prediction - data_point[:output]
end
#=> [4.50, -0.75, 1.35, 2.50]
square_errors = errors.map { |error| error ** 2 }
#=> [20.25, 0.56, 1.82, 6.25]
mean_square_error = square_errors.inject(&:+) / errors.length
predict(4)
#=> 8
class LinearModel
def initialize(y_intercept, slope)
@y_intercept = y_intercept
@slope = slope
end
def predict(x)
return @slope * x + @y_intercept
end
end
dataset = [
{input: 0.50, output: 56},
{input: 0.85, output: 119},
{input: 0.99, output: 140},
{input: 1.30, output: 190}
]
def predict(x)
return x * 2
end
dataset = [
{input: 1, output: 2},
{input: 2, output: 4},
{input: 3, output: 6},
]