Skip to content

Commit

Permalink
GB in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
serenaczx committed Jun 25, 2024
1 parent a053d2b commit 2badf64
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions GB/LinearRegression/linear_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import numpy as np
from utils.features import prepare_for_training

class LinearRegression:
def __init__(self,data,labels,polynomial_degree = 0,sinusoid_degree = 0,normalize_data = 0):
(data_processed, features_mean, features_deviation) = prepare_for_training(data,polynomial_degree = 0,sinusoid_degree = 0,normalize_data = 0)
#data_processed = 处理后的数据; features_mean = 数据均值; features_deviation = 数据标准差

self.data = data_processed
self.labels = labels
self.features_mean = features_mean
self.features_deviation = features_deviation
self.polynomial_degree = polynomial_degree
self.sinusoid_degree = sinusoid_degree
self.normalize_data = normalize_data

num_features = data_processed.shape[1]
self.theta = np.zeros((num_features,1))

def train(self,alpha,num_iterations = 1000):
pass
def gradient_descent(self,alpha,num_iterations):
m = self.data.shape[0]
for i in range(num_iterations):
predictions = np.dot(self.data,self.theta)
self.theta = self.theta - alpha*(1/m)*np.dot(self.data.T,predictions - self.labels)

def gradient_step(self,alpha):
m = self.data.shape[0]
predictions = np.dot(self.data,self.theta)
self.theta = self.theta - alpha*(1/m)*np.dot(self.data.T,predictions - self.labels)


Empty file added GB/_init_.py
Empty file.
Empty file added GB/features/_init_.py
Empty file.
Empty file.
Empty file.
Empty file added GB/features/normalize.py
Empty file.
Empty file.
Empty file added GB/generate_polynomials.py
Empty file.
Empty file added GB/generate_sinusoids.py
Empty file.
Empty file added GB/hypothesis/_init_.py
Empty file.
2 changes: 2 additions & 0 deletions GB/linear_regression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

print(1.7+1.4)
Empty file added GB/normalize.py
Empty file.
Empty file added GB/prepare_for_training.py
Empty file.
Empty file added GB/utils/features/_init_.py
Empty file.
Empty file.
Empty file.
Empty file added GB/utils/features/normalize.py
Empty file.
Empty file.
Empty file added GB/utils/hypothesis/_init_.py
Empty file.

0 comments on commit 2badf64

Please sign in to comment.