ModelOutput.__init__()   C
last analyzed

Complexity

Conditions 8

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 6.6666
cc 8
1
class ModelOutput(object):
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Comprehensibility Best Practice introduced by
The variable object does not seem to be defined.
Loading history...
2
    """Abstract base class for topic models.
3
4
    Ensures consistent interface across models, for base result display capabilities.
5
6
    Attributes
7
    ----------
8
    _doc_topic_matrix : mapping of document ids to weights for topic indices
9
                        matrix storing the relative topic weights for each document
10
    _topic_term_matrix : mapping of terms to each topic
11
    """
12
    def __init__(self, vectorized_corpus=None, model_func=None,
13
                 vocab=None, term_frequency=None, topic_term_matrix=None,
14
                 doc_lengths=None, doc_topic_matrix=None, **kwargs):
15
        if vectorized_corpus and model_func:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable vectorized_corpus does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable model_func does not seem to be defined.
Loading history...
16
            self._vocab = vectorized_corpus.id_term_map
17
            self._doc_lengths = vectorized_corpus.doc_lengths
18
            self._term_frequency = vectorized_corpus.term_frequency
19
            self._topic_term_matrix, self._doc_topic_matrix = model_func(
20
                                                    vectorized_corpus, **kwargs)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable kwargs does not seem to be defined.
Loading history...
21
22
        elif (vocab and term_frequency and topic_term_matrix and doc_lengths and
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable term_frequency does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable topic_term_matrix does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable vocab does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable doc_lengths does not seem to be defined.
Loading history...
23
                     doc_topic_matrix):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable doc_topic_matrix does not seem to be defined.
Loading history...
24
            self._vocab = vocab
25
            self._term_frequency = term_frequency
26
            self._topic_term_matrix = topic_term_matrix
27
            self._doc_lengths = doc_lengths
28
            self._doc_topic_matrix = doc_topic_matrix
29
        else:
30
            raise ValueError("Must provide either vectorized corpus and model func, "
31
                             "or term data and doc data.")
32
33
    @property
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable property does not seem to be defined.
Loading history...
34
    def vocab(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
35
        return self._vocab
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
36
37
    @property
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable property does not seem to be defined.
Loading history...
38
    def term_frequency(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
39
        return self._term_frequency
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
40
41
    @property
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable property does not seem to be defined.
Loading history...
42
    def topic_term_matrix(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
43
        return self._topic_term_matrix
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
44
45
    @property
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable property does not seem to be defined.
Loading history...
46
    def doc_lengths(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
47
        return self._doc_lengths
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
48
49
    @property
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable property does not seem to be defined.
Loading history...
50
    def doc_topic_matrix(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
51
        return self._doc_topic_matrix
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
52
53
54