Fixed the merge.
This commit is contained in:
parent
ccf7e878f9
commit
32f5ceb5a7
3 changed files with 0 additions and 26 deletions
|
|
@ -1,29 +1,5 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
|
|
||||||
class LinearRegression:
|
|
||||||
def __init__(self, add_bias = True)
|
|
||||||
self.add_bias = add_bias
|
|
||||||
pass
|
|
||||||
|
|
||||||
def fit(self,x,y):
|
|
||||||
if x.dim == 1:
|
|
||||||
x = x[:,None]
|
|
||||||
N = x.shape[0]
|
|
||||||
if self.add_bias:
|
|
||||||
x = np.column_stack ([x,np.ones(N)])
|
|
||||||
self.w = np.linalg.lstsq(x,y)[0]
|
|
||||||
return self
|
|
||||||
|
|
||||||
def predict(self,x)
|
|
||||||
if self.add_bias:
|
|
||||||
x = np.column_stack ([x,np.ones(N)])
|
|
||||||
yh = x@self.w
|
|
||||||
return yh
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LinearRegression:
|
class LinearRegression:
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
class LogisticRegression:
|
class LogisticRegression:
|
||||||
'''
|
'''
|
||||||
Constructor for the logistic regression with gradient descent. It uses learning rate, iteration number,
|
Constructor for the logistic regression with gradient descent. It uses learning rate, iteration number,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
class LogisticRegression:
|
class LogisticRegression:
|
||||||
'''
|
'''
|
||||||
Constructor for the logistic regression with gradient descent. It uses learning rate, iteration number,
|
Constructor for the logistic regression with gradient descent. It uses learning rate, iteration number,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue