klotz: python*

Bookmarks on this page are managed by an admin user.

0 bookmark(s) - Sort by: Date ↓ / Title / - Bookmarks from other users for this tag

  1. How to use Burr, an open source framework using simple OpenAI client calls to GPT4, and FastAPI to create a custom email assistant agent. We’ll describe the challenge one faces and then how you can solve for them.
    2024-04-26 Tags: , , , , , by klotz
  2. This article explains permutation feature importance (PFI), a popular method for understanding feature importance in explainable AI. The author walks through calculating PFI from scratch using Python and XGBoost, discussing the rationale behind the method and its limitations.
  3. Intro to Streamlit
    - Simple and complex Streamlit example
    - Data and state management in Streamlit apps
    - Data widgets for Streamlit apps
    - Deploying Streamlit apps
    2024-04-17 Tags: , , , by klotz
  4. import EasyCrypt
    keystring = "SixteenByteKey!!"
    inpstring = "Some super secret string, that I don't want you to see."
    # This is the initialisation vector/nonce. I generated it with the below code. As you
    # will need it to decrypt later on, you might want to store it and not just generate it each time
    # I just generated it like this and printed this one out to store it.
    #
    # import os
    # from binascii import hexlify, unhexlify
    # ivstring = hexlify(os.urandom(16)).decode()

    ivstring = "aba0a3bde34a03487eda3ec96d5736a8"

    crypted = EasyCrypt.encrypt_string(keystring, inpstring, ivstring)
    print(crypted)

    decrypted = EasyCrypt.decrypt_string(keystring, crypted, ivstring)
    print(decrypted)
  5. # main.py

    import json
    from pydantic import BaseModel, EmailStr, ValidationError, validator

    class Employee(BaseModel):
    name: str
    age: int
    email: EmailStr
    department: str
    employee_id: str

    @validator("employee_id")
    def validate_employee_id(cls, v):
    if not v.isalnum() or len(v) != 6:
    raise ValueError("Employee ID must be exactly 6 alphanumeric characters")
    return v

    # Load and parse the JSON data
    with open("employees.json", "r") as f:
    data = json.load(f)

    # Validate each employee record
    for record in data:
    try:
    employee = Employee(**record)
    print(f"Valid employee record: {employee.name}")
    except ValidationError as e:
    print(f"Invalid employee record: {record 'name' » }")
    print(f"Errors: {e.errors()}"
    2024-03-26 Tags: , , by klotz
  6. python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('I love you'))"
  7. The TextWrapper class provides functionality for wrapping long pieces of text into multiple shorter lines while preserving the initial and subsequent indents.
    2024-02-07 Tags: , , , by klotz

Top of the page

First / Previous / Next / Last / Page 1 of 0 SemanticScuttle - klotz.me: Tags: python

About - Propulsed by SemanticScuttle