0

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.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • Please [edit] your question and post the [*full text* of any errors or tracebacks](https://meta.stackoverflow.com/q/359146), as well as a full [mre] of your code. Don't just include a function, show us how you are calling it, including all requisite imports. You don't need to include the entire class, just the relevant parts. Supply dummy values for variables where needed. Please also include example data as formatted text, not an image. – MattDMo Apr 11 '23 at 12:49

0 Answers0