当前位置: 首页>>代码示例>>Python>>正文


Python PathDefaults.getOutputDir方法代码示例

本文整理汇总了Python中sandbox.util.PathDefaults.PathDefaults.getOutputDir方法的典型用法代码示例。如果您正苦于以下问题:Python PathDefaults.getOutputDir方法的具体用法?Python PathDefaults.getOutputDir怎么用?Python PathDefaults.getOutputDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sandbox.util.PathDefaults.PathDefaults的用法示例。


在下文中一共展示了PathDefaults.getOutputDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
    def __init__(self, YList, X, featuresName, ages, args):
        super(MetabolomicsExpRunner, self).__init__(args=args)
        self.X = X
        self.YList = YList  # The list of concentrations
        self.featuresName = featuresName
        self.args = args
        self.ages = ages

        self.maxDepth = 5
        self.numTrees = 10
        self.folds = 3
        self.resultsDir = PathDefaults.getOutputDir() + "metabolomics/"

        self.leafRankGenerators = []
        # self.leafRankGenerators.append((SvcGS.generate(), "SVC"))
        # self.leafRankGenerators.append((LinearSvmGS.generate(), "LinearSVM"))
        self.leafRankGenerators.append((LinearSvmPca.generate(), "LinearSVM-PCA"))

        self.funcLeafRankGenerators = []
        # self.funcLeafRankGenerators.append((LinearSvmFGs.generate, "SVMF"))
        # self.funcLeafRankGenerators.append((DecisionTreeF.generate, "CARTF"))
        self.funcLeafRankGenerators.append((SvcFGs.generate, "SVCF"))

        # Store all the label vectors and their missing values
        YIgf1Inds, YICortisolInds, YTestoInds = MetabolomicsUtils.createIndicatorLabels(YList)
        self.hormoneInds = [YIgf1Inds, YICortisolInds, YTestoInds]
        self.hormoneNames = MetabolomicsUtils.getLabelNames()
开发者ID:kentwang,项目名称:sandbox,代码行数:29,代码来源:CompareTreeRanks.py

示例2: __init__

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
    def __init__(self, maxIter=None, iterStartTimeStamp=None): 
        outputDir = PathDefaults.getOutputDir() + "recommend/erasm/"

        if not os.path.exists(outputDir): 
            os.mkdir(outputDir)
            
        #iterStartDate is the starting date of the iterator 
        if iterStartTimeStamp != None: 
            self.iterStartTimeStamp = iterStartTimeStamp
        else: 
            self.iterStartTimeStamp = 1286229600
            
        self.timeStep = timedelta(30).total_seconds()             
                
        self.ratingFileName = outputDir + "data.npz"          
        self.userDictFileName = outputDir + "userIdDict.pkl"   
        self.groupDictFileName = outputDir + "groupIdDict.pkl" 
        self.isTrainRatingsFileName = outputDir + "is_train.npz"
    
        self.dataDir = PathDefaults.getDataDir() + "erasm/"
        self.dataFileName = self.dataDir + "groupMembers-29-11-12" 
        
        self.maxIter = maxIter 
        self.trainSplit = 4.0/5 
        
        self.processRatings()
        self.splitDataset()        
        self.loadProcessedData()
开发者ID:charanpald,项目名称:wallhack,代码行数:30,代码来源:MendeleyGroupsDataset.py

示例3: __init__

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
    def __init__(self, cmdLine=None, defaultAlgoArgs = None, dirName=""):
        """ priority for default args
         - best priority: command-line value
         - middle priority: set-by-function value
         - lower priority: class value
        """
        # Parameters to choose which methods to run
        # Obtained merging default parameters from the class with those from the user
        self.algoArgs = RankingExpHelper.newAlgoParams(defaultAlgoArgs)


        self.ps = [1, 3, 5]

        #The max number of observations to use for model selection
        self.sampleSize = 5*10**6

        # basic resultsDir
        self.resultsDir = PathDefaults.getOutputDir() + "ranking/" + dirName + "/"

        #Create the results dir if it does not exist
        #    os.makedirs(resultsDir, exist_ok=True) # for python 3.2
        try:
            os.makedirs(self.resultsDir)
        except OSError as err:
            if err.errno != errno.EEXIST:
                raise

        # update algoParams from command line
        self.readAlgoParams(cmdLine)

        #Sometimes there are problems with multiprocessing, so this fixes the issues
        os.system('taskset -p 0xffffffff %d' % os.getpid())
