IBM/causallib

View on GitHub

Showing 111 of 111 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Ktt = torch.exp(-pdist2sq(Xt,Xt)/np.square(sig))
Severity: Minor
Found in causallib/contrib/hemm/hemm_metrics.py and 2 other locations - About 30 mins to fix
causallib/contrib/hemm/hemm_metrics.py on lines 69..69
causallib/contrib/hemm/hemm_metrics.py on lines 70..70

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Kct = torch.exp(-pdist2sq(Xc,Xt)/np.square(sig))
Severity: Minor
Found in causallib/contrib/hemm/hemm_metrics.py and 2 other locations - About 30 mins to fix
causallib/contrib/hemm/hemm_metrics.py on lines 69..69
causallib/contrib/hemm/hemm_metrics.py on lines 71..71

Function predict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def predict(self, times=None, interpolate=False):
"""
Compute survival curve for time points given in 'times' param.
Args:
times: sequence of time points for prediction
Severity: Minor
Found in causallib/survival/univariate_curve_fitter.py - About 25 mins to fix

Function _standardization_predict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _standardization_predict(estimator, X, predict_proba):
"""
Single prediction call.
 
Args:
Severity: Minor
Found in causallib/estimation/standardization.py - About 25 mins to fix

Function estimate_individual_outcome has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def estimate_individual_outcome(self,
X: pd.DataFrame,
a: pd.Series,
t: pd.Series,
y: Optional[Any] = None,
Severity: Minor
Found in causallib/survival/standardized_survival.py - About 25 mins to fix

Function chi2_test has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def chi2_test(X, y):
"""
 
Args:
X (np.ndarray): Binary feature matrix
Severity: Minor
Found in causallib/utils/stat_utils.py - About 25 mins to fix

Function returnIndicesTest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def returnIndicesTest(splits):
"""Takes the splits and return the train, test and dev splits."""
test = []
train = []
dev = []
Severity: Minor
Found in causallib/contrib/hemm/hemm_utilities.py - About 25 mins to fix

Function wass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def wass(X,t,p,lam=10.0,its=20,sq=False,backpropT=False):
"""
Computes the Wasserstein metric.
 
Algorithm 3 from "Fast Computation of Wasserstein Barycenters", Cuturi and Doucet (2014) (https://arxiv.org/pdf/1310.4375.pdf).
Severity: Minor
Found in causallib/contrib/hemm/hemm_metrics.py - About 25 mins to fix

Function _execute_matching has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _execute_matching(self, X, a):
"""Execute matching of samples in X according to the treatment values in a.
 
Returns a DataFrame including all the results, which is also set as
the attribute `self.match_df_`. The arguments `X` and `a` define the
Severity: Minor
Found in causallib/estimation/matching.py - About 25 mins to fix

Function _get_agg_function has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _get_agg_function(self, predict_proba):
if predict_proba:
agg_function = self.regress_agg_function
else:
agg_function = self.classify_agg_function
Severity: Minor
Found in causallib/estimation/matching.py - About 25 mins to fix

Function get_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def get_version(filename):
with open(filename, 'r') as f:
for line in f.readlines():
if line.startswith('__version__'):
quotes_type = '"' if '"' in line else "'"
Severity: Minor
Found in setup.py - About 25 mins to fix
Severity
Category
Status
Source
Language