Skip to content

Commit

Permalink
Lots of fixes! actual database in action!
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas committed Dec 14, 2017
1 parent 0a21d33 commit 8a88d04
Show file tree
Hide file tree
Showing 29 changed files with 141,570 additions and 178 deletions.
197 changes: 75 additions & 122 deletions Final_project.ipynb

Large diffs are not rendered by default.

32 changes: 26 additions & 6 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@
"""
import numpy as np


class Moviedata:
"""Creates a database object, with functions to get information"""
def __init__(self, compo, direct, actor, busin, special, rat):
self.composers = np.genfromtxt('database/' + compo + '.csv', dtype='str', delimiter=',')
self.directors = np.genfromtxt('database/' + direct + '.csv', dtype='str', delimiter=',')
self.actors = np.genfromtxt('database/' + actor + '.csv', dtype='str', delimiter=',')
self.business = np.genfromtxt('database/' + busin + '.csv', dtype='str', delimiter=',')
splitchar = '%'
self.composers = np.genfromtxt('database/' + compo + '.csv',dtype=None, delimiter=splitchar)
self.directors = np.genfromtxt('database/' + direct + '.csv', dtype=None, delimiter=splitchar)
self.actors = np.genfromtxt('database/' + actor + '.csv', dtype =None, delimiter=splitchar)
self.business = np.genfromtxt('database/' + busin + '.csv', dtype='S20', delimiter=splitchar)
self.specials = np.genfromtxt('database/' + special + '.csv',
dtype='str', delimiter=',')
self.ratings = np.genfromtxt('database/' + rat + '.csv', dtype='str', delimiter=',')
dtype=None, delimiter=splitchar)
self.ratings = np.genfromtxt('database/' + rat + '.csv', dtype='S20', delimiter=splitchar)

self.composers = np.char.decode(self.composers)
self.directors = np.char.decode(self.directors)
self.actors = np.char.decode(self.actors)
self.business = np.chararray.decode(self.business)
self.specials = np.char.decode(self.specials)
self.ratings = np.char.decode(self.ratings)

def composer_movie(self, composer):
"""Returns a numpy array with movies with music from composer"""
Expand Down Expand Up @@ -66,3 +75,14 @@ def movie_rating(self, movie):
if len(ratings) == 0:
return 0
return max(ratings.astype(float))

def get_movies(self):
""" returns a list of all movies in dataset movies """
return self.ratings[:, 0].tolist()

print(Moviedata('valcomposers',
'valdirectors',
'valactors',
'valbusiness',
'valspecial-effects-companies',
'valratings').movie_composer('The Polar Express'))
Loading

0 comments on commit 8a88d04

Please sign in to comment.