Class SieveStreamingPP¶
Defined in File SieveStreamingPP.h
Inheritance Relationships¶
Base Type¶
public SubmodularOptimizer(Class SubmodularOptimizer)
Class Documentation¶
-
class SieveStreamingPP : public SubmodularOptimizer¶
The SieveStreaming++ optimizer for nonnegative, monotone submodular functions. This is an improved version of SieveStreaming which re-samples thresholds once a new (better) lower bound is detected. Note that this implementation also requires that \( m = max_e f({e}) \) is known beforehand.
Stream: Yes
Solution: \( 1/2 - \varepsilon \)
Runtime: \( O(1) \)
Memory: \( O(K / \varepsilon) \)
Function Queries per Element: \( O(log(K) / \varepsilon) \)
Function Types: nonnegative, monotone submodular functions
Example usage in C++:
//read some data std::vector<std::vector<data_t>> = read_some_data(); auto K = 50; // Define the function to be maximized and select the summary FastIVM fastIVM(K, RBFKernel( std::sqrt(data[0].size()), 1.0) , 1.0); SieveStreamingPP opt(K, fastIVM, 1.0, 0.1); opt.fit(data); std::cout << "fval:" << opt.get_fval() << "num_elements: " << opt.get_num_elements_stored() << "num_candidates: " << opt.get_num_candidate_solutions() << std::endl; // Process summary auto summary = opt.get_solution();
Example usage in Python:
X = read_some_data(); K = 50 # Create function to be maximized kernel = RBFKernel(sigma=sigma,scale=scale) fastLogDet = FastIVM(K, kernel, 1.0) opt = SieveStreamingPP(K, fastLogDet, 1.0, 0.1) opt.fit(X, K) print("fval: {} num_elements: {} num_candidates: {}".format(opt.get_fval(), opt.get_num_elements_stored(), opt.get_num_candidate_solutions())) # process summary summary = opt.get_solution()
References
Note
Since this is an extension of SieveStreaming it seems likely that this class should be an extension of SieveStreaming. However, I decided against this, since the actual benefit by this is minimal. The
fitis substantially different from SieveStreaming and the internal Sieve class uses a slightly different thresholding rule. Thus I decided to separate both implementations.Kazemi, E., Mitrovic, M., Zadimoghaddam, M., Lattanzi, S., & Karbasi, A. (2019). Submodular streaming in all its glory: Tight approximation, minimum memory and low adaptive complexity. 36th International Conference on Machine Learning, ICML 2019, 2019-June, 5767–5784. Retrieved from http://proceedings.mlr.press/v97/kazemi19a/kazemi19a.pdf
Public Functions
-
inline SieveStreamingPP(unsigned int K, SubmodularFunction &f, data_t m, data_t epsilon)¶
Construct a new SieveStreamingPP object.
- Parameters
K – The cardinality constraint you of the optimization problem, that is the number of items selected.
f – The function which should be maximized. Note, that the clone function is used to construct a new SubmodularFunction which is owned by this object. If you implement a custom SubmodularFunction make sure that everything you need is actually cloned / copied.
m – The maximum value of the singleton set, \( m = max_e f({e}) \)
epsilon – The sampling accuracy for threshold generation
-
inline SieveStreamingPP(unsigned int K, std::function<data_t(std::vector<std::vector<data_t>> const&)> f, data_t m, data_t epsilon)¶
Construct a new SieveStreamingPP object.
- Parameters
K – The cardinality constraint you of the optimization problem, that is the number of items selected.
f – The function which should be maximized. Note, that this parameter is likely moved and not copied. Thus, if you construct multiple optimizers with the same function they all reference the same function. This can be very efficient for state-less functions, but may lead to weird side effects if f keeps track of a state.
m – The maximum value of the singleton set, \( m = max_e f({e}) \)
epsilon – The sampling accuracy for threshold generation
-
inline virtual unsigned int get_num_candidate_solutions() const¶
Returns the number of sieves.
-
inline virtual unsigned long get_num_elements_stored() const¶
Returns the total number of items stored across all sieves.
-
inline virtual void next(std::vector<data_t> const &x, std::optional<idx_t> const id = std::nullopt)¶
Consume the next object in the data stream. This checks for each sieve if the given object exceeds the marginal gain threshold and adds it to the corresponding solution.
- Parameters
&x – A constant reference to the next object on the stream.
id – The id of the given object. If this is a
std::nulloptthis parameter is ignored. Otherwise the id is inserted into the solution. Make sure, that either all or no object receives an id to keep track which id belongs to which object. This algorithm simply stores the objects and the ids in two separate lists and performs no safety checks.