Skip to content
Browse files

modeified models

  • Loading branch information...
1 parent b19c58f commit 836c98164d5287a8b852b9fa1279bc0a816dbd74 @kykamath committed Sep 20, 2012
View
0 data/linear_regression → ...tags_for_locations/data/linear_regression
File renamed without changes.
View
29 hashtags_for_locations/models.py
@@ -139,13 +139,24 @@ class EvaluationMetrics:
def _bestHashtagsForLocation(actualPropagation, **conf):
bestHashtagsForLocation = {}
for loc, occs in actualPropagation.occurrences.iteritems():
- bestHashtagsForLocation[loc] = zip(*
- sorted([
- (h, len(list(hOccs)))
+ if 'hashtags_with_scores' in conf and conf['hashtags_with_scores']:
+ num_of_occs = float(len(occs))
+ bestHashtagsForLocation[loc] = sorted([(h, len(list(hOccs))/num_of_occs)
for h, hOccs in
- groupby(sorted(occs, key=itemgetter(0)), key=itemgetter(0))],
- key=itemgetter(1))
- )[0][-conf['noOfTargetHashtags']:]
+ groupby(sorted(occs, key=itemgetter(0)), key=itemgetter(0))
+ ],
+ key=itemgetter(1))[-conf['noOfTargetHashtags']:]
+ else:
+ bestHashtagsForLocation[loc] = zip(*
+ sorted([
+ (h, len(list(hOccs)))
+ for h, hOccs in
+ groupby(sorted(occs,key=itemgetter(0)),
+ key=itemgetter(0)
+ )
+ ],
+ key=itemgetter(1))
+ )[0][-conf['noOfTargetHashtags']:]
return bestHashtagsForLocation
@staticmethod
def _impact(loc, hashtags, actualPropagation):
@@ -529,6 +540,7 @@ def moved_model_files_to_chevron(self):
GeneralMethods.runCommand('cp %s %s'%(model_file, output_file))
def runToGetDataForLinearRegression(self):
+ self.conf['hashtags_with_scores'] = True
currentTime = self.startTime
timeUnitDelta = timedelta(seconds=TIME_UNIT_IN_SECONDS)
historicalTimeUnitsMap, predictionTimeUnitsMap = {}, {}
@@ -590,7 +602,6 @@ def runToGetDataForLinearRegression(self):
)
mf_model_id_to_mf_location_to_hashtags_ranked_by_model = {}
for modelId in self.predictionModels:
- self.conf['hashtags_with_scores'] = True
hashtagsForLattice = PREDICTION_MODEL_METHODS[modelId](
historicalTimeUnitsMap[timeUnitForPropagationForPrediction],
**self.conf
@@ -827,8 +838,8 @@ def generateDataForLinearRegression(predictionModels, evaluationMetrics, startTi
outputFolder,
predictionModels,
evaluationMetrics,
-# **conf).runToGetDataForLinearRegression()
- **conf).moved_model_files_to_chevron()
+ **conf).runToGetDataForLinearRegression()
+# **conf).moved_model_files_to_chevron()
@staticmethod
def getImageFileName(metric): return 'images/%s_%s.png'%(inspect.stack()[1][3], metric)
@staticmethod
View
5 hashtags_for_locations/mr_analysis_for_ltr.py
@@ -0,0 +1,5 @@
+'''
+Created on Sep 19, 2012
+
+@author: kykamath
+'''
View
4 hashtags_for_locations/temp.py
@@ -42,5 +42,5 @@
# tuples_of_neighbor_location_and_pure_influence_score= sorted(tuples_of_neighbor_location_and_pure_influence_score, key=itemgetter(1))
# print tuples_of_neighbor_location_and_pure_influence_score
-for data in FileIO.iterateJsonFromFile('/mnt/chevron/kykamath/data/geo/hashtags/hashtags_for_locations/testing/models_1/2011-09-01_2011-11-01/360_60/100/linear_regression'):
- print data['mf_model_id_to_mf_location_to_hashtags_ranked_by_model'].keys(), data.keys()
+for data in FileIO.iterateJsonFromFile('data/linear_regression'):
+ print data['mf_location_to_ideal_hashtags_rank'], data.keys()

0 comments on commit 836c981

Please sign in to comment.
Something went wrong with that request. Please try again.