Code Monkey home page Code Monkey logo

Comments (3)

timmyers15 avatar timmyers15 commented on July 18, 2024 1

Thanks for the reply! I'm running Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32

The full error is below......

C:\Users\timmy\OneDrive\Documents\Python For Everybody\Seq2Pat>seqPatMineTest.py
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "C:\Program Files\Python37\lib\multiprocessing\spawn.py", line 114, in _main
    prepare(preparation_data)
  File "C:\Program Files\Python37\lib\multiprocessing\spawn.py", line 225, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Program Files\Python37\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
    run_name="__mp_main__")
  File "C:\Program Files\Python37\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Program Files\Python37\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Program Files\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\timmy\OneDrive\Documents\Python For Everybody\Seq2Pat\seqPatMineTest.py", line 37, in <module>
    results = seq2pat.get_patterns(min_frequency=2)
  File "C:\Users\timmy\AppData\Roaming\Python\Python37\site-packages\sequential\seq2pat.py", line 526, in get_patterns
    thread.start()
  File "C:\Program Files\Python37\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "C:\Program Files\Python37\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Program Files\Python37\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "C:\Program Files\Python37\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Program Files\Python37\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "C:\Program Files\Python37\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

After posting this yesterday, I tried placing code that references the library inside the IF statement referenced in the error (if __name__ == '__main__':). It then ran, so the code looks like this now....

# Import Seq2Pat Library
from sequential.seq2pat import Seq2Pat, Attribute

# A Seq2Pat instance can be initialized with two arguments: sequences and max_span.
#
# Seq2Pat Attributes
# ------------------
# sequences : list[list]
#             A list of sequences each with a list of events. The event values can be all strings or all integers.
# max_span  : Optional[int]
#             The value for applying a built-in maximum span constraint to the length of items in mining,
#             max_span=10 by default. This is going to avoid regular users to run into a scaling
#             issue when data contains long sequences but no constraints are used to run the mining efficiently
#             and practically. Power users can choose to drop this constraint by setting it to be None
#             or increase the maximum span as the system has resources to support.

# Seq2Pat over 3 sequences
seq2pat = Seq2Pat(sequences=[["A", "A", "B", "A", "D"],
                             ["C", "B", "A"],
                             ["C", "A", "C", "D"]])

# Create price attributes
price = Attribute(values=[[5, 5, 3, 8, 2],
                          [1, 3, 3],
                          [4, 5, 2, 1]])

# Create a time attribute
timestamp = Attribute(values=[[1, 1, 2, 3, 3],
                              [3, 8, 9],
                              [2, 5, 5, 7]])

if __name__ == '__main__':
# Constraint to specify the average price of patterns
    avg_constraint = seq2pat.add_constraint(3 <= price.average() <= 4)

# Find patterns that occur at least twice within average price range
    results = seq2pat.get_patterns(min_frequency=2)
    print(results)

# Without avg_constraint, there are three patterns: [['B', 'A', 2], ['C', 'A', 2], ['A', 'D', 2]]
# With avg_constraint, there is only one pattern: ['A', 'D', 2]
# A-D satisfies the constraint becasue
#   - Sequence 0: A-D occurs three times with avg(A:5,D:2)=3.5, avg(A:5,D:2)=3.5, avg(A:8,D:2)=5
#   - Sequence 2: A-D occur once with avg(A:5,D:1) = 3




    print("works")

from seq2pat.

takojunior avatar takojunior commented on July 18, 2024

Thanks @timmyers15 for your interests to the library. I am not able to reproduce the error from my side though. Is this the entire error message? Does it show which line gets the error? Can you share more about the running environment?

from seq2pat.

takojunior avatar takojunior commented on July 18, 2024

Thanks @timmyers15! Great to see that you figured out a solution.

The RuntimeError seems to be caused when starting a child process. We do have all unit tests passed on windows though. We might consider to add a note there when users run the notebook.

(Please consider giving Seq2Pat ⭐ if the library is helpful :)

from seq2pat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.