Skip to content

Commit

Permalink
Merge pull request #117 from jakobrunge/developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
jakobrunge authored Jun 1, 2021
2 parents 438ea3c + 43ddda7 commit 1ce2a4b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 4.2

[Documentation](https://jakobrunge.github.io/tigramite/)

--> [Take a survey to improve tigramite](https://forms.gle/bXdj5vWkSDB7yN9u7) <--

## Overview

Expand Down
32 changes: 26 additions & 6 deletions tigramite/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,8 +1364,14 @@ def predict(self, target,
# Check if we've passed a new dataframe object
test_array = None
if new_data is not None:
if new_data.mask is None:
# if no mask is supplied, use the same mask as for the fitted array
new_data_mask = self.test_mask
else:
new_data_mask = new_data.mask
test_array, _ = new_data.construct_array(X, Y, Z,
tau_max=self.tau_max,
mask=new_data_mask,
mask_type=self.mask_type,
cut_off=cut_off,
verbosity=self.verbosity)
Expand Down Expand Up @@ -1406,6 +1412,7 @@ def get_test_array(self):
if __name__ == '__main__':

import tigramite.data_processing as pp
from tigramite.independence_tests import ParCorr

np.random.seed(6)

Expand All @@ -1418,16 +1425,29 @@ def lin_f(x): return x
data, nonstat = pp.structural_causal_process(links, T=10000)
true_parents = pp._get_true_parent_neighbor_dict(links)
dataframe = pp.DataFrame(data)

med = Models(dataframe=dataframe, model=sklearn.linear_model.LinearRegression(), data_transform=None)
# Fit the model
med.get_fit(all_parents=true_parents, tau_max=3)

print(med.get_val_matrix())
# med = Models(dataframe=dataframe, model=sklearn.linear_model.LinearRegression(), data_transform=None)
# # Fit the model
# med.get_fit(all_parents=true_parents, tau_max=3)

# print(med.get_val_matrix())

# for j, i, tau, coeff in pp._iter_coeffs(links):
# print(i, j, tau, coeff, med.get_coeff(i=i, tau=tau, j=j))

# for causal_coeff in [med.get_ce(i=0, tau=-2, j=2),
# med.get_mce(i=0, tau=-2, j=2, k=1)]:
# print(causal_coeff)
# print(causal_coeff)


pred = Prediction(dataframe=dataframe,
cond_ind_test=ParCorr(), #CMIknn ParCorr
prediction_model = sklearn.linear_model.LinearRegression(),
# prediction_model = sklearn.gaussian_process.GaussianProcessRegressor(),
# prediction_model = sklearn.neighbors.KNeighborsRegressor(),
data_transform=sklearn.preprocessing.StandardScaler(),
# train_indices= range(int(0.8*T)),
# test_indices= range(int(0.8*T), T),
verbosity=1
)

2 changes: 1 addition & 1 deletion tutorials/tigramite_tutorial_pcmciplus.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4082,7 +4082,7 @@
"metadata": {},
"outputs": [],
"source": [
"q_matrix = pcmci.get_corrected_pvalues(p_matrix=results['p_matrix'], tau_max=tau_max, fdr_method='fdr_bh',\n",
"q_matrix = pcmci.get_corrected_pvalues(p_matrix=results['p_matrix'], fdr_method='fdr_bh',\n",
" exclude_contemporaneous=False)"
]
},
Expand Down

0 comments on commit 1ce2a4b

Please sign in to comment.