effspm 0.3.1__cp310-cp310-macosx_11_0_arm64.whl → 0.3.3__cp310-cp310-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
effspm/_effspm.cpp CHANGED
@@ -163,73 +163,187 @@ PYBIND11_MODULE(_effspm, m) {
163
163
  // ─────────────────────────────────────────────────────────────
164
164
  // BTMiner (always uses professor's Load_instance)
165
165
  // ─────────────────────────────────────────────────────────────
166
- m.def("BTMiner",
167
- [](py::object data,
168
- double minsup,
169
- unsigned int time_limit,
170
- bool preproc,
171
- bool use_dic,
172
- bool verbose,
173
- const std::string &out_file)
174
- {
175
- // Configure professor globals
176
- btminer::time_limit = static_cast<int>(time_limit);
177
- btminer::pre_pro = preproc;
178
- btminer::use_dic = use_dic;
179
- btminer::b_disp = verbose;
180
- btminer::b_write = !out_file.empty();
181
- btminer::out_file = out_file;
182
- btminer::N_mult = 1;
183
- btminer::M_mult = 1;
184
- btminer::just_build = false;
185
-
186
- btminer::ClearCollected();
187
- btminer::start_time = std::clock();
166
+ // ─────────────────────────────────────────────────────────────
167
+ // BTMiner (always uses professor's Load_instance)
168
+ // ─────────────────────────────────────────────────────────────
169
+ /*m.def("BTMiner",
170
+ [](py::object data,
171
+ double minsup,
172
+ unsigned int time_limit,
173
+ bool preproc,
174
+ bool use_dic,
175
+ bool verbose,
176
+ const std::string &out_file)
177
+ {
178
+ // 1) Configure professor globals
179
+ btminer::time_limit = static_cast<int>(time_limit);
180
+ btminer::pre_pro = preproc;
181
+ btminer::use_dic = use_dic;
182
+ btminer::b_disp = verbose;
183
+ btminer::b_write = !out_file.empty();
184
+ btminer::out_file = out_file;
185
+ btminer::N_mult = 1;
186
+ btminer::M_mult = 1;
187
+ btminer::just_build = false;
188
188
 
189
- TempFile tmp;
190
- std::string path;
189
+ // 2) HARD RESET of *known* global state for BTMiner
190
+ // (Only touch what we know exists in btminer namespace)
191
+ btminer::ClearCollected(); // clear collected patterns
192
+ btminer::Tree.clear(); // clear MDD tree
193
+ btminer::DFS.clear(); // clear DFS patterns
191
194
 
192
- if (py::isinstance<py::str>(data)) {
193
- // File path: use directly
194
- path = data.cast<std::string>();
195
- } else {
196
- // Python list → write to a temp file in the same format
197
- auto seqs = data.cast<std::vector<std::vector<int>>>();
198
- tmp.path = write_temp_seq_file(seqs);
199
- path = tmp.path;
200
- }
195
+ btminer::M = 0;
196
+ btminer::L = 0;
197
+ btminer::N = 0;
198
+ btminer::theta = 0;
199
+ btminer::E = 0;
200
+ btminer::num_patt = 0; // reset pattern counter if defined
201
201
 
202
- if (verbose) {
203
- std::cerr << "[BTMiner] path=" << path
204
- << " minsup=" << minsup
205
- << " preproc=" << preproc
206
- << " use_dic=" << use_dic
207
- << std::endl;
208
- }
202
+ // NOTE: we do NOT reinsert root here; btminer::Load_instance()
203
+ // is responsible for calling Tree.emplace_back(0,0,0) as needed.
209
204
 
210
- if (!btminer::Load_instance(path, minsup)) {
211
- throw std::runtime_error("BTMiner: failed to load instance from: " + path);
212
- }
205
+ btminer::start_time = std::clock();
213
206
 
214
- btminer::Freq_miner();
207
+ // 3) Handle input (path or list-of-lists)
208
+ TempFile tmp;
209
+ std::string path;
215
210
 
216
- py::dict out;
217
- out["patterns"] = btminer::GetCollected();
218
- out["num_patterns"] = btminer::num_patt;
219
- out["time"] = btminer::give_time(std::clock() - btminer::start_time);
220
- out["N"] = btminer::N;
221
- out["L"] = btminer::L;
222
- out["theta"] = btminer::theta;
223
- return out;
224
- },
225
- py::arg("data"),
226
- py::arg("minsup") = 0.01,
227
- py::arg("time_limit") = 36000,
228
- py::arg("preproc") = false,
229
- py::arg("use_dic") = false,
230
- py::arg("verbose") = false,
231
- py::arg("out_file") = ""
232
- );
211
+ if (py::isinstance<py::str>(data)) {
212
+ // File path: use directly
213
+ path = data.cast<std::string>();
214
+ } else {
215
+ // Python list → write to a temp file in professor’s format
216
+ auto seqs = data.cast<std::vector<std::vector<int>>>();
217
+ tmp.path = write_temp_seq_file(seqs);
218
+ path = tmp.path;
219
+ }
220
+
221
+ if (verbose) {
222
+ std::cerr << "[BTMiner] path=" << path
223
+ << " minsup=" << minsup
224
+ << " preproc=" << preproc
225
+ << " use_dic=" << use_dic
226
+ << std::endl;
227
+ }
228
+
229
+ // 4) Build MDD + run miner
230
+ if (!btminer::Load_instance(path, minsup)) {
231
+ throw std::runtime_error("BTMiner: failed to load instance from: " + path);
232
+ }
233
+
234
+ btminer::Freq_miner();
235
+
236
+ // 5) Return results
237
+ py::dict out;
238
+ out["patterns"] = btminer::GetCollected();
239
+ out["num_patterns"] = btminer::num_patt;
240
+ out["time"] = btminer::give_time(std::clock() - btminer::start_time);
241
+ out["N"] = btminer::N;
242
+ out["L"] = btminer::L;
243
+ out["theta"] = btminer::theta;
244
+ return out;
245
+ },
246
+ py::arg("data"),
247
+ py::arg("minsup") = 0.01,
248
+ py::arg("time_limit") = 36000,
249
+ py::arg("preproc") = false,
250
+ py::arg("use_dic") = false,
251
+ py::arg("verbose") = false,
252
+ py::arg("out_file") = ""
253
+ ); */
254
+ m.def("BTMiner",
255
+ [](py::object data,
256
+ double minsup,
257
+ unsigned int time_limit,
258
+ bool preproc,
259
+ bool use_dic,
260
+ bool verbose,
261
+ const std::string &out_file)
262
+ {
263
+ // 1) Configure professor globals
264
+ btminer::time_limit = static_cast<int>(time_limit);
265
+ btminer::pre_pro = preproc;
266
+ btminer::use_dic = use_dic;
267
+ btminer::b_disp = verbose;
268
+ btminer::b_write = !out_file.empty();
269
+ btminer::out_file = out_file;
270
+ btminer::N_mult = 1;
271
+ btminer::M_mult = 1;
272
+ btminer::just_build = false;
273
+
274
+ // 2) HARD RESET of *known* global state for BTMiner
275
+ btminer::ClearCollected(); // clear collected patterns
276
+ btminer::Tree.clear(); // clear MDD tree
277
+ btminer::DFS.clear(); // clear DFS patterns
278
+
279
+ // clear all frequency / mapping / item structures
280
+ btminer::freq.clear();
281
+ btminer::item_dic.clear();
282
+ btminer::item_map.clear();
283
+ btminer::item_map_rev.clear();
284
+ btminer::items.clear(); // if you have this defined anywhere
285
+
286
+ // reset scalar globals
287
+ btminer::M = 0;
288
+ btminer::L = 0;
289
+ btminer::N = 0;
290
+ btminer::theta = 0;
291
+ btminer::E = 0;
292
+ btminer::num_patt = 0;
293
+ btminer::num_nodes = 0;
294
+ btminer::cur_node = 0;
295
+ // N_mult, M_mult, flags are set just above
296
+
297
+ btminer::start_time = std::clock();
298
+
299
+
300
+ // 3) Handle input (path or list-of-lists)
301
+ TempFile tmp;
302
+ std::string path;
303
+
304
+ if (py::isinstance<py::str>(data)) {
305
+ // File path: use directly
306
+ path = data.cast<std::string>();
307
+ } else {
308
+ // Python list → write to a temp file in professor’s format
309
+ auto seqs = data.cast<std::vector<std::vector<int>>>();
310
+ tmp.path = write_temp_seq_file(seqs);
311
+ path = tmp.path;
312
+ }
313
+
314
+ if (verbose) {
315
+ std::cerr << "[BTMiner] path=" << path
316
+ << " minsup=" << minsup
317
+ << " preproc=" << preproc
318
+ << " use_dic=" << use_dic
319
+ << std::endl;
320
+ }
321
+
322
+ // 4) Build MDD + run miner
323
+ if (!btminer::Load_instance(path, minsup)) {
324
+ throw std::runtime_error("BTMiner: failed to load instance from: " + path);
325
+ }
326
+
327
+ btminer::Freq_miner();
328
+
329
+ // 5) Return results
330
+ py::dict out;
331
+ out["patterns"] = btminer::GetCollected();
332
+ out["num_patterns"] = btminer::num_patt;
333
+ out["time"] = btminer::give_time(std::clock() - btminer::start_time);
334
+ out["N"] = btminer::N;
335
+ out["L"] = btminer::L;
336
+ out["theta"] = btminer::theta;
337
+ return out;
338
+ },
339
+ py::arg("data"),
340
+ py::arg("minsup") = 0.01,
341
+ py::arg("time_limit") = 36000,
342
+ py::arg("preproc") = false,
343
+ py::arg("use_dic") = false,
344
+ py::arg("verbose") = false,
345
+ py::arg("out_file") = ""
346
+ );
233
347
 
234
348
  // ─────────────────────────────────────────────────────────────
235
349
  // HTMiner (works on files; we use a temp file for in-memory data)
@@ -329,49 +443,68 @@ m.def("HTMiner",
329
443
  // ─────────────────────────────────────────────────────────────
330
444
  // LargePrefixProjection (already has its own Load_py)
331
445
  // ─────────────────────────────────────────────────────────────
332
- m.def("LargePrefixProjection",
333
- [](py::object data,
334
- double minsup,
335
- unsigned int time_limit,
336
- bool preproc,
337
- bool use_dic,
338
- bool verbose,
339
- const std::string &out_file)
340
- {
341
- largepp::time_limit = time_limit;
342
- largepp::pre_pro = preproc;
343
- largepp::use_dic = use_dic;
344
- largepp::use_list = true; // large prefix uses list-based mining
345
- largepp::b_disp = verbose;
346
- largepp::b_write = !out_file.empty();
347
- largepp::out_file = out_file;
348
- largepp::just_build = false;
349
-
350
- largepp::ClearCollected();
351
- largepp::start_time = std::clock();
446
+ m.def("LargePrefixProjection",
447
+ [](py::object data,
448
+ double minsup,
449
+ unsigned int time_limit,
450
+ bool preproc,
451
+ bool use_dic,
452
+ bool verbose,
453
+ const std::string &out_file)
454
+ {
455
+ // 1) Configure global flags
456
+ largepp::time_limit = time_limit;
457
+ largepp::pre_pro = preproc;
458
+ largepp::use_dic = use_dic;
459
+ largepp::use_list = true; // LargePrefixProjection is list-based
460
+ largepp::b_disp = verbose;
461
+ largepp::b_write = !out_file.empty();
462
+ largepp::out_file = out_file;
463
+ largepp::just_build = false;
352
464
 
353
- if (py::isinstance<py::str>(data)) {
354
- std::string fname = data.cast<std::string>();
355
- largepp::Load_instance(fname, minsup);
356
- } else {
357
- largepp::Load_py(data, minsup);
358
- }
465
+ // 2) HARD RESET of largepp global state
466
+ // (only touch symbols that actually exist in largepp)
467
+ largepp::ClearCollected(); // clear previously collected patterns
359
468
 
360
- largepp::Freq_miner();
469
+ // If these exist in largepp::load_inst.hpp / utility.hpp they’ll compile;
470
+ // if the compiler complains about any of them, just comment that line out.
471
+ largepp::items.clear(); // transaction DB
472
+ largepp::DFS.clear(); // DFS pattern stack, if list-based miner uses it
361
473
 
362
- py::dict out;
363
- out["patterns"] = largepp::GetCollected();
364
- out["time"] = largepp::give_time(std::clock() - largepp::start_time);
365
- return out;
366
- },
367
- py::arg("data"),
368
- py::arg("minsup") = 0.01,
369
- py::arg("time_limit") = 36000,
370
- py::arg("preproc") = false,
371
- py::arg("use_dic") = false,
372
- py::arg("verbose") = false,
373
- py::arg("out_file") = ""
374
- );
474
+ largepp::M = 0;
475
+ largepp::L = 0;
476
+ largepp::N = 0;
477
+ largepp::theta = 0;
478
+ largepp::E = 0;
479
+ largepp::num_patt = 0;
480
+
481
+ largepp::start_time = std::clock();
482
+
483
+ // 3) Handle input (path or Python list)
484
+ if (py::isinstance<py::str>(data)) {
485
+ std::string fname = data.cast<std::string>();
486
+ largepp::Load_instance(fname, minsup);
487
+ } else {
488
+ largepp::Load_py(data, minsup);
489
+ }
490
+
491
+ // 4) Run miner
492
+ largepp::Freq_miner();
493
+
494
+ // 5) Return results
495
+ py::dict out;
496
+ out["patterns"] = largepp::GetCollected();
497
+ out["time"] = largepp::give_time(std::clock() - largepp::start_time);
498
+ return out;
499
+ },
500
+ py::arg("data"),
501
+ py::arg("minsup") = 0.01,
502
+ py::arg("time_limit") = 36000,
503
+ py::arg("preproc") = false,
504
+ py::arg("use_dic") = false,
505
+ py::arg("verbose") = false,
506
+ py::arg("out_file") = ""
507
+ );
375
508
 
376
509
  // ─────────────────────────────────────────────────────────────
377
510
  // LargeBTMiner (always uses professor's largebm::Load_instance)
Binary file
@@ -31,7 +31,7 @@ map<int, string> item_map_rev;
31
31
 
32
32
  std::vector<int> freq;
33
33
  std::vector<int> item_dic;
34
-
34
+ std::vector<std::vector<int>> items;
35
35
  // ✅ REAL DEFINITION lives here:
36
36
  std::vector<Pattern> DFS;
37
37
 
@@ -103,6 +103,15 @@ bool Load_instance(string &items_file, double thresh) {
103
103
  // preprocessing pass
104
104
  // ---------------------------------------------------------------------
105
105
  bool Preprocess(string &inst, double thresh) {
106
+ N = 0;
107
+ L = 0;
108
+ freq.clear();
109
+ item_dic.clear();
110
+ item_map.clear();
111
+ item_map_rev.clear();
112
+ // (E is usually for entries during Build_MDD, so we can leave it
113
+ // for the load phase; it’s already reset in the binding)
114
+
106
115
  ifstream file(inst);
107
116
 
108
117
  if (file.good()) {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: effspm
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Prefix‑Projection and other sequential pattern mining algorithms
5
5
  Author: Yeswanth Vootla
6
6
  Author-email: yeshu999 <vootlayeswanth20@gmail.com>
@@ -2,9 +2,9 @@ effspm/utility.hpp,sha256=Y_MQVk9AmJWjguKyuyk0LraTi_6VzZFg0StsmVOCkNc,744
2
2
  effspm/_core.cpp,sha256=S6UsUcl0HQLMQUTy2tMJxcrbLGJo8tjkLskyHqESYyI,3675
3
3
  effspm/load_inst.hpp,sha256=VF0o_Ur-mO5xhdWWn1KHrFLu9_bTbd8wcURCVF0A0dM,907
4
4
  effspm/__init__.py,sha256=_BkZ8cFlB_l1haxTzxJMgFHhO6LEmF3pIY-nmPTPMj8,246
5
- effspm/_effspm.cpython-310-darwin.so,sha256=TXG4lKppINPcRAjDsYM_1Mdqn05Ss3fKv6cj58CG7gk,547152
5
+ effspm/_effspm.cpython-310-darwin.so,sha256=yKRIaI44JpARZ4jpfUqryX_fYGSGUnzzc1XtKEH7gQM,547216
6
6
  effspm/freq_miner.cpp,sha256=9K-nO_c-vVzbFlmh511vmvypA2fu1TXpiJhyx03owDU,4642
7
- effspm/_effspm.cpp,sha256=a-jgUMb1WY7gyXGYCKG_ncDcMaVgTaxpVqtVOTnOtM0,46304
7
+ effspm/_effspm.cpp,sha256=NkxFvVVbR5CAsSUZO5Z_Z-UwFVCQRhy6_st8_cD-2Us,51027
8
8
  effspm/load_inst.cpp,sha256=h9pjtvRCIrtqIAt8W1r8SxOb1YViW1pCR52tbxbPdh0,4591
9
9
  effspm/freq_miner.hpp,sha256=XDhydwUFmute6slWwZcFuiBjGZs4Kv5-UvAmcI_IMwI,786
10
10
  effspm/utility.cpp,sha256=luWwBNy7OVWRmam9gz2RjhtrRmx6c37oOobFJaDWqcA,1403
@@ -48,13 +48,13 @@ effspm/btminer/src/build_mdd.cpp,sha256=7J5KMNNB3DngB4Bkn1h-zMfAgRvRiXP4MEkPbd3C
48
48
  effspm/btminer/src/utility.hpp,sha256=5m34T2ATvYY_32Sz6h0Zro4kLolosPwASJF0TiDKhhI,312
49
49
  effspm/btminer/src/load_inst.hpp,sha256=Fj72XjlR7ppGi76vc0PMZZAkj_-JklTVuIqzbsZcTAw,987
50
50
  effspm/btminer/src/freq_miner.cpp,sha256=sTA-bkUZqgFU9tVtSsUUfaVj7BU8MiFZm3scwRsxMeg,9192
51
- effspm/btminer/src/load_inst.cpp,sha256=yRHso99ban7sQNe2SpZpXeNUXu0NDVNq4-rt1yZVoso,8083
51
+ effspm/btminer/src/load_inst.cpp,sha256=fquloXEJlmSXYbwstgX_lAO5-ar0CS6Gx1cfHQRQbS0,8366
52
52
  effspm/btminer/src/freq_miner.hpp,sha256=sS2CGdNT0zSGtSz0evZZlUkuiKyWlSvrR3-M2YXP7-Q,1055
53
53
  effspm/btminer/src/build_mdd.hpp,sha256=p0pEcNZMD-WqV0UB1WtOn-Soe0105gEL071Ht5okgJM,627
54
54
  effspm/btminer/src/utility.cpp,sha256=YmwdNPCUHFjydwrUAyBLEkFqUecyg7r4HbPdgoD-j3s,1194
55
55
  effspm/btminer/src/main.cpp,sha256=Jh9M5nsZUL3i-iENn7Jh--TOY0F5dnu6CvqZ7udWU3A,2678
56
- effspm-0.3.1.dist-info/RECORD,,
57
- effspm-0.3.1.dist-info/WHEEL,sha256=wyHf6UDzyHyUK-aDYscyyyExpYI7SeEZ9xjyEiU4cnw,109
58
- effspm-0.3.1.dist-info/top_level.txt,sha256=2O-AuI0nw0pDmJMo2jzM1wvV2rj48AmkjskkAnsuuQk,7
59
- effspm-0.3.1.dist-info/METADATA,sha256=jG2oHQWgpsHroT6mN4Qx59ujH-PkD-9aruzN3lWtQxU,14227
60
- effspm-0.3.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ effspm-0.3.3.dist-info/RECORD,,
57
+ effspm-0.3.3.dist-info/WHEEL,sha256=wyHf6UDzyHyUK-aDYscyyyExpYI7SeEZ9xjyEiU4cnw,109
58
+ effspm-0.3.3.dist-info/top_level.txt,sha256=2O-AuI0nw0pDmJMo2jzM1wvV2rj48AmkjskkAnsuuQk,7
59
+ effspm-0.3.3.dist-info/METADATA,sha256=0V27Cms7UBjdK62_SOAdqiAhq0bOIByG6oUTTALZEn8,14227
60
+ effspm-0.3.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
File without changes