Commit d74fd3eb authored by Harsh's avatar Harsh

added new files

parents
def collapse(L):
new_L = []
L = (list(map(lambda x: list(map(lambda y: new_L.append(y), x)), L)))
s = ' '.join(new_L)
return s
\ No newline at end of file
from itertools import islice
def nList(L,n):
m=[]
z=len(L)
for i in range (0, n):
p=list(islice(L,i,z,n))
m.append(p)
return m
\ No newline at end of file
def genPrime(N):
start = list(map(lambda x: x, list(range(2, N))))
multi = list(map(lambda x: list(filter(lambda y: y % x == 0 and y > x, start)), start))
new_multi = []
multi = (list(map(lambda x: list(map(lambda y: new_multi.append(y), x)), multi)))
new_multi = set(new_multi)
primes = list(filter(lambda x: x not in new_multi, start))
return primes
\ No newline at end of file
def fib():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
\ No newline at end of file
from numpy import *
import csv
import math
from numpy.linalg import inv
def closedForm():
crim = []
zn = []
indus = []
chas = []
nox2 = []
rm2 = []
age = []
dis = []
lnrad = []
tax = []
ptr = []
b = []
lnstat = []
y = []
c = 0
with open("train.csv") as f:
csvReader = csv.reader(f)
for r in csvReader:
c = c+1
if c == 1:
continue
crim.append(float(r[1]))
zn.append(float(r[2]))
indus.append(float(r[3]))
chas.append(float(r[4]))
nox2.append(float(r[5])**2)
rm2.append(float(r[6])**2)
age.append(float(r[7]))
dis.append(float(r[8]))
lnrad.append(log(float(r[9])))
tax.append(float(r[10]))
ptr.append(float(r[11]))
b.append(float(r[12]))
lnstat.append(log(float(r[13])))
y.append(float(r[14]))
crim = array(crim)
zn = array(zn)
indus = array(indus)
chas = array(chas)
nox2 = array(nox2)
rm2 = array(rm2)
age = array(age)
dis = array(dis)
lnrad = array(lnrad)
tax = array(tax)
ptr = array(ptr)
b = array(b)
lnstat = array(lnstat)
y = array(y)
on = ones(400)
x = column_stack((on,crim,zn,indus,chas,nox2,rm2,age,dis,lnrad,tax,ptr,b,lnstat))
xtranspose = x.T
xxt = dot(xtranspose,x)
xxtinv = inv(xxt)
prod2 = dot(xxtinv,xtranspose)
finalprod = dot(prod2,y)
return finalprod
\ No newline at end of file
harshcse
---------------------
Team HuffleClaw
---------------------
Roll no.s - 160050011, 160050012, 160010056
Contributions :-
160050011 - 1, 3
160050012 - 2, 4
160010056 - 5
Citations :-
1. https://docs.python.org/3/library/index.html
2. https://stackoverflow.com/questions/37418611/map-convert-a-nested-for-loop-to-map-equivalent
3. https://stackoverflow.com/a/14753067
4. https://pythonspot.com/en/reading-csv-files-in-python/
5. https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.inv.html
6. https://stackoverflow.com/questions/20151141/how-to-get-length-of-a-list-of-lists-in-python
7. https://www.programiz.com/python-programming/anonymous-function
8. https://pymotw.com/2/itertools/
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment