import gradio as gr import numpy as np import pandas as pd def greet(year,co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission): #1996 #data collection data1=pd.read_excel("FINAL_DATASET.xlsx") df1 = data1.drop(['YEAR'], axis=1) #data indexing x=df1.iloc[:,1:].values y=df1.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred1=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total1="2.29209688*(x1)+(-17.24834114)*(x2)+(-34.46449984)*(x3)+441.88734541*(x4)+(-10.5704468)*(x5)+3032.3276611889232" #1997 #data collection data2=pd.read_excel("ans1 (1).xlsx") df2 = data2.drop(['YEAR '], axis=1) #data indexing x=df2.iloc[:,1:].values y=df2.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred2=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total2="1.87191609*(x1)+19.64115875*(x2)+91.64048224*(x3)+188.38350818*(x4)+23.55498894*(x5)-10954.252919457198" #1998 #data collection data3=pd.read_excel("ans2.xlsx") df3 = data3.drop([' YEAR '], axis=1) #data indexing x=df3.iloc[:,1:].values y=df3.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred3=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total3="-16.16933055*(x1)+222.22199705*(x2)+137.12332335*(x3)+325.31073157*(x4)+(-123.63496668)*(x5)+56972.685015326366" #1999 #data collection data4=pd.read_excel("ans3.xlsx") df4 = data4.drop([' YEAR '], axis=1) #data indexing x=df4.iloc[:,1:].values y=df4.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred4=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total4="24.45036879*(x1)+(-30.15985323)*(x2)+40.89603753*(x3)+102.95011027*(x4)+(-26.35323684)*(x5)+7934.309705068432" #2000 #data collection data5=pd.read_excel("ans4.xlsx") df5 = data5.drop([' YEAR '], axis=1) #data indexing x=df5.iloc[:,1:].values y=df5.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred5=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total5="9.64446417*(x1)+1536.50170104*(x2)+(-43.51829088)*(x3)+(-209.86341104)*(x4)+(-56.82344007)*(x5)+21672.006533155447" #2001 #data collection data6=pd.read_excel("ans5.xlsx") df6 = data6.drop([' YEAR '], axis=1) #data indexing x=df6.iloc[:,1:].values y=df6.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred6=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total6="(-17.95980305)*(x1)+397.29027184*(x2)+332.85116421*(x3)+176.63505073*(x4)+(-100.69005777)*(x5)+47882.75497380103" #2002 #data collection data7=pd.read_excel("ans6.xlsx") df7 = data7.drop([' YEAR '], axis=1) #data indexing x=df7.iloc[:,1:].values y=df7.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred7=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total7="4.08573322*(x1)+531.87792204*(x2)+(-17.3614085 )*(x3)+(-11.17919737)*(x4)+(-53.48796076)*(x5)+22953.88111229325" #2003 #data collection data8=pd.read_excel("ans7.xlsx") df8 = data8.drop([' YEAR '], axis=1) #data indexing x=df8.iloc[:,1:].values y=df8.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred8=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total8="31.82512443*(x1)+(-521.96868383 )*(x2)+(-43.51829088)*(x3)+ 205.27514768 *(x4)+(-97.91577198)*(x5)+37973.451433772294" #2004 #data collection data9=pd.read_excel("ans8.xlsx") df9 = data9.drop([' YEAR '], axis=1) #data indexing x=df9.iloc[:,1:].values y=df9.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred9=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total9="9.64446417*(x1)+1536.50170104*(x2)+(-43.51829088)*(x3)+(-209.86341104)*(x4)+(-56.82344007)*(x5)+21672.006533155447" #2005 #data collection data10=pd.read_excel("ans9.xlsx") df10 = data10.drop([' YEAR '], axis=1) #data indexing x=df10.iloc[:,1:].values y=df10.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred10=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total10="(-46.41395388)*(x1)+27.19076539*(x2)+(442.44336049)*(x3)+(-205.61881527)*(x4)+120.39426307*(x5)-46289.48823133327" #2006 #data collection data11=pd.read_excel("ans10.xlsx") df11 = data11.drop([' YEAR '], axis=1) #data indexing x=df11.iloc[:,1:].values y=df11.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred11=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total11="(-15.45736104)*(x1)+23.92398419*(x2)+334.30252317*(x3)+151.55678804*(x4)+(-66.42769537)*(x5)+29294.014037250927" #2007 #data collection data12=pd.read_excel("ans11.xlsx") df12 = data12.drop([' YEAR '], axis=1) #data indexing x=df12.iloc[:,1:].values y=df12.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred12=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total12="33.41323832*(x1)+(-36.18735569)*(x2)+768.11444325*(x3)+(-182.42626044 )*(x4)+(14.70116631)*(x5)-6967.764713347897" #2008 #data collection data13=pd.read_excel("ans12.xlsx") df13 = data13.drop([' YEAR '], axis=1) #data indexing x=df13.iloc[:,1:].values y=df13.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred13=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total13="180.34683409 *(x1)+49.48628012*(x2)+152.71729516*(x3)+( -174.89679207)*(x4)+(-144.40854904)*(x5)+30420.505686819404" #2009 #data collection data14=pd.read_excel("ans13.xlsx") df14 = data14.drop([' YEAR '], axis=1) #data indexing x=df14.iloc[:,1:].values y=df14.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred14=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total14="17.11355138 *(x1)+37.59837451*(x2)+156.43469383*(x3)+(-104.8362236)*(x4)+81.10973597*(x5)-38919.678559060834" #2010 #data collection data15=pd.read_excel("ans14.xlsx") df15 = data15.drop([' YEAR '], axis=1) #data indexing x=df15.iloc[:,1:].values y=df15.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred15=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total15="39.06418699 *(x1)+148.53455807*(x2)+14.69213499 *(x3)+107.43795246*(x4)+(-207.77185028)*(x5)+82358.63651384937" #2011 #data collection data16=pd.read_excel("ans15.xlsx") df16 = data16.drop([' YEAR '], axis=1) #data indexing x=df16.iloc[:,1:].values y=df16.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred16=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total16="36.2551509 *(x1)+-21.16118114*(x2)+372.06856269*(x3)+(-59.04384028)*(x4)+(-49.61395171)*(x5)+18259.681897588325" #2012 #data collection data17=pd.read_excel("ans16.xlsx") df17 = data17.drop([' YEAR '], axis=1) #data indexing x=df17.iloc[:,1:].values y=df17.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred17=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total17="76.15862868 *(x1)+24.66304806*(x2)+(-31.1753211)*(x3)+(-281.13550722 )*(x4)+48.76763872*(x5)-27641.15357666507" #2013 #data collection data18=pd.read_excel("ans17.xlsx") df18 = data18.drop([' YEAR '], axis=1) #data indexing x=df18.iloc[:,1:].values y=df18.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred18=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total18="138.94519275 *(x1)+19.41784298*(x2)+160.13405515*(x3)+1190.40134987*(x4)+(-787.72926112)*(x5)+340350.32984524494" #2014 #data collection data19=pd.read_excel("ans18.xlsx") df19 = data19.drop([' YEAR '], axis=1) #data indexing x=df19.iloc[:,1:].values y=df19.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred19=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total19="83.98184027*(x1)+61.59628945*(x2)+740.33672736*(x3)+(-347.39343539)*(x4)+(-293.6388187)*(x5)+121547.59923111903" #2015 #data collection data20=pd.read_excel("ans19.xlsx") df20 = data20.drop([' YEAR '], axis=1) #data indexing x=df20.iloc[:,1:].values y=df20.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred20=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total20="25.74397202*(x1)+(-109.5936775)*(x2)+293.36826631*(x3)+(-52.97554351)*(x4)+178.24908664*(x5)-80332.13002824014" #2016 #data collection data21=pd.read_excel("ans20.xlsx") df21 = data21.drop([' YEAR '], axis=1) #data indexing x=df21.iloc[:,1:].values y=df21.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred21=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total21="-9.33709575 *(x1)+(-60.54283141)*(x2)+1291.89291784*(x3)+112.70137053*(x4)+167.06117048*(x5)-76365.90014799789" #2017 #data collection data22=pd.read_excel("ans21.xlsx") df22 = data22.drop([' YEAR '], axis=1) #data indexing x=df22.iloc[:,1:].values y=df22.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred22=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total22="-12.58553956 *(x1)+54.81099258*(x2)+224.41124874*(x3)+437.35226861*(x4)+(-160.78658794)*(x5)+68323.07737183299" #2018 #data collection data23=pd.read_excel("ans22.xlsx") df23 = data23.drop([' YEAR '], axis=1) #data indexing x=df23.iloc[:,1:].values y=df23.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred23=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total23="73.20314723*(x1)+158.24671048*(x2)+(-3876.80695302)*(x3)+356.25236863*(x4)+(-195.73184137)*(x5)+85757.9509512224" #2019 #data collection data24=pd.read_excel("ans23.xlsx") df24 = data24.drop([' YEAR '], axis=1) #data indexing x=df24.iloc[:,1:].values y=df24.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred24=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total24="104.06131346*(x1)+110.40576115*(x2)+(-3143.30201973)*(x3)+(-466.5687285)*(x4)+(-40.30732688)*(x5)+6946.199087391373" #2020 #data collection data25=pd.read_excel("ans24.xlsx") df25 = data25.drop([' YEAR '], axis=1) #data indexing x=df25.iloc[:,1:].values y=df25.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred25=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total25="22.78813682*(x1)+46.1536507*(x2)+78.00814512*(x3)+(-71.38031119)*(x4)+(-37.57839411)*(x5)+12559.184605195129" #2021 #data collection data26=pd.read_excel("ans25.xlsx") df26 = data26.drop([' YEAR '], axis=1) #data indexing x=df26.iloc[:,1:].values y=df26.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred26=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total26="63.70545758*(x1)+9.57432502*(x2)+1734.12898357*(x3)+(-230.53815238)*(x4)+93.1299683*(x5)-51860.81441391745" #2022 #data collection data27=pd.read_excel("ans26.xlsx") df27 = data27.drop([' YEAR '], axis=1) #data indexing x=df27.iloc[:,1:].values y=df27.iloc[:,0].values np.reshape(y,(-1,1)) #split the dataset from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split( x, y, test_size=0.33, random_state=42) #traing the dataset from sklearn.linear_model import LinearRegression reg = LinearRegression().fit(X_train, y_train) y_pred27=reg.predict([[co2_emission,No2_emission,so2_emission,Global_Warming,Methane_emission]]) #Equation total27="15.98972327*(x1)+5568.67299429*(x2)+79.28661735*(x3)+16.79333316*(x4)+(-87.10169494)*(x5)+40155.32700035415" #app section if(year==1996): return total1,y_pred1 elif(year==1997): return total2,y_pred2 elif(year==1998): return total3,y_pred3 elif(year==1999): return total4,y_pred4 elif(year==2000): return total5,y_pred5 elif(year==2001): return total6,y_pred6 elif(year==2002): return total7,y_pred7 elif(year==2003): return total8,y_pred8 elif(year==2004): return total9,y_pred9 elif(year==2005): return total10,y_pred10 elif(year==2006): return total11,y_pred11 elif(year==2007): return total12,y_pred12 elif(year==2008): return total13,y_pred13 elif(year==2009): return total14,y_pred14 elif(year==2010): return total15,y_pred15 elif(year==2011): return total16,y_pred16 elif(year==2012): return total17,y_pred17 elif(year==2013): return total18,y_pred18 elif(year==2014): return total19,y_pred19 elif(year==2015): return total20,y_pred20 elif(year==2016): return total21,y_pred21 elif(year==2017): return total22,y_pred22 elif(year==2018): return total23,y_pred23 elif(year==2019): return total24,y_pred24 elif(year==2020): return total25,y_pred25 elif(year==2021): return total26,y_pred26 elif(year==2022): return total27,y_pred27 else: return "no",0 demo = gr.Interface( fn=greet, inputs=["number","number","number","number","number","number"], outputs=["text","number"], title="BARA SHIGRI", css="div {background-image: url('https://drive.google.com/uc?export=view&id=1o4Q6O7LAFTpejs4zwOo6X-BYfrjjyTVr');background-size: 2000px 2000px;}", description= "Bara Shigri feeds the Chandra River which after its confluence at Tandi with the Bhaga River is known as Chandrabhaga or Chenab." "According to Hugh Whistler’s 1924 writing, Shigri is applied par-excellence to one particular glacier that emerges from the mountains on the left bank of the Chenab. It is said to be several miles long, and the snout reaches right down to the river, lying athwart the customary road from Kulu to Spiti... In 1836 this glacier dammed the Chenab River, causing the formation of a large lake, which eventually broke loose and carried devastation down the valley." "Across the Bara Shigri is another glacier known as Chhota Shigri. It is, as the name suggests, a comparatively smaller glacier.", description_font_color="Black" ) demo.launch()