Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / linear_regressor.py
Created April 9, 2017 15:45
Linear Regressor
class LinearRegressor(Object):
def gradient_descent(self, x, y, alpha, max_iterations):
num_rows = x.shape[1] + 1
w = np.array([random.random() for item in range(num_rows)]).reshape(num_rows,1)
best_weights = []
lowest_cost = None
iter = 1
@chelseatroy
chelseatroy / learner.py
Created April 12, 2017 21:17
Autograd Regressor
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import autograd.numpy as np # Thinly-wrapped numpy
from autograd import grad as compute_grad # The only autograd function you may ever need
class learner():
def __init__(self,**args):
@chelseatroy
chelseatroy / i_never_said_this_was_finished.ipynb
Last active July 22, 2020 21:41
A first pass at data analysis on some ESG and Performance Data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chelseatroy
chelseatroy / investigating_esg_ratings_and_stock_performance.ipynb
Last active February 19, 2018 02:44
Investigating ESG Ratings and Stock Performance
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@chelseatroy
chelseatroy / certainty.py
Created March 27, 2018 03:38
Confidence Intervals
import math
from scipy.stats import t
import numpy as np
def confidence_interval_for(samples=[], confidence=0.95):
sample_size = len(samples)
degrees_freedom = sample_size - 1
outlier_tails = (1.0 - confidence) / 2.0
t_distribution_number = -1 * t.ppf(outlier_tails, degrees_freedom)
@chelseatroy
chelseatroy / certainty.py
Created March 27, 2018 03:39
Confidence Intervals for Descriptive Collections
import math
from scipy.stats import t
import numpy as np
def confidence_interval_for_collection(sample_size=[], standard_deviation=[], mean=[], confidence=0.95):
degrees_freedom = [count - 1 for count in sample_size]
outlier_tails = (1.0 - confidence) / 2.0
confidence_collection = [outlier_tails for _ in sample_size]
t_distribution_number = [-1 * t.ppf(tails, df) for tails, df in zip(confidence_collection, degrees_freedom)]
@chelseatroy
chelseatroy / distance.py
Last active March 27, 2018 03:48
T-Tests for Independent Examples
def t_test_for(num_samples_1, standard_deviation_1, mean_1, num_samples_2, standard_deviation_2, mean_2, confidence=0.95):
alpha = 1 - confidence
total_degrees_freedom = num_samples_1 + num_samples_2 - 2
t_distribution_number = -1 * t.ppf(alpha, total_degrees_freedom)
degrees_freedom_1 = num_samples_1 - 1
degrees_freedom_2 = num_samples_2 - 1
sum_of_squares_1 = (standard_deviation_1 ** 2) * degrees_freedom_1
sum_of_squares_2 = (standard_deviation_2 ** 2) * degrees_freedom_2
@chelseatroy
chelseatroy / Topic.rb
Created April 9, 2018 14:51
Topic Model
class Topic < ActiveRecord::Base
...
def applicable_formulas
[self, chapter, section, unit, *ancestors].compact.flat_map(&:formula_ids)/code>
end
end
@chelseatroy
chelseatroy / receipt_data_source_transition_spec.rb
Last active June 3, 2018 04:13
Switching Data Sources: Dual-Class Test
require 'rails_helper'
RSpec.describe ReceiptDataSourceTransition do
describe "get_receipts" do
before do
Receipt.delete_all
end
it "gets similarly structured responses from both repository and service" do
#Subjects Under Test
@chelseatroy
chelseatroy / receipt_data_source_spec.rb
Created June 3, 2018 04:10
Switching Data Sources: Repository Unit Test
require 'rails_helper'
RSpec.describe Repositories::ReceiptDataSource do
describe "get_receipts" do
before do
Receipt.delete_all
end
it "gets all receipts" do
@subject_under_test = Repositories::ReceiptDataSource.new