How to use surprise lib for a dataset without rating.csv file?

58 Views Asked by At

I am trying to make a recommendation system using surprise lib. I am using a data set which does not have rating.csv and instead it is a full data set including many features about movies(it does not have any information about the users). I am getting this error "could not convert string to float: 'Action Adventure Fantasy Science Fiction'" I know this is because my i don't have rating.csv but I want to know how do i can use surprise lib for my dataset.

 def loadMovie(self):
        # Look for files relative to the directory we are running from
        os.chdir(os.path.dirname(sys.argv[0]))
        ratingsDataset = 0      
        reader = Reader(line_format='user item rating timestamp', sep=',', skip_lines=1)
        self.movieID_to_name = {}
        self.name_to_movieID = {}  
        ratingsDataset = Dataset.load_from_file(self.moviesPath, reader=reader)
       
        with open(self.moviesPath, newline='', encoding='ISO-8859-1') as csvfile:
            movieReader = csv.reader(csvfile)
            next(movieReader)  #Skip header line
            for row in movieReader:
                movieID = int(row[4])
                movieName = row[18]
                self.movieID_to_name[movieID] = movieName
                self.name_to_movieID[movieName] = movieID
        return  ratingsDataset 

Please help me if you can.

0

There are 0 best solutions below