Skip to main content

A splinters to scripts generator

Project description

Optibot

Create splinters like this

{{ optiid("splinter1") }}

{{ optitask("model") }}
{{ optitask("train") }}
{{ optitask("classification") }}

{{ optiimport("from sklearn.ensemble import RandomForestClassifier")}}

{{ optivar("model")}}
{{ optivar("X")}}
{{ optivar("y")}}

{{ optiparam("n_estimators", "int", min=0, max=100) }}
{{ optiparam("random_state", "float", min=0, max=40000) }}

---

# Train a Lasso model with alpha=0.1
{{model}} = RandomForestClassifier(n_estimators={{n_estimators}}, random_state={{random_state}})
{{model}}.fit({{X}}, {{y}})


Use them in scripts templates like this

import numpy as np
{{ imports() }}

# Load data from CSV file using NumPy
data = np.loadtxt("data.csv", delimiter=",")

# Split the data into features (X) and labels (y)
features = data[:, :-1]
labels = data[:, -1]

# Train a classifier
{{ splinter("train", "model.train.classification", X="features", y="labels", model="clf") }}

# Test the trained classifier
score = clf.score(features, labels)
print("Accuracy: {:.2f}%".format(score * 100))

Generate random scripts with them

from src.optibot.core.optibot import OptiBot

bot = OptiBot()
bot.preload_splinters_from_path("./templates/splinters/*")
bot.preload_templates_from_path("./templates/scripts/*")
bot.compile()

for x in range(10):
    subject = list(bot.generate_script())

    with open(f"subject_{x + 1}.py", "w") as fp:
        fp.write(bot.render("simple.jinja", subject))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optibot-0.0.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

optibot-0.0.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file optibot-0.0.1.tar.gz.

File metadata

  • Download URL: optibot-0.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for optibot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8d5106467f3e11432781f35277eea916ad5bcd126ab32c8dbf897a2023cf80ff
MD5 8a2106e4c8f63c6f2a7c275c77e1707f
BLAKE2b-256 5c83348a3d04cb718a69d3c0af62564cbfd600436ae9648cf89d91f3a3179cd2

See more details on using hashes here.

File details

Details for the file optibot-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: optibot-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.2

File hashes

Hashes for optibot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f43718688807beb36fd909c4e316e1d1d2cd7404de032e61d14dcff2d6299646
MD5 74eeda31243a859fcc88be58692d4944
BLAKE2b-256 1770ff84625e81455f4c33b73afdcab7b1bb9538d107e636cd177c3a37be0803

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page