コード例 #1
0
 def setUpClass(cls):
     metamap = MetaMap(
         metamap_path=
         "/home/share/programs/metamap/2016/public_mm/bin/metamap",
         cache_output=False)
     cls.pipeline = ClinicalPipeline(
         metamap)  # Will fail as MetaMap isn't installed
コード例 #2
0
    def test_with_metamap(self):
        """
        Constructs a model that memorizes an entity, predicts it on same file, writes to ann
        :return:
        """

        train_loader = DataLoader(self.train_dir)
        test_loader = DataLoader(self.test_dir)
        metamap = MetaMap(metamap_path="/home/share/programs/metamap/2016/public_mm/bin/metamap",
                          cache_output=False)

        train_loader.metamap(metamap)
        test_loader.metamap(metamap)

        pipeline = ClinicalPipeline(metamap, entities=['Strength'])

        learner = Learner(pipeline, train_loader)

        model = learner.train()

        predictor = Predictor(pipeline, test_loader, model=model)

        predictor.predict()

        with open(predictor.prediction_directory+"predict_test.ann") as f:
            self.assertEqual(f.read(), "T1	Strength 7 11	5 mg\n")
コード例 #3
0
    def test_with_metamap(self):

        loader = DataLoader(self.test_dir)
        metamap = MetaMap(
            metamap_path=
            "/home/share/programs/metamap/2016/public_mm/bin/metamap")

        loader.metamap(metamap)  #pre-cache metamap files

        pipeline = ClinicalPipeline(metamap, entities=['Strength'])

        learner = Learner(pipeline, loader)

        model = learner.train()

        self.assertIsInstance(learner, Learner)
コード例 #4
0
    def test_fit_with_clinical_pipeline(self):
        """
        Loads in training data and uses it to fit a model using the Clinical Pipeline
        :return:
        """
        train_loader = DataLoader(self.train_dir)
        metamap = MetaMap(
            metamap_path=
            "/home/share/programs/metamap/2016/public_mm/bin/metamap",
            cache_output=False)

        train_loader.metamap(metamap)

        pipeline = ClinicalPipeline(metamap, entities=['Strength'])

        model = Model(pipeline)
        model.fit(train_loader)

        self.assertIsInstance(model, Model)
        self.assertIsNot(model.model, None)
コード例 #5
0
    def test_prediction_with_clinical_pipeline(self):
        """
        Constructs a model that memorizes an entity, predicts it on same file, writes to ann
        :return:
        """

        train_loader = DataLoader(self.train_dir)
        test_loader = DataLoader(self.test_dir)
        metamap = MetaMap(
            metamap_path=
            "/home/share/programs/metamap/2016/public_mm/bin/metamap",
            cache_output=False)

        train_loader.metamap(metamap)
        test_loader.metamap(metamap)

        pipeline = ClinicalPipeline(metamap, entities=['Strength'])

        model = Model(pipeline)
        model.fit(train_loader)
        model.predict(test_loader)

        with open(self.test_dir + "/predictions/" + "predict_test.ann") as f:
            self.assertEqual(f.read(), "T1	Strength 7 11	5 mg\n")
コード例 #6
0
 def setUpClass(cls):
     cls.pipeline = ClinicalPipeline(
     )  # Will fail as MetaMap isn't installed
コード例 #7
0
 def setUpClass(cls):
     cls.pipeline = ClinicalPipeline()