Skip to content

Commit

Permalink
Remake of the documentation (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 committed Nov 18, 2020
1 parent 2d2f232 commit 4ca41f9
Show file tree
Hide file tree
Showing 85 changed files with 1,709 additions and 654 deletions.
37 changes: 19 additions & 18 deletions asreview/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def get_fuzzy_scores(keywords, match_strings):
Returns
-------
np.ndarray:
numpy.ndarray
Array of scores ordered in the same way as the str_list input.
"""
return token_set_ratio(keywords, match_strings)
Expand All @@ -99,7 +99,7 @@ class ASReviewData():
Arguments
---------
df: pd.DataFrame
df: pandas.DataFrame
Dataframe containing the data for the ASReview data object.
data_name: str
Give a name to the data object.
Expand Down Expand Up @@ -168,12 +168,12 @@ def slice(self, idx, by_index=True):
Arguments
---------
idx: list, np.ndarray
idx: list, numpy.ndarray
Record ids that should be kept.
Returns
-------
ASReviewData:
ASReviewData
Slice of itself.
"""
if self.df is None:
Expand Down Expand Up @@ -242,9 +242,9 @@ def from_file(cls, fp, read_fn=None, data_name=None, data_type=None):
Arguments
---------
fp: str, Path
fp: str, pathlib.Path
Read the data from this file.
read_fn: function
read_fn: callable
Function to read the file. It should return a standardized
dataframe.
data_name: str
Expand Down Expand Up @@ -300,7 +300,7 @@ def record(self, i, by_index=True):
Returns
-------
PaperRecord:
PaperRecord
The corresponding record if i was an integer, or a list of records
if i was an iterable.
"""
Expand Down Expand Up @@ -376,15 +376,16 @@ def fuzzy_find(self,
Don't return records below this threshold.
max_return: int
Maximum number of records to return.
exclude: list, np.ndarray
exclude: list, numpy.ndarray
List of indices that should be excluded in the search. You would
put papers that were already labeled here for example.
by_index: bool
If True, use internal indexing.
If False, use record ids for indexing.
Returns
-------
list:
list
Sorted list of indexes that match best the keywords.
"""
new_ranking = get_fuzzy_scores(keywords, self.match_string)
Expand Down Expand Up @@ -528,7 +529,7 @@ def prior_labels(self, state, by_index=True):
Returns
-------
np.array:
numpy.ndarray
Array of indices that have the 'initial' property.
"""
query_src = state.startup_vals()["query_src"]
Expand All @@ -552,9 +553,9 @@ def to_file(self, fp, labels=None, ranking=None):
---------
fp: str
Filepath to export to.
labels: list, np.array
labels: list, numpy.ndarray
Labels to be inserted into the dataframe before export.
ranking: list, np.array
ranking: list, numpy.ndarray
Optionally, dataframe rows can be reordered.
"""
if Path(fp).suffix in [".csv", ".CSV"]:
Expand All @@ -573,7 +574,7 @@ def to_dataframe(self, labels=None, ranking=None):
Arguments
---------
labels: list, np.ndarray
labels: list, numpy.ndarray
Current labels will be overwritten by these labels
(including unlabelled). No effect if labels is None.
ranking: list
Expand All @@ -582,7 +583,7 @@ def to_dataframe(self, labels=None, ranking=None):
Returns
-------
pd.DataFrame:
pandas.DataFrame
Dataframe of all available record data.
"""
new_df = pd.DataFrame.copy(self.df)
Expand All @@ -607,7 +608,7 @@ def to_csv(self, fp, labels=None, ranking=None):
---------
fp: str, NoneType
Filepath or None for buffer.
labels: list, np.ndarray
labels: list, numpy.ndarray
Current labels will be overwritten by these labels
(including unlabelled). No effect if labels is None.
ranking: list
Expand All @@ -616,7 +617,7 @@ def to_csv(self, fp, labels=None, ranking=None):
Returns
-------
pd.DataFrame:
pandas.DataFrame
Dataframe of all available record data.
"""
df = self.to_dataframe(labels=labels, ranking=ranking)
Expand All @@ -629,7 +630,7 @@ def to_excel(self, fp, labels=None, ranking=None):
---------
fp: str, NoneType
Filepath or None for buffer.
labels: list, np.ndarray
labels: list, numpy.ndarray
Current labels will be overwritten by these labels
(including unlabelled). No effect if labels is None.
ranking: list
Expand All @@ -638,7 +639,7 @@ def to_excel(self, fp, labels=None, ranking=None):
Returns
-------
pd.DataFrame:
pandas.DataFrame
Dataframe of all available record data.
"""
df = self.to_dataframe(labels=labels, ranking=ranking)
Expand Down
2 changes: 1 addition & 1 deletion asreview/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def standardize_dataframe(df, column_spec={}):
Arguments
---------
df: pd.DataFrame
df: pandas.DataFrame
Unclean dataframe to be cleaned up.
Returns
Expand Down
8 changes: 4 additions & 4 deletions asreview/models/balance/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ def sample(self, X, y, train_idx, shared):
Arguments
---------
X: np.array
X: numpy.ndarray
Complete feature matrix.
y: np.array
y: numpy.ndarray
Labels for all papers.
train_idx: np.array
train_idx: numpy.ndarray
Training indices, that is all papers that have been reviewed.
shared: dict
Dictionary to share data between balancing models and other models.
Returns
-------
np.array, np.array:
numpy.ndarray, numpy.ndarray
X_train, y_train: the resampled matrix, labels.
"""
raise NotImplementedError
8 changes: 4 additions & 4 deletions asreview/models/balance/double.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ def sample(self, X, y, train_idx, shared):
Arguments
---------
X: np.array
X: numpy.ndarray
Complete feature matrix.
y: np.array
y: numpy.ndarray
Labels for all papers.
train_idx: np.array
train_idx: numpy.ndarray
Training indices, that is all papers that have been reviewed.
shared: dict
Dictionary to share data between balancing models and other models.
Returns
-------
np.array, np.array:
numpy.ndarray,numpy.ndarray:
X_train, y_train: the resampled matrix, labels.
"""
# Get inclusions and exclusions
Expand Down
8 changes: 4 additions & 4 deletions asreview/models/balance/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ def sample(self, X, y, train_idx, shared):
Arguments
---------
X: np.array
X: numpy.ndarray
Complete matrix of all samples.
y: np.array
y: numpy.ndarray
Classified results of all samples.
extra_vars: dict:
Extra variables that can be passed around between functions.
Returns
-------
np.array:
numpy.ndarray:
Training samples.
np.array:
numpy.ndarray:
Classification of training samples.
"""
return X[train_idx], y[train_idx]
8 changes: 4 additions & 4 deletions asreview/models/balance/triple.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ def sample(self, X, y, train_idx, shared):
Arguments
---------
X: np.array
X: numpy.ndarray
Complete feature matrix.
y: np.array
y: numpy.ndarray
Labels for all papers.
train_idx: np.array
train_idx: numpy.ndarray
Training indices, that is all papers that have been reviewed.
shared: dict
Dictionary to share data between balancing models and other models.
Returns
-------
np.array, np.array:
numpy.ndarray,numpy.ndarray:
X_train, y_train: the resampled matrix, labels.
"""
max_idx = np.array(shared["query_src"].get("max", []), dtype=np.int)
Expand Down
8 changes: 4 additions & 4 deletions asreview/models/balance/undersample.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ def sample(self, X, y, train_idx, shared):
Arguments
---------
X: np.array
X: numpy.ndarray
Complete feature matrix.
y: np.array
y: numpy.ndarray
Labels for all papers.
train_idx: np.array
train_idx: numpy.ndarray
Training indices, that is all papers that have been reviewed.
shared: dict
Dictionary to share data between balancing models and other models.
Returns
-------
np.array, np.array:
numpy.ndarray,numpy.ndarray:
X_train, y_train: the resampled matrix, labels.
"""
one_ind = train_idx[np.where(y[train_idx] == 1)]
Expand Down
4 changes: 2 additions & 2 deletions asreview/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def default_param(self):
Returns
-------
dict:
dict
Dictionary with parameter: default value
"""
cur_class = self.__class__
Expand All @@ -55,7 +55,7 @@ def param(self):
Returns
-------
dict:
dict
Dictionary with parameter: current value.
"""
parameters = self.default_param
Expand Down
18 changes: 9 additions & 9 deletions asreview/models/classifiers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def __init__(self):
def fit(self, X, y):
"""Fit the model to the data.
X: np.array
Arguments
---------
X: numpy.ndarray
Feature matrix to fit.
y: np.array
y: numpy.ndarray
Labels for supervised learning.
"""
return self._model.fit(X, y)
Expand All @@ -48,12 +50,12 @@ def predict_proba(self, X):
Arguments
---------
X: np.array
X: numpy.ndarray
Feature matrix to predict.
Returns
-------
np.array:
numpy.ndarray
Array with the probabilities for each class, with two
columns (class 0, and class 1) and the number of samples rows.
"""
Expand All @@ -64,10 +66,8 @@ def full_hyper_space(self):
Returns
-------
dict:
Parameter space.
dict:
Parameter choices; in case of hyperparameters with a list of
choices, store the choices there.
dict, dict
Parameter space. Parameter choices; in case of hyperparameters
with a list of choices, store the choices there.
"""
return {}, {}
2 changes: 1 addition & 1 deletion asreview/models/classifiers/lstm_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LSTMBaseClassifier(BaseTrainClassifier):
Arguments
---------
embedding_matrix: np.array
embedding_matrix: numpy.ndarray
Embedding matrix to use with LSTM model.
backwards: bool
Whether to have a forward or backward LSTM.
Expand Down
2 changes: 1 addition & 1 deletion asreview/models/classifiers/lstm_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LSTMPoolClassifier(BaseTrainClassifier):
Arguments
---------
embedding_matrix: np.array
embedding_matrix: numpy.ndarray
Embedding matrix to use with LSTM model.
backwards: bool
Whether to have a forward or backward LSTM.
Expand Down
11 changes: 5 additions & 6 deletions asreview/models/feature_extraction/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def fit_transform(self, texts, titles=None, abstracts=None, keywords=None):
Arguments
---------
texts: np.array
texts: numpy.ndarray
A sequence of texts to be transformed. They are not yet tokenized.
Returns
-------
np.array:
numpy.ndarray
Feature matrix representing the texts.
"""
self.fit(texts)
Expand Down Expand Up @@ -53,13 +53,12 @@ def fit_transform(self, texts, titles=None, abstracts=None, keywords=None):
def fit(self, texts):
"""Fit the model to the texts.
It is not always necessary to implement this if there's not real
fitting being done.
Arguments
---------
texts: np.array
texts: numpy.ndarray
Texts to be fitted.
"""
pass
Expand All @@ -70,12 +69,12 @@ def transform(self, texts):
Arguments
---------
texts: np.array
texts: numpy.ndarray
A sequence of texts to be transformed. They are not yet tokenized.
Returns
-------
np.array:
numpy.ndarray
Feature matrix representing the texts.
"""
raise NotImplementedError
Expand Down

0 comments on commit 4ca41f9

Please sign in to comment.