| import gradio as gr |
| import random |
|
|
| def analyze_data(data_source, timeframe, metric): |
| data_points = random.randint(5000, 50000) |
| avg_value = round(random.uniform(20, 80), 2) |
| peak = round(random.uniform(80, 100), 2) |
| anomalies = random.randint(0, 15) |
| |
| result = f"""### IoT Data Analysis Results |
| |
| **Data Source**: {data_source} |
| **Timeframe**: {timeframe} |
| **Metric**: {metric} |
| |
| π **Analysis Summary**: |
| - Total Data Points: {data_points:,} |
| - Average Value: {avg_value} |
| - Peak Value: {peak} |
| - Anomalies Detected: {anomalies} |
| - Data Quality Score: {round(random.uniform(85, 99), 1)}% |
| |
| **Insights**: The IoT data shows {'consistent patterns' if anomalies < 5 else 'some irregularities'} over the {timeframe.lower()} period. |
| |
| --- |
| **Anktechsol** - IoT Analytics Platform |
| π [Visit anktechsol.com](https://anktechsol.com)""" |
| return result |
|
|
| with gr.Blocks(title="IoT Data Analyzer") as demo: |
| gr.Markdown("# π IoT Data Analytics Platform") |
| gr.Markdown("Advanced IoT data insights - **Anktechsol**") |
| |
| with gr.Row(): |
| with gr.Column(): |
| source = gr.Dropdown(["Temperature Sensors", "Humidity Sensors", "Pressure Sensors", "Motion Detectors"], label="Data Source", value="Temperature Sensors") |
| time = gr.Radio(["Last Hour", "Last 24 Hours", "Last 7 Days", "Last 30 Days"], label="Timeframe", value="Last 24 Hours") |
| metric = gr.Dropdown(["Average", "Peak", "Trend Analysis", "Anomaly Detection"], label="Analysis Metric", value="Average") |
| btn = gr.Button("Analyze Data") |
| |
| with gr.Column(): |
| output = gr.Markdown() |
| |
| btn.click(analyze_data, inputs=[source, time, metric], outputs=output) |
| |
| gr.Markdown("""--- |
| ### Anktechsol - IoT Analytics Experts |
| Comprehensive IoT data solutions. [Contact us](https://anktechsol.com)""") |
|
|
| demo.launch() |