コード例 #1
0
ファイル: UnitTestMLData.py プロジェクト: Kaziaa/rdkit-1
 def testQuantPickle(self):
     # " testing QuantDataSet pickling "
     self.setUpQuantLoad()
     DataUtils.WritePickledData(
         RDConfig.RDCodeDir + '/ML/Data/test_data/testquant.qdat.pkl',
         self.d)
     with open(RDConfig.RDCodeDir + '/ML/Data/test_data/testquant.qdat.pkl',
               'rb') as f:
         vNames = pickle.load(f)
         qBounds = pickle.load(f)
         ptNames = pickle.load(f)
         examples = pickle.load(f)
     d = MLData.MLQuantDataSet(examples,
                               varNames=vNames,
                               qBounds=qBounds,
                               ptNames=ptNames)
     assert self.d.GetNPts() == d.GetNPts(), 'nPts wrong'
     assert self.d.GetNVars() == d.GetNVars(), 'nVars wrong'
     assert self.d.GetNResults() == d.GetNResults(), 'nResults wrong'
     assert self.d.GetVarNames() == d.GetVarNames(), 'varNames wrong'
     assert self.d.GetPtNames() == d.GetPtNames(), 'ptNames wrong'
     assert self.d.GetNPossibleVals() == d.GetNPossibleVals(
     ), 'nPossible Wrong'
     assert self.d.GetQuantBounds() == d.GetQuantBounds(
     ), 'quantBounds Wrong'
     assert self.d.GetResults() == d.GetResults(), 'GetResults wrong'
     assert self.d.GetAllData()[1] == d.GetAllData()[1], 'GetAllData wrong'
     assert self.d.GetInputData()[3] == d.GetInputData(
     )[3], 'GetInputData wrong'
     assert self.d.GetNamedData()[2] == d.GetNamedData(
     )[2], 'GetNamedData wrong'
コード例 #2
0
ファイル: UnitTestID3.py プロジェクト: rwest/rdkit
    def _setupMultiTree(self):
        examples = [[0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 2], [0, 1, 1, 2],
                    [1, 0, 0, 2], [1, 0, 1, 2], [1, 1, 0, 2], [1, 1, 1, 0]]

        data = MLData.MLQuantDataSet(examples)
        attrs = range(0, data.GetNVars())
        t1 = ID3.ID3Boot(data.GetAllData(), attrs, data.GetNPossibleVals())
        self.t1 = t1
        self.examples = examples
コード例 #3
0
ファイル: UnitTestID3.py プロジェクト: rwest/rdkit
    def _setupPyMultiTree(self):
        from rdkit.ML.InfoTheory import entropy
        ID3.entropy.InfoEntropy = entropy.PyInfoEntropy
        ID3.entropy.InfoGain = entropy.PyInfoGain

        examples = [[0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 2], [0, 1, 1, 2],
                    [1, 0, 0, 2], [1, 0, 1, 2], [1, 1, 0, 2], [1, 1, 1, 0]]

        data = MLData.MLQuantDataSet(examples)
        attrs = range(0, data.GetNVars())
        t1 = ID3.ID3Boot(data.GetAllData(), attrs, data.GetNPossibleVals())
        self.t1 = t1
        self.examples = examples
コード例 #4
0
def BuildQuantDataSet(fileName):
  """ builds a data set from a .qdat file

    **Arguments**

      - fileName: the name of the .qdat file

    **Returns**

      an _MLData.MLQuantDataSet_
      
  """
  with open(fileName, 'r') as inFile:
    varNames, qBounds = ReadVars(inFile)
    ptNames, examples = ReadQuantExamples(inFile)
  data = MLData.MLQuantDataSet(examples, qBounds=qBounds, varNames=varNames, ptNames=ptNames)
  return data