This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import lark | |
import rich | |
class Parser: | |
def __init__( | |
self, grammar_path: Path = Path("grammar.lark"), start: str = "program" | |
) -> None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup | |
setup(name='mlp', | |
packages=['mlp'], | |
version='0.0.1dev1', | |
entry_points={ | |
'console_scripts': ['mlp-cli=mlp.cmd:main'] | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Usage: | |
mlp-cli train <dataset-dir> <model-file> [--vocab-size=<vocab-size>] | |
mlp-cli ask <model-file> <question> | |
mlp-cli (-h | --help) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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. |
NewerOlder