def set_data(self, data):
        self.data = data
        if self.data is not None:
            for type_, names in [
                (data.relation.row_type, data.relation.row_names),
                (data.relation.col_type, data.relation.col_names)
            ]:
                if type_.name == "Actors":
                    self.row_type = type_
                    self.row_names = names
                    self.relation_name = "prefer"
                    self.matrix, self.genres = movielens.actor_genre_matrix(
                        actors=self.row_names)
                    break
                elif type_.name == "Movies":
                    self.row_type = type_
                    self.row_names = names
                    self.relation_name = "fit in"
                    self.matrix, self.genres = movielens.movie_concept_matrix(
                        self.row_names, concept="genre")
                    break
            else:
                raise ValueError(
                    "Can produce genres only for movies or actors.")

            self.update_genres()
            self.send_output()
    def send_output(self):
        if self.movies is not None:
            movie_actor_mat, actors = movielens.movie_concept_matrix(self.movies, concept="actor",
                                                                     actors=self.percent)
            actor_actor_mat = movielens.actor_matrix(movie_actor_mat)

            movies_actors = fusion.Relation(movie_actor_mat.T, name='play in',
                                            row_type=movielens.ObjectType.Actors, row_names=actors,
                                            col_type=movielens.ObjectType.Movies, col_names=self.movies)
            self.send(MOVIE_ACTORS, Relation(movies_actors))

            actors_actors = fusion.Relation(actor_actor_mat, name='costar with',
                                            row_type=movielens.ObjectType.Actors, row_names=actors,
                                            col_type=movielens.ObjectType.Actors, col_names=actors)
            self.send(ACTORS_ACTORS, Relation(actors_actors))
Beispiel #3
0
    def send_output(self):
        if self.movies is not None:
            movie_actor_mat, actors = movielens.movie_concept_matrix(self.movies, concept="actor",
                                                                     actors=self.percent)
            actor_actor_mat = movielens.actor_matrix(movie_actor_mat)

            movies_actors = fusion.Relation(movie_actor_mat.T, name='play in',
                                            row_type=movielens.ObjectType.Actors, row_names=actors,
                                            col_type=movielens.ObjectType.Movies, col_names=self.movies)
            self.Outputs.movie_actors.send(Relation(movies_actors))

            actors_actors = fusion.Relation(actor_actor_mat, name='costar with',
                                            row_type=movielens.ObjectType.Actors, row_names=actors,
                                            col_type=movielens.ObjectType.Actors, col_names=actors)
            self.Outputs.actors_actors.send(Relation(actors_actors))
    def set_data(self, data):
        self.data = data
        if self.data is not None:
            for type_, names in [(data.relation.row_type, data.relation.row_names),
                                 (data.relation.col_type, data.relation.col_names)]:
                if type_.name == "Actors":
                    self.row_type = type_
                    self.row_names = names
                    self.relation_name = "prefer"
                    self.matrix, self.genres = movielens.actor_genre_matrix(actors=self.row_names)
                    break
                elif type_.name == "Movies":
                    self.row_type = type_
                    self.row_names = names
                    self.relation_name = "fit in"
                    self.matrix, self.genres = movielens.movie_concept_matrix(self.row_names, concept="genre")
                    break
            else:
                raise ValueError("Can produce genres only for movies or actors.")

            self.update_genres()
            self.send_output()