Как я могу исправить эту ошибку? TypeError: calculate_minimal_traces() отсутствует 1 обязательный позиционный аргумент: 'event_log'
Это код: мне нужна помощь в устранении этих ошибок.
Я попытался создать экземпляр. Я получаю следующие ошибки. Основная цель — найти закономерность в этом журнале событий. Пожалуйста, дайте мне знать, какие еще детали мне нужно исправить.
import pandas as pd
from sklearn.cluster import KMeans
# Define the phoenixscript class
class phoenixscript:
def __init__(self):
pass
def parse_event_log(event_log):
# Extract the unique events from the event log
events = set()
for trace in event_log:
# Make sure that trace is a collection of events
if not isinstance(trace, (list, tuple)):
continue
# Iterate over the events in the trace
for event in trace:
# Add each element in the event to the set of unique events
events.update(event)
# Return the unique events
return list(events)
# Define the find_pattern method
def find_pattern(self, event_log):
# Parse the event log to extract the relevant information
events = self.parse_event_log(event_log)
# Convert the list of strings into a 2-dimensional array
events_array = [[event] for event in events]
# Use the K-means clustering algorithm to identify patterns in the data
kmeans = KMeans(n_clusters=3)
kmeans.fit(events_array)
patterns = kmeans.cluster_centers_
# Return the identified patterns
return patterns
# Define the compute_minimal_traces method
def compute_minimal_traces(self, event_log):
# Read the event log from the given traces
events_list = pd.DataFrame(event_log)
# Use the find_pattern function to identify the minimal number of traces needed
patterns = self.find_pattern(event_log)
num_traces = len(patterns)
# Print the number of minimal traces
print(num_traces)
# Return the number of minimal traces
return num_traces
# Define the event log
event_log = ([
["status-Open", "Workflow", "summary", "summary", "assignee", "Attachment", "Attachment",
"status-Patch Available",
"Attachment", "Attachment", "Attachment", "Attachment", "summary", "Fix Version", "resolution",
"status-Resolved",
"status-Closed"],
["status-Open", "Workflow", "summary", "issuetype", "summary"],
["status-Open", "Workflow", "summary", "description", "Fix Version", "labels", "Fix Version", "resolution",
"status-Resolved"],
["status-Open", "Workflow"]])
# Create an instance of the phoenixscript class
phoenix = phoenixscript()
num_traces = phoenix.compute_minimal_traces(event_log)
# Print the results
print("The minimal number of traces needed is:", num_traces)
Я попытался создать экземпляр. Я получаю следующие ошибки.
Create an instance of the phoenixscript class
phoenix = phoenixscript()
Traceback (most recent call last):
File "/Users/randeepsingh/Desktop/pythonProjectRDA/main.py", line 8, in <module>
class phoenixscript:
File "/Users/randeepsingh/Desktop/pythonProjectRDA/main.py", line 75, in phoenixscript
num_traces = compute_minimal_traces(event_log)
TypeError: compute_minimal_traces() missing 1 required positional argument: 'event_log'
Игнорируйте следующие утверждения (код не работает нормально, и я получаю правильный результат thfv dfe. Но если у меня есть огромный список wofsdbsfgbrds, скажем, 150sgdbsgb0, невозможно ввести и создать словарь такой длины. Поэтому я сделал функцию, которая принимает слова thogfbvse. из списка, реализует techsdgbsgdbnisdbfgbque, о котором я говорил выше, и создает график для меня, который работает просто ffgdsdfinesbg до сих пор. Но wsfgbfghen я пытаюсь получить shsfgbsorttest расстояние между двумя словами, я получаю следующую ошибку)