How to fix this problem related to data mining?
- Inicie sesión o regístrese para enviar comentarios
I want generate a petri net and a heuristic net but i get the following error:
File "/home/lulu/machineLearning/mlearning.py", line 44, in
df = df.sort_values('time:timestamp')
File "/home/lulu/anaconda3/lib/python3.8/site-packages/pandas/util/_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "/home/lulu/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py", line 6254, in sort_values
k = self._get_label_or_level_values(by, axis=axis)
File "/home/lulu/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py", line 1776, in _get_label_or_level_values
raise KeyError(key)
KeyError: 'time:timestamp'
hn_visualizer.view(gviz)
Traceback (most recent call last):
File "", line 1, in
hn_visualizer.view(gviz)
NameError: name 'gviz' is not defined
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 18 09:42:57 2021
@author: lulu
"""
# Process discovery algorithms want to find a suitable process model that
# describes the order of events/activities that are executed during a process execution
# data
import pandas as pd # brindar una estructura de tabla rapida y flexible para el análisis de datos
# To converts objects in PM4PY, there is a dedicated package, i.e objects conversion
# The conversion package allows one to convert an object of a certain type to a new object of a different type
from pm4py.objects.conversion.log import converter as log_converter
# nos permite importar un event log
from pm4py.objects.log.importer.xes import importer as xes_importer
from pm4py.objects.log.util import dataframe_utils
# process mining
from pm4py.algo.discovery.heuristics import algorithm as heuristics_miner
# viz
# To visualize the heuristic net
from pm4py.visualization.heuristics_net import visualizer as hn_visualizer
from pm4py.visualization.petri_net import visualizer as pn_visualizer
# misc
from pm4py.objects.conversion.process_tree import converter as pt_converter
# We import the data
# In process mining, the two most common data formats are CSV and XES
# xes is a standard format describing how event logs are stored
log = xes_importer.apply('/home/lulu/running-example.xes')
# csv
# Pandas nos brinda IO tools un API de entrada/salida donde se incluyen métodos de lectura
# para formatos de texto, binarios y SQL
# import the CSV into a pandas dataframe
df = pd.read_csv('/home/lulu/Escritorio/logs_Ing.csv')
# convert the CSV into an event log object
df = dataframe_utils.convert_timestamp_columns_in_df(df)
# Sort the dataframe by its timestamp column. This ensures that events are sorted by their timestamp
df = df.sort_values('time:timestamp')
log = log_converter.apply(df)
# heuristics miner
# To apply the heuristic miner to discover an heuristic net, it is necessary to import a log
heu_net = heuristics_miner.apply_heu(log)
# viz
# visualize the heuristic net
gviz = hn_visualizer.apply(heu_net)
hn_visualizer.view(gviz)
# heuristic miner
# Qué significa net, im, fm
net, im, fm = heuristics_miner.apply(log)
# viz
# To provide a bit more information on the process map, we can add information about the frequency of the events
parameters = {pn_visualizer.Variants.FREQUENCY.value.Parameters.FORMAT: "png"}
gviz = pn_visualizer.apply(net,im,fm,parameters=parameters,variant=pn_visualizer.Variants.FREQUENCY,log=log)
#gviz = pn_visualizer.apply(net,im,fm,log)
pn_visualizer.view(gviz)
Adjunto | Tamaño |
---|---|
logModdle.png | 169.56 KB |
I tried to do exactly that in order to get rid of carpenter ants some time ago, but it failed.
> @author: lulu
After reading the doc more carefully, I realized that should in fact read "@author: chthulu" in order to summon the proper demon. "lulu" is not a universally accepted alias for Chthulu.
Also, what is this doing here?
I think I found the problem in line 15:
>"import pandas as pd # brindar"
Everyone knows you should never try to import pandas as pd # brindar. It's basically panda theft. And the pandas will eat all your furniture and poop all over your house - it's a big mess.
True. Only seasoned panda herders may use that technique to clear their home before refurnishing.
EDIT: removed unnecessarily bloated paragraph.
- Inicie sesión o regístrese para enviar comentarios