|
1 | 1 | from __future__ import print_function |
2 | 2 |
|
3 | | -import numpy as np |
4 | | -import pandas as pd |
5 | | -import patsy |
6 | | - |
7 | 3 | import orca |
8 | | -from choicemodels import mnl |
9 | | -from choicemodels import MultinomialLogit, MultinomialLogitResults |
10 | | -from choicemodels.tools import (MergedChoiceTable, monte_carlo_choices, |
11 | | - iterative_lottery_choices) |
| 4 | +# choicemodels imports are in the fit() and run() methods |
12 | 5 |
|
13 | 6 | from .. import modelmanager |
| 7 | +from ..utils import version_greater_or_equal |
14 | 8 | from .shared import TemplateStep |
15 | 9 |
|
16 | 10 |
|
@@ -412,6 +406,15 @@ def fit(self, mct=None): |
412 | 406 | None |
413 | 407 | |
414 | 408 | """ |
| 409 | + try: |
| 410 | + from choicemodels import __version__, MultinomialLogit |
| 411 | + from choicemodels.tools import MergedChoiceTable |
| 412 | + assert version_greater_or_equal(__version__, '0.2.dev4') |
| 413 | + except: |
| 414 | + raise ImportError("LargeMultinomialLogitStep estimation requires " |
| 415 | + "choicemodels 0.2.dev4 or later. For installation instructions, see " |
| 416 | + "https://github.com/udst/choicemodels.") |
| 417 | + |
415 | 418 | if (mct is not None): |
416 | 419 | data = mct |
417 | 420 |
|
@@ -476,6 +479,16 @@ def run(self, chooser_batch_size=None, interaction_terms=None): |
476 | 479 | None |
477 | 480 | |
478 | 481 | """ |
| 482 | + try: |
| 483 | + from choicemodels import __version__, MultinomialLogitResults |
| 484 | + from choicemodels.tools import (MergedChoiceTable, monte_carlo_choices, |
| 485 | + iterative_lottery_choices) |
| 486 | + assert version_greater_or_equal(__version__, '0.2.dev4') |
| 487 | + except: |
| 488 | + raise ImportError("LargeMultinomialLogitStep simulation requires " |
| 489 | + "choicemodels 0.2.dev4 or later. For installation instructions, see " |
| 490 | + "https://github.com/udst/choicemodels.") |
| 491 | + |
479 | 492 | obs = self._get_df(tables=self.out_choosers, fallback_tables=self.choosers, |
480 | 493 | filters=self.out_chooser_filters) |
481 | 494 |
|
|
0 commit comments