File size: 1,711 Bytes
8e22fcd
 
 
be2f547
 
 
 
 
e3e35e7
b7bf350
 
547800a
 
 
 
e3e35e7
547800a
 
e3e35e7
b7bf350
547800a
 
 
 
e3e35e7
b7bf350
547800a
 
 
e3e35e7
b7bf350
547800a
 
e3e35e7
b7bf350
547800a
 
 
e3e35e7
b7bf350
 
 
 
 
 
 
e3e35e7
8e22fcd
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import streamlit as st
from transformers import pipeline

from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error, r2_score

st.write("begin of house prediction")
st.write("load dataset")
# Load the California Housing dataset
data = fetch_california_housing(as_frame=True)
X = data.data
y = data.target

# Split the dataset into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

st.write("standardize")
# Standardize features
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

st.write("train")
# Train the model
model = LinearRegression()
model.fit(X_train, y_train)

st.write("make predictions")
# Make predictions on the test set
y_pred = model.predict(X_test)

st.write("evaluate")
# Evaluate the model
mse = mean_squared_error(y_test, y_pred)
r2 = r2_score(y_test, y_pred)

st.write(f"Mean Squared Error: {mse:.2f}")
st.write(f"R-squared Score: {r2:.2f}")
         
# print(f"Mean Squared Error: {mse:.2f}")
# print(f"R-squared Score: {r2:.2f}")

st.write("end of house prediction")

sentiment_pipeline = pipeline("sentiment-analysis")

st.title("Sentiment Analysis with HuggingFace Spaces")
st.write("Enter a sentence to analyze its sentiment:")

user_input = st.text_input("")
if user_input:
    result = sentiment_pipeline(user_input)
    sentiment = result[0]["label"]
    confidence = result[0]["score"]

    st.write(f"Sentiment: {sentiment}")
    st.write(f"Confidence: {confidence:.2f}")