Spaces:
Sleeping
Sleeping
Commit
·
62af38c
1
Parent(s):
6dd31bd
working tech stack advisor app
Browse files- .dockerignore +38 -0
- app.py +31 -0
- requirements.txt +4 -0
- train.py +36 -0
.dockerignore
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Ignore virtual environments
|
| 2 |
+
.venv/
|
| 3 |
+
venv/
|
| 4 |
+
|
| 5 |
+
# Python cache
|
| 6 |
+
__pycache__/
|
| 7 |
+
*.pyc
|
| 8 |
+
*.pyo
|
| 9 |
+
*.pyd
|
| 10 |
+
*.pyc
|
| 11 |
+
*.pyo
|
| 12 |
+
*.pyd
|
| 13 |
+
*.pdb
|
| 14 |
+
*.egg-info/
|
| 15 |
+
|
| 16 |
+
# Jupyter Notebook checkpoints (if applicable)
|
| 17 |
+
.ipynb_checkpoints/
|
| 18 |
+
|
| 19 |
+
# MacOS metadata
|
| 20 |
+
.DS_Store
|
| 21 |
+
|
| 22 |
+
# VSCode or other IDE settings
|
| 23 |
+
.vscode/
|
| 24 |
+
.idea/
|
| 25 |
+
|
| 26 |
+
# Git files
|
| 27 |
+
.git
|
| 28 |
+
.gitignore
|
| 29 |
+
|
| 30 |
+
# Test folders or data artifacts (if any)
|
| 31 |
+
*.log
|
| 32 |
+
*.csv
|
| 33 |
+
*.tsv
|
| 34 |
+
*.xlsx
|
| 35 |
+
|
| 36 |
+
# Docker-specific
|
| 37 |
+
Dockerfile.*
|
| 38 |
+
.dockerignore
|
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pickle
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Load trained model and encoders
|
| 6 |
+
model = pickle.load(open("model.pkl", "rb"))
|
| 7 |
+
encoders = pickle.load(open("encoders.pkl", "rb"))
|
| 8 |
+
|
| 9 |
+
def recommend_stack(project_type, team_size, perf_need, experience):
|
| 10 |
+
pt = encoders["project_type"].transform([project_type])[0]
|
| 11 |
+
pn = encoders["perf_need"].transform([perf_need])[0]
|
| 12 |
+
ex = encoders["experience"].transform([experience])[0]
|
| 13 |
+
input_data = np.array([[pt, team_size, pn, ex]])
|
| 14 |
+
pred_encoded = model.predict(input_data)[0]
|
| 15 |
+
return f"🔧 Recommended Tech Stack: {encoders['stack'].inverse_transform([pred_encoded])[0]}"
|
| 16 |
+
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=recommend_stack,
|
| 19 |
+
inputs=[
|
| 20 |
+
gr.Radio(["Web App", "API", "ML App", "Real-time App"], label="Project Type"),
|
| 21 |
+
gr.Slider(1, 10, step=1, label="Team Size"),
|
| 22 |
+
gr.Radio(["Low", "Medium", "High"], label="Performance Need"),
|
| 23 |
+
gr.Radio(["Beginner", "Intermediate", "Expert"], label="Experience Level")
|
| 24 |
+
],
|
| 25 |
+
outputs="text",
|
| 26 |
+
title="Tech Stack Advisor",
|
| 27 |
+
description="Get a recommended tech stack based on your project and team!"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 31 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
scikit-learn==1.3.2
|
| 2 |
+
pandas==2.1.4
|
| 3 |
+
numpy==1.26.4
|
| 4 |
+
gradio==4.44.1
|
train.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
from sklearn.preprocessing import LabelEncoder
|
| 3 |
+
from sklearn.tree import DecisionTreeClassifier
|
| 4 |
+
import pickle
|
| 5 |
+
|
| 6 |
+
# Sample synthetic data
|
| 7 |
+
data = {
|
| 8 |
+
"project_type": ["Web App", "API", "ML App", "Real-time App", "Web App"],
|
| 9 |
+
"team_size": [3, 2, 5, 6, 1],
|
| 10 |
+
"perf_need": ["Medium", "Low", "Medium", "High", "Low"],
|
| 11 |
+
"experience": ["Intermediate", "Beginner", "Expert", "Expert", "Beginner"],
|
| 12 |
+
"stack": ["Django + PostgreSQL", "Flask + SQLite", "FastAPI + TensorFlow", "Node.js + Redis", "Django + SQLite"]
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
df = pd.DataFrame(data)
|
| 16 |
+
|
| 17 |
+
# Encode categorical variables
|
| 18 |
+
encoders = {}
|
| 19 |
+
for col in ["project_type", "perf_need", "experience", "stack"]:
|
| 20 |
+
le = LabelEncoder()
|
| 21 |
+
df[col] = le.fit_transform(df[col])
|
| 22 |
+
encoders[col] = le
|
| 23 |
+
|
| 24 |
+
# Train model
|
| 25 |
+
X = df[["project_type", "team_size", "perf_need", "experience"]]
|
| 26 |
+
y = df["stack"]
|
| 27 |
+
model = DecisionTreeClassifier()
|
| 28 |
+
model.fit(X, y)
|
| 29 |
+
|
| 30 |
+
# Save model
|
| 31 |
+
with open("model.pkl", "wb") as f:
|
| 32 |
+
pickle.dump(model, f)
|
| 33 |
+
|
| 34 |
+
# Save encoders for use in app
|
| 35 |
+
with open("encoders.pkl", "wb") as f:
|
| 36 |
+
pickle.dump(encoders, f)
|