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
import json | |
import pandas as pd | |
import plotly.graph_objects as go | |
import numpy as np | |
# aggregating multiple sentiments | |
def aggregate_multiple_sentiments(sentiments): | |
if len(sentiments) == 0: | |
return 'Neutral' | |
sentiment_count = { |
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
#%% | |
import requests | |
base_url = "http://127.0.0.1:8000" | |
# Endpoint path for generating a streaming response | |
endpoint_path = "/generate_streaming_response" | |
# Full URL to the API endpoint | |
url = base_url + endpoint_path |
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
import datetime | |
import requests | |
from flask import Flask, jsonify, request | |
app = Flask(__name__) | |
# The URL of the database API (note that the endpoint in the example may not work) | |
DB_API_URL = "https://app.ylytic.com/ylytic/test" |
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
smooth_loss_function(out1, torch.tensor(400)), smooth_loss_function(out2, torch.tensor(420)) |
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
model = LinearRegressor() | |
loss_function = torch.nn.L1Loss() | |
def train_model(model, loss_function): | |
optimizer = torch.optim.Adam(model.parameters(), lr = 0.05) | |
losses = [] | |
for epoch in range(200):# let's train this model for 1000 epochs | |
loss_output = [] | |
for (input,output) in tqdm(zip(X,y)): | |
input = torch.tensor([input]).to(torch.float32) | |
output = torch.tensor([output]).to(torch.long) |
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
# let's take a sample data here we are taking integer in range 1 to 20 and output as 20 multiple this will be | |
# enough for understanding loss function | |
X = np.arange(1,20) | |
y = X * 20 |
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
import torch | |
import numpy as np | |
from tqdm import tqdm | |
import plotly.express as px # for visualisation | |
import plotly.io as pio | |
pio.renderers.default = 'iframe' | |
class LinearRegressor(torch.nn.Module): | |
""" | |
Building a simple linear regression model with pytorch |
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
## tldraw link | |
https://www.tldraw.com/r/v2_K6fVYupNBLleeGnEWr_FD?viewport=-2801%2C-997%2C8043%2C4421&page=page%3A94tU4XAecUE6Z4VJurSZf | |
## dataset and github | |
another dataset I've found this one is free to download | |
https://zenodo.org/record/7152317#.Yz6mJ9JByC0 |
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
SA (m2/g) | Vt (m3/g) | pH_BC | pH | CT (min) | Dose (g/L) | T (K) | Co (mg/L) | Adsorption Capacity (mg/g) | |
---|---|---|---|---|---|---|---|---|---|
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 318 | 20 | 50 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 318 | 60 | 125 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 318 | 100 | 200 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 318 | 200 | 210 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 318 | 300 | 323 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 308 | 20 | 51 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 308 | 60 | 110 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 308 | 100 | 175 | |
82.06 | 6.06E-02 | 3.69 | 2 | 1440 | 0.75 | 308 | 200 | 210 |
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
class threads extends Thread | |
{ | |
threads() | |
{ | |
super("User Threads"); | |
System.out.println("User thread is created " + this); | |
start(); | |
} | |
public void run() | |
{ |
NewerOlder