hashirlodhi commited on
Commit
422efbb
·
verified ·
1 Parent(s): bfaf7cb

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +90 -0
  2. requirements (1).txt +2 -0
app.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import google.generativeai as genai
2
+ import gradio as gr
3
+
4
+ # Your API key (replace with a new one if this doesn't work)
5
+ GOOGLE_API_KEY = "AIzaSyA6B_OIML84hzYB4cQfKFDaixLMyXXMRps"
6
+
7
+ # Configure API
8
+ genai.configure(api_key=GOOGLE_API_KEY)
9
+
10
+ # Use the free model
11
+ model = genai.GenerativeModel('gemini-1.5-flash-latest')
12
+
13
+ def generate_recommendation(problem_type, dataset_size, num_features, feature_type, priority, additional_info):
14
+ prompt = f"""
15
+ You are an expert machine learning engineer specializing in algorithm selection.
16
+ Recommend machine learning algorithms for a project with these characteristics:
17
+
18
+ 1. Problem Type: {problem_type}
19
+ 2. Dataset Size: {dataset_size}
20
+ 3. Number of Features: {num_features}
21
+ 4. Feature Types: {feature_type}
22
+ 5. Priority: {priority}
23
+ 6. Additional Information: {additional_info}
24
+
25
+ Provide:
26
+ 1. Top 3 ranked algorithm recommendations (most suitable first)
27
+ 2. For each algorithm:
28
+ - Brief justification
29
+ - Strengths for this use case
30
+ - Potential limitations
31
+ 3. Final recommendation with detailed comparison
32
+
33
+ Format exactly like this:
34
+
35
+ === TOP RECOMMENDATIONS ===
36
+ 1. [Algorithm 1]
37
+ - Why: [Justification]
38
+ - Pros: [Strengths]
39
+ - Cons: [Limitations]
40
+
41
+ 2. [Algorithm 2]
42
+ - Why: [Justification]
43
+ - Pros: [Strengths]
44
+ - Cons: [Limitations]
45
+
46
+ 3. [Algorithm 3]
47
+ - Why: [Justification]
48
+ - Pros: [Strengths]
49
+ - Cons: [Limitations]
50
+
51
+ === FINAL CHOICE ===
52
+ Best Algorithm: [Algorithm Name]
53
+ - Why Best: [Detailed comparison]
54
+ - Why Others Are Less Suitable: [Explanation]
55
+ """
56
+
57
+ try:
58
+ response = model.generate_content(prompt)
59
+ return response.text
60
+ except Exception as e:
61
+ return f"Error: {e}\n\nTip: The API key may need enabling at https://aistudio.google.com/"
62
+
63
+ # Create Gradio interface
64
+ with gr.Blocks(title="ML Algorithm Recommender", theme=gr.themes.Soft()) as demo:
65
+ gr.Markdown("""
66
+ # Machine Learning Algorithm Recommender
67
+ Enter your project characteristics to get personalized algorithm recommendations
68
+ """)
69
+
70
+ with gr.Row():
71
+ with gr.Column():
72
+ problem_type = gr.Textbox(label="Problem Type*", placeholder="classification, regression, clustering...")
73
+ dataset_size = gr.Textbox(label="Dataset Size*", placeholder="small, medium, large or specific number")
74
+ num_features = gr.Textbox(label="Number of Features*", placeholder="few, many, or specific number")
75
+ feature_type = gr.Textbox(label="Feature Types*", placeholder="numerical, categorical, mixed")
76
+ priority = gr.Textbox(label="Priority*", placeholder="accuracy, speed, interpretability")
77
+ additional_info = gr.Textbox(label="Additional Details (optional)", placeholder="Any other important information")
78
+ submit_btn = gr.Button("Get Recommendations", variant="primary")
79
+
80
+ with gr.Column():
81
+ output = gr.Textbox(label="Recommendation Results", lines=20, interactive=False)
82
+
83
+ submit_btn.click(
84
+ fn=generate_recommendation,
85
+ inputs=[problem_type, dataset_size, num_features, feature_type, priority, additional_info],
86
+ outputs=output
87
+ )
88
+
89
+ if __name__ == "__main__":
90
+ demo.launch()
requirements (1).txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ google-generativeai>=0.5.0
2
+ gradio==4.44.0