100% Live Browser HTML5 / Canvas / SVG Outputs & Unseen SWE-bench Shootout — Same Hardware (A100-80GB), Same Prompts
| Unseen GitHub Issue | Qwen3.8-27B + ReAct | Qwen4-35B-A3B + ReAct | Ours (27B + KhalilSWE v3.6) | Bonus: Qwen4-35B-A3B + Our KhalilSWE v3.6 |
|---|---|---|---|---|
django__django-14725 | FAIL | FAIL | FAIL | FAIL |
django__django-14771 | FAIL | PASS | PASS | PASS |
django__django-14787 | FAIL | PASS | PASS | PASS |
sympy__sympy-22456 | FAIL | FAIL | PASS | PASS |
sympy__sympy-22914 | FAIL | PASS | PASS | PASS |
sympy__sympy-23262 | FAIL | FAIL | FAIL | PASS |
| Total Resolved | 0 / 6 (0.0%) | 3 / 6 (50.0%) | 4 / 6 (66.7%) | 5 / 6 (83.3%) |
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df, target_column):
# Separate features and target
X = df.drop(columns=[target_column])
y = df[target_column]
# Train Random Forest Classifier
clf = RandomForestClassifier()
clf.fit(X, y)
# Get feature importances
feature_importances = clf.feature_importances_
# Create a dataframe for sorting
importance_df = pd.DataFrame({
'Feature': X.columns,
'Importance': feature_importances
})
# Sort in descending order
importance_df = importance_df.sort_values(by='Importance', ascending=False).reset_index(drop=True)
# Plot horizontal bar plot
fig, ax = plt.subplots()
sns.barplot(x='Importance', y='Feature', data=importance_df, ax=ax)
ax.set_xlabel('Feature Importance Score')
ax.set_ylabel('Features')
ax.set_title('Visualizing Important Features')
return clf, ax
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df, target_column):
"""
Train a Random Forest classifier on a dataframe (using `target_column` as the
label) and plot the feature importances as a horizontal bar plot.
Parameters
----------
df : pandas.DataFrame
The dataframe containing the features and the column of interest.
target_column : str
The name of the column used as the classification target.
Returns
-------
(sklearn.ensemble.RandomForestClassifier, matplotlib.axes.Axes)
The trained random forest classifier and the Axes object of the
plotted bar chart.
"""
# ------------------------------------------------------------------
# 1. Split the data into features (X) and target (y)
# ------------------------------------------------------------------
X = df.drop(columns=[target_column])
y = df[target_column]
# ------------------------------------------------------------------
# 2. Encode any non numeric (categorical / boolean) feature columns so
# that the random forest can consume them.
# ------------------------------------------------------------------
non_numeric = X.select_dtypes(include=["object", "category", "bool", "string"]).columns
if len(non_numeric) > 0:
X = pd.get_dummies(X, columns=list(non_numeric))
# ------------------------------------------------------------------
# 3. Train the random forest classifier
# ------------------------------------------------------------------
clf = RandomForestClassifier()
clf.fit(X, y)
# ------------------------------------------------------------------
# 4. Collect and sort the feature importances in descending order
# ------------------------------------------------------------------
importances = clf.feature_importances_
feature_names = np.asarray(X.columns)
sorted_idx = np.argsort(importances)[::-1] # descending order
sorted_importances = np.asarray(importances)[sorted_idx]
sorted_features = feature_names[sorted_idx]
# ------------------------------------------------------------------
# 5. Plot: importances on the x-axis, feature names on the y-axis
# ------------------------------------------------------------------
fig, ax = plt.subplots(figsize=(10, 6))
ax.barh(sorted_features, sorted_importances, color="skyblue", edgecolor="black")
ax.set_xlabel("Feature Importance Score")
ax.set_ylabel("Features")
ax.set_title("Visualizing Important Features")
fig.tight_layout()
return clf, ax
if __name__ == "__main__":
# Simple demo
data = pd.DataFrame({
"feature1": np.random.rand(100),
"feature2": np.random.rand(100),
"feature3": np.random.rand(100),
"category": np.random.choice(["a", "b", "c"], 100),
"target": np.random.choice([0, 1], 100),
})
model, axis = task_func(data, "target")
plt.show()
def analyze_isnad_dag(chains: list[list[str]], unreliable: set[str]) -> dict:
from heapq import heappush, heappop
nodes = set()
edges = set()
for chain in chains:
for n in chain:
nodes.add(n)
for i in range(len(chain) - 1):
edges.add((chain[i], chain[i + 1]))
# Check for self-loops (direct cycle)
for u, v in edges:
if u == v:
return {"valid_dag": False, "topological_order": [], "authentic_chains": 0, "longest_clean_path": 0}
# Build adjacency and in-degree
adj = {n: [] for n in nodes}
in_degree = {n: 0 for n in nodes}
for u, v in edges:
adj[u].append(v)
in_degree[v] += 1
# Kahn's algorithm with lexicographic tie-breaking
heap = [n for n in nodes if in_degree[n] == 0]
heap.sort()
topo = []
while heap:
u = heappop(heap)
topo.append(u)
for v in adj[u]:
in_degree[v] -= 1
if in_degree[v] == 0:
heappush(heap, v)
if len(topo) != len(nodes):
return {"valid_dag": False, "topological_order": [], "authentic_chains": 0, "longest_clean_path": 0}
# Authentic chains: non-empty and no narrator in unreliable
authentic_chains = 0
for chain in chains:
if len(chain) > 0 and not any(n in unreliable for n in chain):
authentic_chains += 1
# Longest clean path (number of nodes) in subgraph of reliable nodes
clean_nodes = {n for n in nodes if n not in unreliable}
if not clean_nodes:
longest_clean_path = 0
else:
dp = {n: 1 for n in clean_nodes}
for u in topo:
if u not in clean_nodes:
continue
for v in adj[u]:
if v in clean_nodes:
if dp[u] + 1 > dp[v]:
dp[v] = dp[u] + 1
longest_clean_path = max(dp.values())
return {
"valid_dag": True,
"topological_order": topo,
"authentic_chains": authentic_chains,
"longest_clean_path": longest_clean_path
}
import heapq
def analyze_isnad_dag(chains: list[list[str]], unreliable: set[str]) -> dict:
"""
تحليل رسم الإسناد الموجّه المُجمَّع من كل سلاسل الإسناد.
يعيد:
{
"valid_dag": bool,
"topological_order": list[str], # كسني أبجدي عند التساوي
"authentic_chains": int,
"longest_clean_path": int
}
"""
invalid = {
"valid_dag": False,
"topological_order": [],
"authentic_chains": 0,
"longest_clean_path": 0,
}
if unreliable is None:
unreliable = set()
nodes: set[str] = set()
adj: dict[str, set] = {}
indeg: dict[str, int] = {}
edge_set: set[tuple[str, str]] = set()
# ---- بناء الرسم البياني المُجمَّع (عقد + حواف فريدة) ----
for chain in chains:
if chain is None:
continue
chain = list(chain)
if not chain:
continue
for name in chain:
nodes.add(name)
if name not in adj:
adj[name] = set()
indeg[name] = 0
for a, b in zip(chain, chain[1:]):
if a == b:
# حلقة ذاتية => دورة موجهة حتماً
adj.setdefault(a, set())
indeg.setdefault(a, 0)
if (a, b) not in edge_set:
edge_set.add((a, b))
adj[a].add(b)
indeg[b] += 1
continue
if (a, b) not in edge_set:
edge_set.add((a, b))
adj[a].add(b)
indeg[b] += 1
if not nodes:
return {
"valid_dag": True,
"topological_order": [],
"authentic_chains": 0,
"longest_clean_path": 0,
}
# ---- خوارزمية كان مع أولوية صغرى (كسني أبجدي) ----
heap = [n for n in nodes if indeg[n] == 0]
heapq.heapify(heap)
order: list[str] = []
while heap:
u = heapq.heappop(heap)
order.append(u)
for v in sorted(adj[u]):
indeg[v] -= 1
if indeg[v] == 0:
heapq.heappush(heap, v)
if len(order) != len(nodes):
# توجد دورة موجهة (أو حلقة ذاتية)
return invalid
# ---- عدد السلاسل الصحيحة (خالية من الرواة غير الموثوقين) ----
authentic_chains = 0
for chain in chains:
if chain is None:
continue
if not chain:
continue
ok = True
for name in chain:
if name in unreliable:
ok = False
break
if ok:
authentic_chains += 1
# ---- أطول مسار موجّه يمر فقط برواة موثوقين (DP على الترتيب الطوبولوجي) ----
dp: dict[str, int] = {}
for u in order:
if u in unreliable:
continue
if u not in dp:
dp[u] = 1
base = dp[u]
for v in adj[u]:
if v in unreliable:
continue
if dp.get(v, 0) < base + 1:
dp[v] = base + 1
longest_clean_path = max(dp.values()) if dp else 0
return {
"valid_dag": True,
"topological_order": order,
"authentic_chains": authentic_chains,
"longest_clean_path": longest_clean_path,
}
if __name__ == "__main__":
print(analyze_isnad_dag([["مالك", "نافع", "ابن عمر"]], {"ابن عمر"}))
print(analyze_isnad_dag([["أ", "ب"], ["ب", "أ"]], set()))
print(analyze_isnad_dag([], set()))