Skip to content

Commit

Permalink
Add Python support.
Browse files Browse the repository at this point in the history
  • Loading branch information
carloskelly13 committed Sep 28, 2023
1 parent 87ce248 commit 1af2707
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-eyes-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prism-react-renderer": minor
---

Add Python support.
27 changes: 27 additions & 0 deletions packages/demo/src/sample-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,33 @@ end if
`,
},

["Python"]: {
language: "python",
code: `
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score, classification_report
iris = load_iris()
X = iris.data
y = iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
clf = DecisionTreeClassifier(random_state=42)
clf.fit(X_train, y_train)
y_pred = clf.predict(X_test)
accuracy = accuracy_score(y_test, y_pred)
report = classification_report(y_test, y_pred)
print(f"Accuracy: {accuracy}")
print("Classification Report:\\n", report)
print("Feature Importances:", clf.feature_importances_)
`,
},

["Rust"]: {
language: "rust",
code: `
Expand Down
1 change: 1 addition & 0 deletions packages/generate-prism-languages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const languagesToBundle = <const>[
"cpp",
"markdown",
"html",
"python",
]

/**
Expand Down

0 comments on commit 1af2707

Please sign in to comment.