Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update greedy_similarity_binning.py #930

Closed

Conversation

humbleOldSage
Copy link
Contributor

@humbleOldSage humbleOldSage commented Aug 11, 2023

Added a new list type variable to store labels at one place in order of trips processed. Explained at e-mission/e-mission-eval-private-data#35 (comment) and e-mission/e-mission-eval-private-data#35 (comment).

Added a new list type variable to store  labels at one place in order of trips processed.
@@ -121,6 +121,7 @@ class label to apply:
self.is_incremental = config['incremental_evaluation']

self.bins: Dict[str, Dict] = {}
self.tripLabels=[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we need a separate array here.
the bins already are indexed by the bin_id, and bin has the labels in it

"25": {
'feature_rows': ....
'labels':...
}

So I don't see what this is adding to the data structure

Copy link
Contributor Author

@humbleOldSage humbleOldSage Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clustering.py file ( which calls this function) file builds on data_loc dataframe that requires

Trip 1   -->    bin No. (say 2)
Trip 2.  -->    bin No. (say 3) 
Trip 3   -->   bin No.( say 2)
Trip 4   -->   bin No.( say 1)
Trip 5   -->   bin No.( say 1)
.
.
.

However, the way they are stored here is .

  "1": { 'feature_rows': [ [feature of Trip4], [feature of Trip5]]
            'labels': ...
  }
  
  "2": { 'feature_rows': [ [feature of Trip1], [feature of Trip3]]
            'labels': ...
  }
  
  "3": { 'feature_rows': [ [feature of Trip2]]
            'labels': ...
  }

Surely, we can extract the trip and its bin from the way they are already stored, but creating a separate array initially itself feels more efficient.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the problem with creating an additional data structure is that then we are changing production code to make analysis easier. We don't really need the trip -> bin mapping on production, and at some point, might want to include memoization as well. So I would prefer doing the additional work in clustering.py to create the dataframe from the output of the production model and not the other way around.

Copy link
Contributor Author

@humbleOldSage humbleOldSage Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I'll remove the extra data structure and move all the additional computations to clustering.py.

These changes were done to return `entry` type data ( alongside dataframe) to clustering_example.ipynb.
Comment on lines +26 to +28

entryList=[]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@humbleOldSage this is wrong. There is not only one set of entries in the database. Please read and understand the data model from chapter 5 of my thesis.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured this was not necessary

Comment on lines +267 to +269
def getEntryList(self):
return self.entryList

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, this is wrong as well. you can't return the entry list because there is not just one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are existing methods to get an entry list. the trip model uses existing methods. You should not have to make changes to the BuiltinTimeseries for this change.

Comment on lines +300 to +303
for e in entry_it:
BuiltinTimeSeries.entryList.append(map_fn(e))
df = pd.DataFrame(BuiltinTimeSeries.entryList)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@humbleOldSage
Copy link
Contributor Author

NO changes needed here if, e-mission/e-mission-eval-private-data#37 are approved.

@shankari
Copy link
Contributor

Closing this since all changes are in e-mission/e-mission-eval-private-data#37

@shankari shankari closed this Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants