Skip to content

Instantly share code, notes, and snippets.

View mbednarski's full-sized avatar

Mateusz Bednarski mbednarski

View GitHub Profile
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType
from langchain.tools import BaseTool
from langchain.llms import OpenAI
from langchain import LLMMathChain, SerpAPIWrapper
from spotipy.oauth2 import SpotifyClientCredentials, SpotifyOAuth
import azapi
import spotipy
from langchain.utilities import GoogleSearchAPIWrapper
from urllib.parse import quote_plus
from pathlib import Path
import lark
import rich
class Parser:
def __init__(
self, grammar_path: Path = Path("grammar.lark"), start: str = "program"
) -> None:
from pathlib import Path
import rich
import typer
from lark.tree import pydot__tree_to_png
from xdlang.pipeline import Parser
from xdlang.pipeline.ast_builder import AstBuilder
app = typer.Typer()
from pathlib import Path
import lark
import rich
class Parser:
def __init__(
self, grammar_path: Path = Path("grammar.lark"), start: str = "program"
) -> None:
with grammar_path.open("rt") as f:
from lark import Lark, tree
from lark.visitors import CollapseAmbiguities
import matplotlib.pyplot as plt
def plot_trees(grammar:str, text:str, start='expr'):
parser = Lark(grammar=grammar, start=start,ambiguity='explicit')
parsed = parser.parse(text)
trees = CollapseAmbiguities().transform(parsed)
for t in trees:
tree.pydot__tree_to_png(t, filename='tree.png', rankdir='TB')
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
import optuna
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.20, stratify=y)
from setuptools import setup
setup(name='mlp',
packages=['mlp'],
version='0.0.1dev1',
entry_points={
'console_scripts': ['mlp-cli=mlp.cmd:main']
}
)
Usage:
mlp-cli train <dataset-dir> <model-file> [--vocab-size=<vocab-size>]
mlp-cli ask <model-file> <question>
mlp-cli (-h | --help)
def main():
arguments = docopt(__doc__)
if arguments['train']:
train_model(arguments['<dataset-dir>'],
arguments['<model-file>'],
int(arguments['--vocab-size'])
)
elif arguments['ask']:
ask_model(arguments['<model-file>'],
"""MLP - machine-learning-production
Usage:
mlp.py train <dataset-dir> <model-file> [--vocab-size=<vocab-size>]
mlp.py ask <model-file> <question>
mlp.py (-h | --help)
Arguments:
<dataset-dir> Directory with dataset.
<model-file> Serialized model file.