politewolf commited on
Commit
b644b70
·
0 Parent(s):

first commit

Browse files
Files changed (6) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. Startups.csv +51 -0
  4. app.py +77 -0
  5. best_regression_model.pkl +3 -0
  6. requirements.txt +3 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Profit Prediction
3
+ emoji: 🌍
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: streamlit
7
+ sdk_version: 1.52.2
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ short_description: A simple regression model to predict profit.
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Startups.csv ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ R&D Spend,Administration,Marketing Spend,State,Profit
2
+ 165349.2,136897.8,471784.1,New York,192261.83
3
+ 162597.7,151377.59,443898.53,California,191792.06
4
+ 153441.51,101145.55,407934.54,Florida,191050.39
5
+ 144372.41,118671.85,383199.62,New York,182901.99
6
+ 142107.34,91391.77,366168.42,Florida,166187.94
7
+ 131876.9,99814.71,362861.36,New York,156991.12
8
+ 134615.46,147198.87,127716.82,California,156122.51
9
+ 130298.13,145530.06,323876.68,Florida,155752.6
10
+ 120542.52,148718.95,311613.29,New York,152211.77
11
+ 123334.88,108679.17,304981.62,California,149759.96
12
+ 101913.08,110594.11,229160.95,Florida,146121.95
13
+ 100671.96,91790.61,249744.55,California,144259.4
14
+ 93863.75,127320.38,249839.44,Florida,141585.52
15
+ 91992.39,135495.07,252664.93,California,134307.35
16
+ 119943.24,156547.42,256512.92,Florida,132602.65
17
+ 114523.61,122616.84,261776.23,New York,129917.04
18
+ 78013.11,121597.55,264346.06,California,126992.93
19
+ 94657.16,145077.58,282574.31,New York,125370.37
20
+ 91749.16,114175.79,294919.57,Florida,124266.9
21
+ 86419.7,153514.11,0,New York,122776.86
22
+ 76253.86,113867.3,298664.47,California,118474.03
23
+ 78389.47,153773.43,299737.29,New York,111313.02
24
+ 73994.56,122782.75,303319.26,Florida,110352.25
25
+ 67532.53,105751.03,304768.73,Florida,108733.99
26
+ 77044.01,99281.34,140574.81,New York,108552.04
27
+ 64664.71,139553.16,137962.62,California,107404.34
28
+ 75328.87,144135.98,134050.07,Florida,105733.54
29
+ 72107.6,127864.55,353183.81,New York,105008.31
30
+ 66051.52,182645.56,118148.2,Florida,103282.38
31
+ 65605.48,153032.06,107138.38,New York,101004.64
32
+ 61994.48,115641.28,91131.24,Florida,99937.59
33
+ 61136.38,152701.92,88218.23,New York,97483.56
34
+ 63408.86,129219.61,46085.25,California,97427.84
35
+ 55493.95,103057.49,214634.81,Florida,96778.92
36
+ 46426.07,157693.92,210797.67,California,96712.8
37
+ 46014.02,85047.44,205517.64,New York,96479.51
38
+ 28663.76,127056.21,201126.82,Florida,90708.19
39
+ 44069.95,51283.14,197029.42,California,89949.14
40
+ 20229.59,65947.93,185265.1,New York,81229.06
41
+ 38558.51,82982.09,174999.3,California,81005.76
42
+ 28754.33,118546.05,172795.67,California,78239.91
43
+ 27892.92,84710.77,164470.71,Florida,77798.83
44
+ 23640.93,96189.63,148001.11,California,71498.49
45
+ 15505.73,127382.3,35534.17,New York,69758.98
46
+ 22177.74,154806.14,28334.72,California,65200.33
47
+ 1000.23,124153.04,1903.93,New York,64926.08
48
+ 1315.46,115816.21,297114.46,Florida,49490.75
49
+ 0,135426.92,0,California,42559.73
50
+ 542.05,51743.15,0,New York,35673.41
51
+ 0,116983.8,45173.06,California,14681.4
app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from sklearn.pipeline import Pipeline
3
+ from sklearn.compose import ColumnTransformer
4
+ from sklearn.preprocessing import StandardScaler, OneHotEncoder
5
+ import streamlit as st
6
+ import joblib
7
+
8
+ # Load the trained model and dataset
9
+ model = joblib.load('best_regression_model.pkl')
10
+
11
+ df = pd.read_csv('Startups.csv')
12
+
13
+ # Preprocessor setup for scaling numerical and encoding categorical features
14
+ preprocessor = ColumnTransformer(
15
+ transformers=[
16
+ ('num', StandardScaler(), ['R&D Spend', 'Administration', 'Marketing Spend']),
17
+ ('cat', OneHotEncoder(), ['State'])
18
+ ]
19
+ )
20
+
21
+ # Pipeline for preprocessing and model prediction
22
+ pipeline = Pipeline(steps=[('preprocessor', preprocessor), ('regressor', model)])
23
+ pipeline.fit(df[['R&D Spend', 'Administration', 'Marketing Spend', 'State']], df['Profit'])
24
+
25
+ # Prediction function
26
+ def price_pred(rd, administration, marketing, state):
27
+ input_data = pd.DataFrame({
28
+ 'R&D Spend': [rd],
29
+ 'Administration': [administration],
30
+ 'Marketing Spend': [marketing],
31
+ 'State': [state]
32
+ })
33
+ prediction = pipeline.predict(input_data)[0]
34
+ return prediction
35
+
36
+ # Main function for Streamlit app layout
37
+ def main():
38
+ st.set_page_config(page_title="Profit Prediction", page_icon="💰", layout="wide")
39
+
40
+ # Header Section
41
+ st.title("💼 Profit Prediction Tool")
42
+ st.markdown("""
43
+ Welcome to the **Profit Prediction Tool**! This tool uses machine learning to predict the profit of a company
44
+ based on different financial parameters. Please input the values for **R&D Spend**, **Administration Spend**,
45
+ and **Marketing Spend** along with the **State** to get the predicted profit.
46
+ """)
47
+
48
+ # Sidebar Section for better organization
49
+ st.sidebar.header("Enter Your Company Details")
50
+ state = st.sidebar.selectbox('Select your State', df['State'].unique())
51
+ rd = st.sidebar.number_input('R&D Spend Amount ($)', 0, int(df['R&D Spend'].max()), step=1000)
52
+ administration = st.sidebar.number_input('Administration Spend Amount ($)', 0, int(df['Administration'].max()), step=1000)
53
+ marketing = st.sidebar.number_input('Marketing Spend Amount ($)', 0, int(df['Marketing Spend'].max()), step=1000)
54
+
55
+ # Display entered data for user confirmation
56
+ st.markdown("### You entered:")
57
+ st.write(f"**State**: {state}")
58
+ st.write(f"**R&D Spend**: ${rd:,.2f}")
59
+ st.write(f"**Administration Spend**: ${administration:,.2f}")
60
+ st.write(f"**Marketing Spend**: ${marketing:,.2f}")
61
+
62
+ # Prediction Button
63
+ if st.sidebar.button('Predict Profit'):
64
+ profit = price_pred(rd, administration, marketing, state)
65
+ profit = float(profit)
66
+ st.markdown(f"### The Predicted Profit is: **${profit:,.2f}**")
67
+
68
+ # Add some styling with markdown and display information
69
+ st.markdown("""
70
+ ---
71
+ ### About the Model
72
+ The model is built using a **regression algorithm** that takes into account the R&D spend, administration expenses,
73
+ and marketing spend for a company to predict its profit. The model was trained using real-world company data.
74
+ """)
75
+
76
+ if __name__ == '__main__':
77
+ main()
best_regression_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d1a197dc6c1c7a0c03998e4f615650f5f33a647c681655f86cdbbf2744f563a
3
+ size 178493
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ scikit-learn==1.5.2
2
+ streamlit
3
+ joblib