开发者ID:charanpald,项目名称:wallhack,代码行数:34,代码来源:RankingExpHelper.py

示例4: loadParams

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
def loadParams(ind): 
    if processReal: 
        resultsDir = PathDefaults.getOutputDir() + "viroscopy/real/theta" + str(ind) + "/"
        outputDir = resultsDir + "stats/"
        
        N, matchAlpha, breakScale, numEpsilons, epsilon, minEpsilon, matchAlg, abcMaxRuns, batchSize, pertScale = HIVModelUtils.realABCParams(True)
        startDate, endDate, recordStep, M, targetGraph, numInds = HIVModelUtils.realSimulationParams(test=True, ind=ind)
        realTheta, sigmaTheta, pertTheta = HIVModelUtils.estimatedRealTheta(ind)
        numInds=2
        prefix = "Real"
    else: 
        resultsDir = PathDefaults.getOutputDir() + "viroscopy/toy/theta/"
        outputDir = resultsDir + "stats/"        
        
        N, matchAlpha, breakScale, numEpsilons, epsilon, minEpsilon, matchAlg, abcMaxRuns, batchSize, pertScale = HIVModelUtils.toyABCParams()
        startDate, endDate, recordStep, M, targetGraph = HIVModelUtils.toySimulationParams(test=True)
        realTheta, sigmaTheta, pertTheta = HIVModelUtils.toyTheta()
        prefix = "Toy"
        numInds = 1

    breakSize = (targetGraph.subgraph(targetGraph.removedIndsAt(endDate)).size - targetGraph.subgraph(targetGraph.removedIndsAt(startDate)).size)  * breakScale       
        
    return N, resultsDir, outputDir, recordStep, startDate, endDate, prefix, targetGraph, breakSize, numEpsilons, M, matchAlpha, matchAlg, numInds
开发者ID:charanpald,项目名称:wallhack,代码行数:25,代码来源:ProcessResults.py

示例5: __init__

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
    def __init__(self, iteratorFunc, cmdLine=None, defaultAlgoArgs = None, dirName=""):
        # Parameters to choose which methods to run
        # Obtained merging default parameters from the class with those from the user
        self.algoArgs = ClusterExpHelper.newAlgoParams(defaultAlgoArgs)
        
        # Variables related to the dataset
        self.getIteratorFunc = iteratorFunc
        
        #How often to print output 
        self.logStep = 10

        # basic resultsDir
        self.resultsDir = PathDefaults.getOutputDir() + "cluster/" + dirName + "/"

        # update algoParams from command line
        self.readAlgoParams(cmdLine)
开发者ID:charanpald,项目名称:wallhack,代码行数:18,代码来源:ClusterExpHelper.py

示例6: __init__

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
    def __init__(self, maxIter=None, iterStartTimeStamp=None): 
        """
        Return a training and test set for itemlens based on the time each 
        rating was made. 
        """ 
        self.timeStep = timedelta(30).total_seconds() 
        
        #iterStartDate is the starting date of the iterator 
        if iterStartTimeStamp != None: 
            self.iterStartTimeStamp = iterStartTimeStamp
        else: 
            self.iterStartTimeStamp = time.mktime(datetime(2009,1,1).timetuple())
         
        self.numItems = 1560144
        #It says 13668319 on the site but that seems to be wrong 
        self.numRatings = 8196072
        self.numCustomers = 71567
        
        outputDir = PathDefaults.getOutputDir() + "recommend/Flixster/"

        if not os.path.exists(outputDir): 
            os.mkdir(outputDir)
                
        self.ratingFileName = outputDir + "data.npz"  
        self.custDictFileName = outputDir + "custIdDict.pkl"   
        self.itemDictFileName = outputDir + "itemIdDict.pkl" 
        self.isTrainRatingsFileName = outputDir + "is_train.npz"
        
        self.maxIter = maxIter 
        self.trainSplit = 4.0/5 

        self.processRatings()
        self.splitDataset()        
        self.loadProcessedData()
        
        if self.maxIter != None: 
            logging.debug("Maximum number of iterations: " + str(self.maxIter))
