本文整理汇总了Python中FileSystem.FileSystem.getResultsDir方法的典型用法代码示例。如果您正苦于以下问题:Python FileSystem.getResultsDir方法的具体用法?Python FileSystem.getResultsDir怎么用?Python FileSystem.getResultsDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem.FileSystem
的用法示例。
在下文中一共展示了FileSystem.getResultsDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
categories = [[],[],[],[],[]]
numClasses = 0
classNames = []
path = os.path.join(FileSystem.getResultsDir(),projectName)
for fname in os.listdir(path):
if fname[-4:] == '.csv':
numClasses += 1
classNames.append(fname[:-4])
with open(os.path.join(path, fname)) as fid:
rows = fid.readlines()
data = [float(r.strip().split(', ')[1]) for r in rows]
for i in range(len(data)):
categories[i].append(data[i])
ind = range(numClasses)
width = .5
plt.figure(1)
p0 = plt.bar(ind, categories[0], width,color = 'k')
p1 = plt.bar(ind, categories[1], width,color = 'r',bottom=categories[0])
p2 = plt.bar(ind, categories[2], width,color = 'g',bottom=listsum(categories,[0,1]))
p3 = plt.bar(ind, categories[3], width,color = 'b',bottom=listsum(categories,[0,1,2]))
p4 = plt.bar(ind, categories[4], width,color = 'c',bottom=listsum(categories,[0,1,2,3]))
plt.xticks([x + width/2. for x in ind], classNames, rotation='vertical')
#plt.show()
plt.ylim((0.,1.))
plt.subplots_adjust(bottom=0.5)
figpath = os.path.join(FileSystem.getResultsDir(),projectName,'distribution.pdf')
plt.savefig(figpath)
示例2: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
path = os.path.join(FileSystem.getResultsDir(),projectName,'results.csv')
fid = open(path)
rows = fid.readlines()
fid.close()
buckets = []
bucketsByGender = {}
bucketsByGender['male'] = []
bucketsByGender['female'] = []
bucketsByEmployment = {}
for key in employmentOptions:
bucketsByEmployment[employmentOptions[key]] = []
ageMax = 75
ageMin = 15
sizeBucket = 5
oldies = []
oldiesByGender = {}
oldiesByGender['male'] = []
oldiesByGender['female'] = []
oldiesByEmployment = {}
for key in employmentOptions:
oldiesByEmployment[employmentOptions[key]] = []
for i in range((ageMax-ageMin)/sizeBucket):
buckets.append([])
bucketsByGender['male'].append([])
bucketsByGender['female'].append([])
for key in employmentOptions:
bucketsByEmployment[employmentOptions[key]].append([])
for r in rows:
row = r.strip().split(', ')
age = int(row[1])
gender = row[2]
employment = row[3]
studentStatus = row[4]
grade = int(row[5])
numPosts = int(row[6])
if age >= ageMin and age < ageMax:
bin = (age - ageMin) / sizeBucket
buckets[bin].append(numPosts)
if gender == 'male' or gender == 'female':
bucketsByGender[gender][bin].append(numPosts)
bucketsByEmployment[employment][bin].append(numPosts)
if age >= ageMax:
oldies.append(numPosts)
if gender == 'male' or gender == 'female':
oldiesByGender[gender].append(numPosts)
oldiesByEmployment[employment].append(numPosts)
path = os.path.join(FileSystem.getResultsDir(),projectName,'aggregatedAgeVsForumPosts.csv')
pathMale = os.path.join(FileSystem.getResultsDir(),projectName,'maleAgeVsForumPosts.csv')
pathFemale = os.path.join(FileSystem.getResultsDir(),projectName,'femaleAgeVsForumPosts.csv')
summarizeBuckets(buckets,oldies,path,ageMin, ageMax, sizeBucket)
summarizeBuckets(bucketsByGender['male'],oldiesByGender['male'],pathMale,ageMin, ageMax, sizeBucket)
summarizeBuckets(bucketsByGender['female'],oldiesByGender['female'],pathFemale,ageMin, ageMax, sizeBucket)
for key in employmentOptions:
if len(key) > 0:
path = os.path.join(FileSystem.getResultsDir(), projectName, employmentOptions[key] + 'AgeVsForumPosts.csv')
summarizeBuckets(bucketsByEmployment[employmentOptions[key]], \
oldiesByEmployment[employmentOptions[key]],path,ageMin,ageMax,sizeBucket)
示例3: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run():
projectName = 'ForumMetrics'
path = os.path.join(FileSystem.getResultsDir(),projectName,'results.csv')
outputPath = os.path.join(FileSystem.getResultsDir(),projectName,'corrMat.csv')
arr, nanmask = loadResults(path)
X = ma.array(arr,mask = nanmask)
C = np.ma.corrcoef(np.transpose(X))
writeCorrMat(C, outputPath)
示例4: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
courseDatasets = FileSystem.loadCourseDatasetInfo()
resultsDir = os.path.join(FileSystem.getResultsDir(),projectName)
medianDiffs = []
meanDiffs = []
for course in courseDatasets:
path = os.path.join(resultsDir, course.name + '_contribution.csv')
try:
with open(path) as fid:
forumUserIds = [r.strip() for r in fid.readlines()]
except IOError:
continue
topUserIds = getTopFivePercent(forumUserIds)
DBSetup.switch(course)
threads = ForumThreads.objects.all()
posts = ForumPosts.objects.all()
TC, nonTC = isolateThreadLengths(threads, posts,topUserIds)
TCMedian = median(TC)
nonTCMedian = median(nonTC)
TCMean = mean(TC)
nonTCMean = mean(nonTC)
medianDiffs.append(TCMedian-nonTCMedian)
meanDiffs.append(TCMean-nonTCMean)
print(course.name)
print('Median thread length for threads with posts by top contributors: ' + str(TCMedian))
print('Median thread length for threads without posts by top contributors: ' + str(nonTCMedian))
print('Mean thread length for threads with posts by top contributors: ' + str(TCMean))
print('Mean thread length for threads without posts by top contributors: ' + str(nonTCMean))
print(' ')
print('Average difference between median thread lengths: ' + str(mean(medianDiffs)))
print('Average difference between mean thread lengths: ' + str(mean(meanDiffs)))
示例5: __init__
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def __init__(self):
self.projectName = "PerUserPosting"
self.resultsDir = os.path.join(FileSystem.getResultsDir(), self.projectName)
self.path = os.path.join(self.resultsDir, "results.csv")
self.posters = {}
self._loadPosters()
示例6: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
boundDataDir = os.path.join(FileSystem.getResultsDir(),projectName)
boundDataPath = os.path.join(boundDataDir,'results.csv')
outputPath = os.path.join(boundDataDir,'fullCourseList.csv')
courseData = FileSystem.loadCourseDatasetInfo()
boundData = loadBoundData(boundDataPath)
writeData(outputPath, courseData, boundData)
示例7: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
path = os.path.join(FileSystem.getResultsDir(),projectName,'results.csv')
outPath = os.path.join(FileSystem.getResultsDir(),projectName,'resultsSorted.csv')
strings = {}
numContributions = {}
with open(path) as fid:
rows = fid.readlines()
for r in rows:
row = r.strip().split(', ')
courseName = row[0]
strings[courseName] = r
numContributions[courseName] = float(row[1])
sortedCourseNames = sorted(numContributions.iteritems(), \
key = itemgetter(1), reverse = True)
with open(outPath,'wt') as fid:
for courseName,_ in sortedCourseNames:
fid.write(strings[courseName])
示例8: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
courseDatasets = FileSystem.loadCourseDatasetInfo()
resultsDir = os.path.join(FileSystem.getResultsDir(),projectName)
outputPath = os.path.join(resultsDir,'topContributorPositions.txt')
cumulativeResultsTC = {}
cumulativeResultsNonTC = {}
cumulativeContHistTC = NUMBINS*[0]
cumulativeContHistNonTC = NUMBINS*[0]
ofid = open(outputPath,'wt')
for course in courseDatasets:
print(course.name)
path = os.path.join(resultsDir, course.name + '_contribution.csv')
try:
with open(path) as fid:
forumUserIds = [r.strip() for r in fid.readlines()]
except IOError:
continue
topUserIds = getTopFivePercent(forumUserIds)
DBSetup.switch(course)
forumData = CourseForums()
resultsTC, resultsNonTC, continuousHistTC, continuousHistNonTC = tallyPositions(forumData, topUserIds)
cumulativeResultsTC = addResultsDict(cumulativeResultsTC, resultsTC)
cumulativeResultsNonTC = addResultsDict(cumulativeResultsNonTC, resultsNonTC)
cumulativeContHistTC = addResultsList(cumulativeContHistTC, continuousHistTC)
cumulativeContHistNonTC = addResultsList(cumulativeContHistNonTC, continuousHistNonTC)
ofid.write('--------------------------------------------\n')
ofid.write('Course: ' + course.name + '\n')
ofid.write('Top contributor post position histogram\n')
summarization(ofid, resultsTC, 10)
ofid.write('\n\n')
ofid.write('Non top contributor post position histogram\n')
summarization(ofid, resultsNonTC, 10)
ofid.write('**************************************\n')
ofid.write('Aggregated over courses:\n')
ofid.write('Top contributor post position histogram\n')
summarization(ofid, cumulativeResultsTC, 20)
ofid.write('\n\n')
ofid.write('Non top contributor post position histogram\n')
summarization(ofid, cumulativeResultsNonTC, 20)
ofid.close()
normalizedCumulativeContHistTC = normalize(cumulativeContHistTC)
normalizedCumulativeContHistNonTC = normalize(cumulativeContHistNonTC)
outputPathTC = os.path.join(resultsDir,'normalizedPositionHistTC.csv')
with open(outputPathTC,'wt') as ofid:
for i in range(NUMBINS):
ofid.write(str(i) + ', ' + str(normalizedCumulativeContHistTC[i]) + '\n')
outputPathNonTC = os.path.join(resultsDir,'normalizedPositionHistNonTC.csv')
with open(outputPathNonTC,'wt') as ofid:
for i in range(NUMBINS):
ofid.write(str(i) + ', ' + str(normalizedCumulativeContHistNonTC[i]) + '\n')
示例9: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
path = os.path.join(FileSystem.getResultsDir(),projectName,'results.csv')
fid = open(path)
rows = fid.readlines()
fid.close()
courseNames = []
for r in rows:
courseNames.append(r.strip().split(', ')[0])
courseNames = list(set(courseNames))
for course in courseNames:
print(course)
示例10: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
path = os.path.join(FileSystem.getResultsDir(),projectName,'results.csv')
df = pd.read_csv(path,sep = ', ')
df = killOutliers(df)
X = 'MedianFirstResponseTime'
Y = 'FracLecsViewed'
corrResult = getCorr(df,X,Y)
reportCorrelation(corrResult,X,Y)
X = 'FracOpenThreads'
Y = 'FracLecsViewed'
corrResult = getCorr(df,X,Y)
reportCorrelation(corrResult,X,Y)
X = 'FracOpenThreads'
Y = 'FracQuizSubmissions'
corrResult = getCorr(df,X,Y)
reportCorrelation(corrResult,X,Y)
X = 'AvgNumResponses'
Y = 'FracLecsViewed'
corrResult = getCorr(df,X,Y)
reportCorrelation(corrResult,X,Y)
X = 'MedianNumVotes'
Y = 'FracLecsViewed'
corrResult = getCorr(df,X,Y)
reportCorrelation(corrResult,X,Y)
X = 'FracQuizSubmissions'
Y = 'FracLecsViewed'
corrResult = getCorr(df,X,Y)
reportCorrelation(corrResult,X,Y)
return
X = 'AvgNumResponses'
Y = 'FracLecsViewed'
figId = 1
plotCorr(figId,df,X,Y,15)
X = 'AvgNumResponses'
Y = 'FracQuizSubmissions'
figId = 2
plotCorr(figId,df,X,Y,15)
X = 'MedianFirstResponseTime'
Y = 'FracLecsViewed'
figId = 3
plotCorr(figId,df,X,Y,5)
示例11: mergeCorrelationResults
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def mergeCorrelationResults(projectName):
courseList = FileSystem.loadCourseList()
resultsDir = os.path.join(FileSystem.getResultsDir(),projectName)
results = []
for course in courseList:
currDir = os.path.join(resultsDir,course)
path = os.path.join(currDir,'ForumActivityVsQuizScore_regression.csv')
pathStats = os.path.join(currDir,'CourseStats.csv')
try:
currResults = loadRegressionResults(path)
currCourseStats = loadCourseStats(pathStats)
results.append((course,currResults,currCourseStats))
except IOError:
continue
outputPath = os.path.join(resultsDir,'mergedCorrelationResults.csv')
writeMergedCorrelationResults(results, outputPath)
示例12: mergeCorrelationResults
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def mergeCorrelationResults(projectName):
courseList = FileSystem.loadCourseList()
resultsDir = os.path.join(FileSystem.getResultsDir(),projectName)
resultsScore = []
resultsLectures = []
for course in courseList:
currDir = os.path.join(resultsDir,course)
pathScore = os.path.join(currDir,'allForumVsFinalScore_regression.csv')
pathLectures = os.path.join(currDir,'allForumVsLecturesViewed_regression.csv')
try:
currResults = loadRegressionResults(pathScore)
resultsScore.append((course,currResults))
except IOError:
continue
try:
currResults = loadRegressionResults(pathLectures)
resultsLectures.append((course,currResults))
except IOError:
continue
outputPath = os.path.join(resultsDir,'mergedCorrelationResults.csv')
writeMergedCorrelationResults(resultsScore,resultsLectures,outputPath)
示例13: combineResults
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def combineResults(projectName):
courseList = FileSystem.loadCourseList()
resultsDir = os.path.join(FileSystem.getResultsDir(),projectName)
forumActivities = []
finalGrades = []
forumActivities2 = []
lecturesViewed = []
for course in courseList:
currDir = os.path.join(resultsDir, course)
pathScore = os.path.join(currDir,'allForumVsFinalScore.csv')
try:
forumActivity, finalGrade = loadResults(pathScore)
forumActivities += forumActivity
finalGrades += finalGrade
except IOError:
continue
pathLectures = os.path.join(currDir,'allForumVsLecturesViewed.csv')
try:
forumActivity, numLectures = loadResults(pathLectures)
forumActivities2 += forumActivity
lecturesViewed += numLectures
except IOError:
continue
outputPathScore = os.path.join(resultsDir,'allForumVsFinalScore.csv')
regressOutputPathScore = os.path.join(resultsDir,'allForumVsFinalScore_regression.csv')
outputPathLectures = os.path.join(resultsDir,'allForumVsLectures.csv')
regressOutputPathLectures = os.path.join(resultsDir,'allForumVsLectures_regression.csv')
forumActivitiesHistPath = os.path.join(resultsDir,'allForum_hist.csv')
finalGradesHistPath = os.path.join(resultsDir,'finalScore_hist.csv')
lecturesHistPath = os.path.join(resultsDir,'lecturesViewed_hist.csv')
writeResults(forumActivities, finalGrades, outputPathScore)
writeRegressionResults(forumActivities, finalGrades, regressOutputPathScore)
writeResults(forumActivities, lecturesViewed, outputPathLectures)
writeRegressionResults(forumActivities2, lecturesViewed, regressOutputPathLectures)
writeHistogram(forumActivities, forumActivitiesHistPath, limits = (-3.0,3.0))
writeHistogram(finalGrades, finalGradesHistPath, limits = (-3.0, 3.0))
writeHistogram(lecturesViewed, lecturesHistPath, limits = (-3.0, 3.0))
示例14: run
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
def run(projectName):
courseDatasets = FileSystem.loadCourseDatasetInfo()
resultsDir = os.path.join(FileSystem.getResultsDir(),projectName)
outputPath = os.path.join(resultsDir,'topContributorPositions.txt')
numTopContributors = 0
numContributors = 0
for course in courseDatasets:
print(course.name)
path = os.path.join(resultsDir, course.name + '_contribution.csv')
try:
with open(path) as fid:
forumUserIds = [r.strip() for r in fid.readlines()]
except IOError:
continue
topUserIds = getTopFivePercent(forumUserIds)
numTopContributors += len(topUserIds)
numContributors += len(forumUserIds)
print('Number of Top Contributors: ' + str(numTopContributors))
print('Number of contributors: ' + str(numContributors))
示例15: loadResults
# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import getResultsDir [as 别名]
sys.path.append(FileSystem.getSiteDir())
from numpy import mean, std
def loadResults(resultsDir):
resultsMean = []
resultsStd = []
for k in range(100):
path = os.path.join(resultsDir, "results" + str(k) + ".csv")
ratioList = []
with open(path) as fid:
rows = fid.readlines()
for r in rows:
ratioList.append(float(r.rstrip().split(", ")[-1]))
resultsMean.append(mean(ratioList))
resultsStd.append(std(ratioList))
return resultsMean, resultsStd
def writeResults(path, resultsMean, resultsStd):
with open(path, "wt") as fid:
fid.write("t, mean of ratios, std of ratios\n")
for (k, m, s) in zip(range(100), resultsMean, resultsStd):
fid.write(str(k) + ", " + str(m) + ", " + str(s) + "\n")
resultsDir = os.path.join(FileSystem.getResultsDir(), "SubscriptionRatio")
outputPath = os.path.join(resultsDir, "combinedResults.csv")
resultsMean, resultsStd = loadResults(resultsDir)
writeResults(outputPath, resultsMean, resultsStd)