text stringlengths 0 105k |
|---|
from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.document_loaders import TextLoader loader = TextLoader("data/data_2.0.txt") # Use this line if you only need data.txt text_splitter = RecursiveCharacterTextSplitter(chunk_size=1500, chunk_overlap=0) data = loader.load() texts = ... |
from langchain.embeddings.openai import OpenAIEmbeddings from dotenv import load_dotenv import os load_dotenv() OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY") from langchain.chains import RetrievalQAWithSourcesChain from langchain import OpenAI from langchain.vectorstores import Chroma from langcha... |
import os import sys import openai from langchain.chains import RetrievalQA from langchain.chat_models import ChatOpenAI from langchain.document_loaders import DirectoryLoader, TextLoader from langchain.embeddings import OpenAIEmbeddings from langchain.indexes import VectorstoreIndexCreator from langchain.ind... |
s = open("data/data.txt", "r") s = s.read().replace("\n", "") with open("data/new_data.txt", "w") as x: x.write(s) |
import requests from bs4 import BeautifulSoup from urllib.parse import urlparse, urljoin def scrape_domain_and_subdomains(base_url, file_path): visited_urls = set() def scrape(url): response = requests.get(url) if response.status_code == 200: soup = BeautifulSoup(respon... |
# This is a sample Python script. # Press Maj+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # ... |
import taipy as tp from taipy.gui import Gui, notify from taipy.config import Config import numpy as np import pandas as pd BUSINESS_PATH = "data/yelp_business.csv" # Load the business data using pandas business_df = pd.read_csv(BUSINESS_PATH) # Remove quotation marks from the name business_df.name =... |
import dask.dataframe as dd def get_data(path_to_csv: str, optional: str = None): """ Loads a csv file into a dask dataframe. Converts the date column to datetime. Args: - path_to_csv: path to the csv file - optional: optional argument (currently necessary to fix Core bug wi... |
import pandas as pd import dask.dataframe as dd def get_id_from_name(name: str, business_dict: dict): """ Returns the business_id from the name of the business. Args: - name: name of the business - business_dict: dict with the name as key and the business_id as value Retu... |
import time import pandas as pd import dask.dataframe as dd def task1(path_to_original_data: str): print("__________________________________________________________") print("1. TASK 1: DATA PREPROCESSING AND CUSTOMER SCORING ...") start_time = time.perf_counter() # Start the timer # Step... |
from recsys.recsys import page_scenario_manager from taipy.gui import Gui gui = Gui(page_scenario_manager) gui.run() |
import pandas as pd import numpy as np TEST_RATIO = 0.2 MOVIELENS_DATA_PATH = "u.data" MOVIE_DATA_PATH = "u.item" def convert_data_to_dataframe(data_path: str, movie_path: str): data = pd.read_table(data_path) data.columns = ["u_id", "i_id", "rating", "timestamp"] data_sort = data.sort_values(... |
import pandas as pd from datetime import datetime data = pd.read_csv("dataset/rating_train.csv") timestamp = data.timestamp.to_list() date = [] for time in timestamp: date.append(datetime.fromtimestamp(time)) data["timestamp"] = date data.to_csv("data.csv", index=False) |
import pandas as pd import numpy as np from scipy import sparse class DataLoader: def __init__(self): self.__train_data = None self.__val_data = None self.__test_data = None def __create_id_mapping(self): if self.__val_data: unique_uIds = pd.concat( ... |
from taipy import Config, Scope from functions.funtions import preprocess_data, fit, predict from config.svd_config import ( n_epochs_cfg, n_factors_cfg, learning_rate_cfg, qi_cfg, bi_cfg, bu_cfg, pu_cfg, ) from config.kNN_config import ( x_id_cfg, n_k_neighboor_cfg, ... |
from taipy import Config, Scope x_id_cfg = Config.configure_data_node(id="x_id", default_data=1) n_min_k_cfg = Config.configure_data_node(id="n_min_k", default_data=10) n_k_neighboor_cfg = Config.configure_data_node( id="n_k_neighboor", default_data=1) sim_measure_cfg = Config.configure_in_memory_data_... |
from taipy import Config, Scope n_factors_cfg = Config.configure_data_node(id="n_factors", default_data=30) n_epochs_cfg = Config.configure_data_node(id="n_epochs", default_data=50) learning_rate_cfg = Config.configure_data_node(id="learning_rate", default_data=0.001) qi_cfg = Config.configure_data_node(id="q... |
import taipy as tp from taipy.config import Config from taipy.gui import notify, Markdown import pandas as pd import numpy as np from helper.knn_helper import calculate_precision_recall from config.config import pipeline_cfg Config.configure_global_app(clean_entities_enabled=True) tp.clean_all_entities(... |
import pandas as pd import numpy as np from ultis.dataloader import DataLoader from helper.svd_helper import sgd, predict_svd_pair from helper.knn_helper import predict_pair, compute_similarity_matrix VALID_ALGORITHM = ["kNN", "MF"] def preprocess_data( train_data: pd.DataFrame, test_data: pd.DataFrame... |
import numpy as np from numba import njit def compute_similarity_matrix(train_set, sim_measure="pcc"): x_rated, _, n_x, _, x_list, y_list = list_ur_ir(train_set) if sim_measure == "pcc": print("Computing similarity matrix as pcc...") S = pcc(n_x, x_rated, min_support=1) elif sim_m... |
import numpy as np from numba import njit def sgd( X, pu, qi, bu, bi, n_epochs, global_mean, n_factors, lr_pu, lr_qi, lr_bu, lr_bi, reg_pu, reg_qi, reg_bu, reg_bi, ): for epoch_ix in range(n_epochs): pu, qi, bu, bi, tra... |
import pandas as pd from prophet import Prophet from taipy import Config def clean_data(initial_dataset: pd.DataFrame): print("Cleaning Data") initial_dataset = initial_dataset.rename(columns={"Date": "ds", "Close": "y"}) initial_dataset['ds'] = pd.to_datetime(initial_dataset['ds']).dt.tz_localize(N... |
from taipy.gui import Gui, notify import pandas as pd import yfinance as yf from taipy.config import Config import taipy as tp import datetime as dt Config.load('config_model_train.toml') scenario_cfg = Config.scenarios['stock'] def get_stock_data(ticker, start): ticker_data = yf.download(ticker, star... |
from taipy import Gui import pandas as pd # Interactive GUI and state, we maintain states for each individual client # hence we can have multiple clients with each client having its own state, # change of the state of one client will not affect the other client's state. # Each client has its own state and glob... |
from taipy import Gui import pandas as pd # visual elements: Taipy adds visual elements on top of markdown # to give you the ability to add charts, tables... The format for # it is as follows: # <|{variable}|visual_element_name|param_1=param_1|param_2=param_2| ... |>. # variable: python variable eg dataframe ... |
from taipy import Gui # not no empty spaces at the beginning of the markdown # markdown must start from the baseline page = """ ### Hello world """ # Gui(page=page).run(dark_mode=False) # you can specify the port number in the run(port=xxxx) # its by default 5000 Gui(page="Intro to Taipy").run(dark_mode=... |
# 데이터를 처리하기 위한 파이썬의 기본 패키지 from login.login import * import pandas as pd # 타이피 코어 import import taipy as tp # 내 파이썬 코드의 백엔드 가져오기 | 시나리오를 생성하려면 원본 파이프라인_cfg 및 시나리오_cfg가 필요합니다. # fixed_variables_default는 고정 변수의 기본값으로 사용됩니다. from config.config import fixed_variables_default, scenario_cfg, pipeline_cfg from tai... |
import taipy as tp from taipy import Scope, Config from taipy.core import Frequency import json from algos.algos import * # 이 코드는 시나리오_cfg 및 파이프라인_csg를 생성하는 코드입니다. # 이 두 변수는 기본 코드에서 새 시나리오를 만드는 데 사용됩니다. # 이 코드는 실행 그래프를 구성할 것입니다. ##########################################################################... |
import pandas as pd import numpy as np from pulp import * # 이 코드는 이러한 기능이 필요한 작업을 생성하는 config.py에서 사용됩니다. # 이 함수는 전형적인 파이썬 함수입니다(Taipy는 없습니다) ############################################################################### # 기능 ############################################################################### ... |
import numpy as np import pandas as pd # 이 코드는 수요에 대한 csv 파일을 생성하는 데 사용되며 문제의 소스 데이터입니다. def create_time_series(nb_months=12,mean_A=840,mean_B=760,std_A=96,std_B=72, amplitude_A=108,amplitude_B=144): time_series_A = [] time_series_A.append(mean_A) time_series_B = [] time_series_B.append... |
da_display_table_md = "<center>\n<|{ch_results.round()}|table|columns={list(chart.columns)}|width=fit-content|height={height_table}|></center>\n" d_chart_csv_path = None def da_create_display_table_md(str_to_select_chart): return "<center>\n<|{" + str_to_select_chart + \ "}|table|width=fit-content|hei... |
import pandas as pd import json with open('data/fixed_variables_default.json', "r") as f: fixed_variables_default = json.load(f) # Taipy Core의 코드는 아직 실행되지 않았습니다. csv 파일을 이런 식으로 읽습니다. da_initial_demand = pd.read_csv('data/time_series_demand.csv') da_initial_demand = da_initial_demand[['Year', 'Month', 'Dem... |
from pages.annex_scenario_manager.chart_md import ch_chart_md, ch_choice_chart, ch_show_pie, ch_layout_dict, ch_results from pages.annex_scenario_manager.parameters_md import pa_parameters_md, pa_param_selector, pa_param_selected, pa_choice_product_param, pa_product_param from taipy.gui.gui_actions import notify f... |
from data.create_data import time_series_to_csv from config.config import scenario_cfg from taipy.core import taipy as tp import datetime as dt import pandas as pd cc_data = pd.DataFrame( { 'Date': [dt.datetime(2021, 1, 1)], 'Cycle': [dt.date(2021, 1, 1)], 'Cost of Back Order'... |
import taipy as tp import pandas as pd cs_compare_scenario_md = """ # 시나리오 비교 <|layout|columns=3 3 1|columns[mobile]=1| <layout_scenario| **Scenario 1** <|layout|columns=1 1 3|columns[mobile]=1| <| Year <|{sm_selected_year}|selector|lov={sm_year_selector}|dropdown|width=100%|on_change=change_sm_mo... |
from .chart_md import ch_chart_md, ch_layout_dict, ch_results from config.config import fixed_variables_default from taipy.gui import Icon def create_sliders(fixed_variables): """" 이것은 매개변수에 대한 슬라이더를 자체적으로 생성하는 매우 복잡한 함수입니다. 손으로 할 수도 있었습니다. 그러나 이 방법은 장기적으로 더 유연합니다. """ # 반환될 문자열 ... |
from taipy.gui import Icon import pandas as pd ch_layout_dict = {"margin":{"t":20}} # 차트 설정 토글 ch_choice_chart = [("pie", Icon("images/pie.png", "pie")), ("chart", Icon("images/chart.png", "chart"))] ch_show_pie = ch_choice_chart[1][0] ch_results = pd.DataFrame({"Monthly Production FPA"... |
import taipy as tp from taipy.gui import Icon import datetime as dt import os import hashlib import json login = '' password = '' dialog_login = False dialog_new_account = False new_account = False all_scenarios = tp.get_scenarios() users = {} json.dump(users, open('login/login.json', 'w')) ... |
from taipy import Gui page = """ # Hello World 🌍 with *Taipy* This is my first Taipy test app. And it is running fine! """ Gui(page).run(use_reloader=True) # use_reloader=True if you are in development |
from taipy import Gui from page.dashboard_fossil_fuels_consumption import * if __name__ == "__main__": Gui(page).run( use_reloader=True, title="Test", dark_mode=False, ) # use_reloader=True if you are in development |
import pandas as pd import taipy as tp from data.data import dataset_fossil_fuels_gdp country = "Spain" region = "Europe" lov_region = list(dataset_fossil_fuels_gdp.Entity.unique()) def load_dataset(_country): """Load dataset for a specific country. Args: _country (str): The name of t... |
import pandas as pd dataset_fossil_fuels_gdp = pd.read_csv("data/per-capita-fossil-energy-vs-gdp.csv") country_codes = pd.read_csv("./data/country_codes.csv") dataset_fossil_fuels_gdp = dataset_fossil_fuels_gdp.merge( country_codes[["alpha-3", "region"]], how="left", left_on="Code", right_on="alpha-3" ) ... |
from taipy.gui import Gui as tpGui from taipy.gui import notify as tpNotify import pandas as pd text = "Original text" col1 = "first col" col2 = "second col" col3 = "third col" ballon_img = "./img/Ballon_15_20.png" section_1 = """ <h1 align="center">Getting started with Taipy GUI</h1> <|layout|colum... |
import os import logging from opentelemetry import metrics from opentelemetry import trace from opentelemetry.sdk.metrics import MeterProvider from opentelemetry.sdk.resources import Resource, SERVICE_NAME from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter from opentelemetry.ex... |
import time from pathlib import Path from taipy import Config, Status import taipy as tp from taipy.gui import get_state_id, invoke_callback from metrics import init_metrics, tracer # Telemetry rec_svc_metrics = init_metrics() @tracer.start_as_current_span("function_double") def double(nb): """D... |
from taipy.gui import Gui from tensorflow.keras import models from PIL import Image import numpy as np class_names = { 0: 'airplane', 1: 'automobile', 2: 'bird', 3: 'cat', 4: 'deer', 5: 'dog', 6: 'frog', 7: 'horse', 8: 'ship', 9: 'truck', } model = models.lo... |