开发者ID:charanpald,项目名称:wallhack,代码行数:39,代码来源:FlixsterDataset.py

示例7: rc

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
rc('text', usetex=True)
from sandbox.util.PathDefaults import PathDefaults 



logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

#For now just print some results for a particular dataset 
#dataset = "MovieLensDataset"
dataset = "NetflixDataset"
#dataset = "FlixsterDataset"
#dataset = "SyntheticDataset1"
#dataset = "EpinionsDataset"
outputDir = PathDefaults.getOutputDir() + "recommend/" + dataset + "/"

plotStyles = ['k-', 'k--', 'k-.', 'r--', 'r-', 'g-', 'b-', 'b--', 'b-.', 'g--', 'g--', 'g-.', 'r-', 'r--', 'r-.']
methods = ["propack", "arpack", "rsvd", "rsvdUpdate2"]
updateAlgs = ["initial", "zero"]

#pq = [(10, 2), (50, 2), (10, 5)]
pq = [(10, 3), (50, 2), (50, 3)]
#fileNames = [outputDir + "ResultsSgdMf.npz"]
#labels = ["SgdMf"]
fileNames = []
labels = []

consise = True

for method in methods:
开发者ID:charanpald,项目名称:wallhack,代码行数:33,代码来源:ProcessResults.py

示例8: IterativeSoftImpute

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
minContacts = 3
minAcceptableSims = 3
maxIterations = 30 
alpha = 0.2
numProcesses = 2
modelSelectSamples = 10**6

modelSelect = args.modelSelect
folds = 3
ks = numpy.array([64, 128, 256])
rhosSi = numpy.linspace(1.0, 0.0, 5)

overwrite = args.overwrite
datasets = ["Keyword", "Document"]

resultsDir = PathDefaults.getOutputDir() + "coauthors/"
contactsFilename = PathDefaults.getDataDir() + "reference/contacts_anonymised.tsv"
interestsFilename = PathDefaults.getDataDir() + "reference/author_interest"


#Create all the recommendation algorithms
softImpute = IterativeSoftImpute(k=k, postProcess=True, svdAlg="rsvd")
softImpute.maxIterations = maxIterations
softImpute.metric = "f1" 
softImpute.q = 3
softImpute.p = 10
softImpute.rho = 0.1
softImpute.eps = 10**-4 
softImpute.numProcesses = args.processes

wrmf = WeightedMf(k=k, maxIterations=maxIterations, alpha=1.0)
开发者ID:charanpald,项目名称:wallhack,代码行数:33,代码来源:ContactsRecommenderExp.py

