Skip to content

Commit

Permalink
Merge pull request #226 from FormidableLabs/feature/python
Browse files Browse the repository at this point in the history
Add Python support.
  • Loading branch information
carloskelly13 committed Sep 28, 2023
2 parents 87ce248 + 1af2707 commit 9c041df
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
@@ -0,0 +1,5 @@
---
"prism-react-renderer": minor
---

Add Python support.
27 changes: 27 additions & 0 deletions packages/demo/src/sample-code.ts
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
Expand Up @@ -21,6 +21,7 @@ export const languagesToBundle = <const>[
"cpp",
"markdown",
"html",
"python",
]

/**
Expand Down

0 comments on commit 9c041df

Please sign in to comment.