Skip to content

Instantly share code, notes, and snippets.

View someshfengde's full-sized avatar
👨‍💻
Learning something new!

Somesh someshfengde

👨‍💻
Learning something new!
View GitHub Profile
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 = {
#%%
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
@someshfengde
someshfengde / output.py
Last active December 11, 2023 10:52
output
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"
smooth_loss_function(out1, torch.tensor(400)), smooth_loss_function(out2, torch.tensor(420))
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)
# 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
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
## 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
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
class threads extends Thread
{
threads()
{
super("User Threads");
System.out.println("User thread is created " + this);
start();
}
public void run()
{