示例9: len

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
"""


logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
numpy.random.seed(21)        
numpy.set_printoptions(precision=4, suppress=True, linewidth=150)
#numpy.seterr(all="raise")

if len(sys.argv) > 1:
    dataset = sys.argv[1]
else: 
    dataset = "synthetic"

saveResults = True
prefix = "LossROC"
outputFile = PathDefaults.getOutputDir() + "ranking/" + prefix + dataset.title() + "Results.npz" 
X = DatasetUtils.getDataset(dataset, nnz=20000)

m, n = X.shape
u = 0.1 
w = 1-u

testSize = 5
folds = 5
trainTestXs = Sampling.shuffleSplitRows(X, folds, testSize)

numRecordAucSamples = 200

k2 = 8
u2 = 0.5
w2 = 1-u2
开发者ID:charanpald,项目名称:wallhack,代码行数:33,代码来源:LossROCExp.py

示例10: HIVGraphReader

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
from apgl.viroscopy.HIVGraphReader import HIVGraphReader

"""
This script computes some basic statistics on the growing infection graph.
"""

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
numpy.set_printoptions(suppress=True, linewidth=100, precision=3)

undirected = False 
hivReader = HIVGraphReader()
graph = hivReader.readHIVGraph(undirected, indicators=False)
fInds = hivReader.getNonIndicatorFeatureIndices()


figureDir = PathDefaults.getOutputDir() + "viroscopy/figures/infect/"
resultsDir = PathDefaults.getOutputDir() + "viroscopy/"

#The set of edges indexed by zeros is the contact graph
#The ones indexed by 1 is the infection graph
edgeTypeIndex1 = 0
edgeTypeIndex2 = 1
sGraphContact = graph.getSparseGraph(edgeTypeIndex1)
sGraphInfect = graph.getSparseGraph(edgeTypeIndex2)

sGraph = sGraphInfect
#sGraph = sGraph.subgraph(range(0, 500))

graphStats = GraphStatistics()
statsArray = graphStats.scalarStatistics(sGraph, False)
slowStats = True
开发者ID:charanpald,项目名称:wallhack,代码行数:33,代码来源:InfectGrowthStatistics.py

示例11: getIterator

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

plotHIV = False 
plotCitation = False
plotBemol = True 

saveResults = False 
findEigs = False

if plotHIV: 
    def getIterator(): 
        generator = HIVIterGenerator()
        return generator.getIterator()
        
    resultsDir = PathDefaults.getOutputDir() + "cluster/HIV/Stats/"
    
if plotCitation: 
    
    def getIterator(): 
        maxGraphSize = None 
        generator = CitationIterGenerator(maxGraphSize=maxGraphSize)
        return generator.getIterator()
    
    resultsDir = PathDefaults.getOutputDir() + "cluster/Citation/Stats/"
if plotBemol: 
    def getIterator(): 
        dataDir = PathDefaults.getDataDir() + "cluster/"
        
        nbUser = 10000 # set to 'None' to have all users
        nbPurchasesPerIt = 500 # set to 'None' to take all the purchases per date
开发者ID:charanpald,项目名称:wallhack,代码行数:32,代码来源:DatasetStats.py

示例12: list

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
#The set of edges indexed by zeros is the contact graph
#The ones indexed by 1 is the infection graph
edgeTypeIndex1 = 0
edgeTypeIndex2 = 1
sGraphContact = graph.getSparseGraph(edgeTypeIndex1)
sGraphInfect = graph.getSparseGraph(edgeTypeIndex2)
sGraphContact = sGraphContact.union(sGraphInfect)
graph = sGraphContact

#Find max component
components = graph.findConnectedComponents()
graph = graph.subgraph(list(components[0]))
logging.debug(graph)

resultsDir = PathDefaults.getOutputDir() + "cluster/"

detectionIndex = fInds["detectDate"]
vertexArray = graph.getVertexList().getVertices()
detections = vertexArray[:, detectionIndex]

startYear = 1900
daysInMonth = 30
monthStep = 1
dayList = list(range(int(numpy.min(detections)), int(numpy.max(detections)), daysInMonth*monthStep))
dayList.append(numpy.max(detections))

subgraphIndicesList = []
minGraphSize = 150
maxGraphSize = 500 
开发者ID:charanpald,项目名称:wallhack,代码行数:31,代码来源:HIVExperiment3.py

示例13: __init__

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
    def __init__(self, k=500, additionalFields=[], runLSI=True, knownAuthors=False):
        numpy.random.seed(21)
        self.runLSI = runLSI 
        self.dataDir = PathDefaults.getDataDir() + "reputation/" 
        self.outputDir = PathDefaults.getOutputDir() + "reputation/"
        
        self.fields = ["Boosting", "Computer Vision", "Cryptography", "Data Mining"]
        self.fields.extend(["Information Extraction", "Intelligent Agents", "Machine Learning"])
        self.fields.extend(["Natural Language Processing", "Neural Networks", "Ontology Alignment"])
        self.fields.extend(["Planning", "Semantic Web", "Support Vector Machine"])    
        #self.fields.extend(["Planning", "Semantic Web"])  
        self.fields.extend(additionalFields)      
        
        self.dataFilename = self.dataDir + "DBLP-citation-Feb21.txt" 
        #self.dataFilename = self.dataDir + "DBLP-citation-7000000.txt" 
        #self.dataFilename = self.dataDir + "DBLP-citation-100000.txt"  
        
        #This option is true if we have a data file which lists authors within each field 
        self.knownAuthors = knownAuthors
        
        for field in self.fields: 
            if not os.path.exists(self.getOutputFieldDir(field)): 
                os.mkdir(self.getOutputFieldDir(field))
        
        if runLSI:
            self.methodName = "LSI"
        else: 
            self.methodName = "LDA"
            
        self.authorListFilename = self.outputDir + "authorList" + self.methodName +".pkl"
        self.citationListFilename = self.outputDir + "citationList" + self.methodName +".pkl"
        self.vectoriserFilename = self.outputDir + "vectoriser" + self.methodName +".pkl"   
        self.modelFilename = self.outputDir + "model" + self.methodName + ".pkl"
        self.docTermMatrixFilename = self.outputDir + "termDocMatrix" + self.methodName
        self.indexFilename = self.outputDir + "index" + self.methodName 
        self.coverageFilename = self.outputDir + "meanCoverages" + self.methodName + ".npy"
        self.relevantDocsFilename = self.outputDir + "relevantDocs" + self.methodName + ".npy"
        
        self.stepSize = 1000000    
        self.numLines = 15192085
        self.matchCutoff = 1.0   
        
        #Params for finding relevant authors
        self.gamma = 1.3
        self.maxRelevantAuthors = 500
        self.maxRelevantAuthorsMult = 10
        self.printPossibleMatches = False
        self.gammas = numpy.arange(1.0, 2, 0.1)
        self.minExpertArticles = 2

        #Params for vectoriser 
        self.numFeatures = 500000
        self.binary = True 
        self.sublinearTf = False
        self.minDf = 10**-4 
        self.ngram = 2
        self.minDfs = [10**-3, 10**-4, 10**-5]
        
        logging.debug("Limiting BOW/TFIDF features to " + str(self.numFeatures))
        
        #params for LSI        
        self.k = k
        self.q = 3
        self.p = 30 
        self.ks = [100, 200, 300, 400, 500, 600]
        self.sampleDocs = 1000000
        
        self.overwriteGraph = True
        self.overwriteVectoriser = True
        self.overwriteModel = True
        
        self.chunksize = 2000
        self.tfidf = runLSI 
        
        #Load the complete set of experts 
        self.expertsDict = {} 
        for field in self.fields: 
            expertsFile = open(self.getDataFieldDir(field) + "matched_experts.txt")
            self.expertsDict[field] = expertsFile.readlines()
            self.expertsDict[field] = set([x.strip() for x in self.expertsDict[field]])
            expertsFile.close()
            
        #Create a set of experts we use for training 
        self.trainExpertDict = {}
        self.testExpertDict = {}        
        
        for field in self.fields: 
            inds  = numpy.random.permutation(len(self.expertsDict[field]))            
            
            numTrainInds = int(0.5*len(self.expertsDict[field])) 
            trainInds = inds[0:numTrainInds]
            self.trainExpertDict[field] = list(numpy.array(list(self.expertsDict[field]))[trainInds]) 
            
            testInds = inds[numTrainInds:]
            self.testExpertDict[field] = list(numpy.array(list(self.expertsDict[field]))[testInds]) 
开发者ID:charanpald,项目名称:wallhack,代码行数:97,代码来源:ArnetMinerDataset.py

示例14: runToyExp

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
def runToyExp(datasetNames, sampleSizes, foldsSet, cvScalings, sampleMethods, numProcesses, fileNameSuffix):
    dataDir = PathDefaults.getDataDir() + "modelPenalisation/toy/"
    outputDir = PathDefaults.getOutputDir() + "modelPenalisation/"

    svm = LibSVM()
    numCs = svm.getCs().shape[0]
    numGammas = svm.getGammas().shape[0]
    numMethods = 1+(1+cvScalings.shape[0])
    numParams = 2

    runIdeal = True
    runCv = True
    runVfpen = True

    for i in range(len(datasetNames)):
        datasetName = datasetNames[i][0]
        numRealisations = datasetNames[i][1]
        logging.debug("Learning using dataset " + datasetName)

        for s in range(len(sampleMethods)):
            sampleMethod = sampleMethods[s][1]
            outfileName = outputDir + datasetName + sampleMethods[s][0] + fileNameSuffix

            fileLock = FileLock(outfileName + ".npz")
            if not fileLock.isLocked() and not fileLock.fileExists():
                fileLock.lock()
                errors = numpy.zeros((numRealisations, len(sampleSizes), foldsSet.shape[0], numMethods))
                params = numpy.zeros((numRealisations, len(sampleSizes), foldsSet.shape[0], numMethods, numParams))
                errorGrids = numpy.zeros((numRealisations, len(sampleSizes), foldsSet.shape[0], numMethods, numCs, numGammas))
                approxGrids = numpy.zeros((numRealisations, len(sampleSizes), foldsSet.shape[0], numMethods, numCs, numGammas))
                idealGrids = numpy.zeros((numRealisations, len(sampleSizes), foldsSet.shape[0], numCs, numGammas))

                data = numpy.load(dataDir + datasetName + ".npz")
                gridPoints, trainX, trainY, pdfX, pdfY1X, pdfYminus1X = data["arr_0"], data["arr_1"], data["arr_2"], data["arr_3"], data["arr_4"], data["arr_5"]

                #We form a test set from the grid points
                testX = numpy.zeros((gridPoints.shape[0]**2, 2))
                for m in range(gridPoints.shape[0]):
                    testX[m*gridPoints.shape[0]:(m+1)*gridPoints.shape[0], 0] = gridPoints
                    testX[m*gridPoints.shape[0]:(m+1)*gridPoints.shape[0], 1] = gridPoints[m]

                for j in range(numRealisations):
                    Util.printIteration(j, 1, numRealisations, "Realisation: ")

                    for k in range(sampleSizes.shape[0]):
                        sampleSize = sampleSizes[k]
                        for m in range(foldsSet.shape[0]):
                            folds = foldsSet[m]
                            logging.debug("Using sample size " + str(sampleSize) + " and " + str(folds) + " folds")
                            perm = numpy.random.permutation(trainX.shape[0])
                            trainInds = perm[0:sampleSize]
                            validX = trainX[trainInds, :]
                            validY = trainY[trainInds]

                            svm = LibSVM(processes=numProcesses)
                            #Find ideal penalties
                            if runIdeal:
                                logging.debug("Finding ideal grid of penalties")
                                idealGrids[j, k, m, :, :] = parallelPenaltyGridRbf(svm, validX, validY, testX, gridPoints, pdfX, pdfY1X, pdfYminus1X)

                            #Cross validation
                            if runCv:
                                logging.debug("Running V-fold cross validation")
                                methodInd = 0
                                idx = sampleMethod(folds, validY.shape[0])
                                if sampleMethod == Sampling.bootstrap:
                                    bootstrap = True
                                else:
                                    bootstrap = False

                                bestSVM, cvGrid = svm.parallelVfcvRbf(validX, validY, idx, True, bootstrap)
                                predY, decisionsY = bestSVM.predict(testX, True)
                                decisionGrid = numpy.reshape(decisionsY, (gridPoints.shape[0], gridPoints.shape[0]), order="F")
                                errors[j, k, m, methodInd] = ModelSelectUtils.bayesError(gridPoints, decisionGrid, pdfX, pdfY1X, pdfYminus1X)
                                params[j, k, m, methodInd, :] = numpy.array([bestSVM.getC(), bestSVM.getKernelParams()])
                                errorGrids[j, k, m, methodInd, :, :] = cvGrid

                            #v fold penalisation
                            if runVfpen:
                                logging.debug("Running penalisation")
                                #BIC penalisation
                                Cv = float((folds-1) * numpy.log(validX.shape[0])/2)
                                tempCvScalings = cvScalings*(folds-1)
                                tempCvScalings = numpy.insert(tempCvScalings, 0, Cv)

                                #Use cross validation
                                idx = sampleMethod(folds, validY.shape[0])
                                svmGridResults = svm.parallelVfPenRbf(validX, validY, idx, tempCvScalings)

                                for n in range(len(tempCvScalings)):
                                    bestSVM, trainErrors, approxGrid = svmGridResults[n]
                                    methodInd = n+1
                                    predY, decisionsY = bestSVM.predict(testX, True)
                                    decisionGrid = numpy.reshape(decisionsY, (gridPoints.shape[0], gridPoints.shape[0]), order="F")
                                    errors[j, k, m, methodInd] = ModelSelectUtils.bayesError(gridPoints, decisionGrid, pdfX, pdfY1X, pdfYminus1X)
                                    params[j, k, m, methodInd, :] = numpy.array([bestSVM.getC(), bestSVM.getKernelParams()])
                                    errorGrids[j, k, m, methodInd, :, :] = trainErrors + approxGrid
                                    approxGrids[j, k, m, methodInd, :, :] = approxGrid


#.........这里部分代码省略.........
开发者ID:charanpald,项目名称:wallhack,代码行数:103,代码来源:ToyDataExp.py

示例15: MetabolomicsUtils

# 需要导入模块: from sandbox.util.PathDefaults import PathDefaults [as 别名]
# 或者: from sandbox.util.PathDefaults.PathDefaults import getOutputDir [as 别名]
import sys
import numpy 
import logging
import datetime
import matplotlib 
matplotlib.use("GTK3Agg")
import matplotlib.pyplot as plt  
from sandbox.util.PathDefaults import PathDefaults
from sandbox.util.Latex import Latex 
from wallhack.metabolomics.MetabolomicsUtils import MetabolomicsUtils
from wallhack.metabolomics.MetabolomicsExpHelper import MetabolomicsExpHelper

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
numpy.set_printoptions(suppress=True, precision=3)
resultsDir = PathDefaults.getOutputDir() + "metabolomics/"
figureDir = resultsDir + "Figures/"

metaUtils = MetabolomicsUtils() 
X, XStd, X2, (XoplsCortisol, XoplsTesto, XoplsIgf1), YCortisol, YTesto, YIgf1, ages = metaUtils.loadData()

dataDict = {}
numpy.random.seed(datetime.datetime.now().microsecond)
helper = MetabolomicsExpHelper(dataDict, YCortisol, YTesto, YIgf1, ages)

dataNames =[] 
dataNames.extend(["raw", "pca", "Db4", "Db8", "Haar"])
#algorithms = ["CartTreeRank", "CartTreeRankForest", "L1SvmTreeRank", "L1SvmTreeRankForest", "RbfSvmTreeRank", "RbfSvmTreeRankForest", "RankBoost", "RankSVM"]
algorithms = ["CartTreeRankForest", "L1SvmTreeRankForest", "RbfSvmTreeRankForest", "RankBoost", "RankSVM"]
algorithmsAbbr = ["CART-TRF", "L1-TRF", "RBF-TRF", "RB", "RSVM"]

hormoneNameIndicators = [] 
开发者ID:charanpald,项目名称:wallhack,代码行数:33,代码来源:ProcessResults.py


注:本文中的sandbox.util.PathDefaults.PathDefaults.getOutputDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。