https://api.vvhan.com/api/avatar/boy

技术博客分享

SciKit-Learn-全面分析分类任务-wine-葡萄酒数据集

本文对葡萄酒数据集(178个样本,13个特征,3个类别)进行了7种分类模型的比较分析。通过标准化预处理后,分别测试了K近邻、决策树、SVM、逻辑回归、随机森林、朴素贝叶斯和MLP模型。结果显示,随机森林和朴素贝叶斯表现最佳,准确率达100%;SVM、逻辑回归和MLP准确率为98.15%;K近邻和决策树为96.30%。ROC曲线分析表明各模型对三类葡萄酒均有良好区分能力,其中随机森林和朴素贝叶斯的AUC值达到1.0,展现出最优的分类性能。该研究为葡萄酒品种识别提供了有效的机器学习方法参考。

html获取16个随机颜色并不重复

html获取16个随机颜色并不重复

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>16个不重复随机颜色</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        body {
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
            color: #fff;
            min-height: 100vh;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .container {
            max-width: 1200px;
            width: 100%;
            text-align: center;
        }
        h1 {
            margin: 20px 0;
            font-size: 2.8rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
        }
        .description {
            margin-bottom: 30px;
            font-size: 1.2rem;
            max-width: 800px;
            line-height: 1.6;
        }
        .colors-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 20px;
            width: 100%;
            margin-bottom: 40px;
        }
        .color-box {
            height: 150px;
            border-radius: 10px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            overflow: hidden;
            cursor: pointer;
        }
        .color-box:hover {
            transform: translateY(-5px);
            box-shadow: 0 12px 20px rgba(0, 0, 0, 0.4);
        }
        .color-value {
            background-color: rgba(0, 0, 0, 0.5);
            padding: 8px 15px;
            border-radius: 20px;
            font-weight: bold;
            margin-top: 10px;
            backdrop-filter: blur(5px);
        }
        .controls {
            margin: 20px 0;
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            justify-content: center;
            align-items: center;
        }
        button {
            padding: 12px 25px;
            background: #2c3e50;
            color: white;
            border: none;
            border-radius: 30px;
            cursor: pointer;
            font-size: 1rem;
            font-weight: bold;
            transition: all 0.3s ease;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        button:hover {
            background: #3498db;
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
        }
        .excluded-colors {
            margin-top: 30px;
            background: rgba(0, 0, 0, 0.2);
            padding: 20px;
            border-radius: 15px;
            max-width: 800px;
        }
        .excluded-colors h2 {
            margin-bottom: 15px;
        }
        .excluded-list {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
        }
        .excluded-color {
            width: 50px;
            height: 50px;
            border-radius: 8px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 0.8rem;
            font-weight: bold;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        .notification {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.8);
            color: white;
            padding: 15px 25px;
            border-radius: 30px;
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        .show {
            opacity: 1;
        }
        @media (max-width: 768px) {
            .colors-container {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            }
            h1 {
                font-size: 2rem;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>16个不重复随机颜色生成器</h1>
        <p class="description">点击下方按钮生成16个独特的随机颜色,已排除您提供的颜色。点击颜色框可以复制色值到剪贴板。</p>
        
        <div class="controls">
            <button id="generate-btn">生成新颜色</button>
            <button id="copy-all-btn">复制所有色值</button>
        </div>
        
        <div class="colors-container" id="colors-container">
            <!-- 颜色框将通过JavaScript动态生成 -->
        </div>
        
        <div class="excluded-colors">
            <h2>已排除的颜色</h2>
            <div class="excluded-list">
                <div class="excluded-color" style="background-color: #FFEA3B;">#FFEA3B</div>
                <div class="excluded-color" style="background-color: #1569FF;">#1569FF</div>
                <div class="excluded-color" style="background-color: #6462CC;">#6462CC</div>
                <div class="excluded-color" style="background-color: #23B3FF;">#23B3FF</div>
                <div class="excluded-color" style="background-color: #14FFF1;">#14FFF1</div>
                <div class="excluded-color" style="background-color: #01B064;">#01B064</div>
            </div>
        </div>
    </div>
    
    <div class="notification" id="notification">颜色已复制到剪贴板</div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const colorsContainer = document.getElementById('colors-container');
            const generateBtn = document.getElementById('generate-btn');
            const copyAllBtn = document.getElementById('copy-all-btn');
            const notification = document.getElementById('notification');
            
            // 需要排除的颜色列表
            const excludedColors = [
                '#FFEA3B', '#1569FF', '#6462CC', 
                '#23B3FF', '#14FFF1', '#01B064'
            ];
            
            // 生成随机颜色
            function generateRandomColor() {
                const letters = '0123456789ABCDEF';
                let color = '#';
                for (let i = 0; i < 6; i++) {
                    color += letters[Math.floor(Math.random() * 16)];
                }
                return color;
            }
            
            // 生成16个不重复且不在排除列表中的颜色
            function generateUniqueColors() {
                const colors = new Set();
                
                while (colors.size < 16) {
                    const color = generateRandomColor();
                    if (!excludedColors.includes(color.toUpperCase()) && !colors.has(color)) {
                        colors.add(color);
                    }
                }
                
                return Array.from(colors);
            }
            
            // 显示颜色
            function displayColors() {
                colorsContainer.innerHTML = '';
                const colors = generateUniqueColors();
                
                colors.forEach(color => {
                    const colorBox = document.createElement('div');
                    colorBox.className = 'color-box';
                    colorBox.style.backgroundColor = color;
                    
                    const colorValue = document.createElement('div');
                    colorValue.className = 'color-value';
                    colorValue.textContent = color;
                    
                    colorBox.appendChild(colorValue);
                    colorsContainer.appendChild(colorBox);
                    
                    // 添加点击复制功能
                    colorBox.addEventListener('click', () => {
                        copyToClipboard(color);
                        showNotification(`已复制: ${color}`);
                    });
                });
            }
            
            // 复制到剪贴板
            function copyToClipboard(text) {
                const textarea = document.createElement('textarea');
                textarea.value = text;
                document.body.appendChild(textarea);
                textarea.select();
                document.execCommand('copy');
                document.body.removeChild(textarea);
            }
            
            // 显示通知
            function showNotification(message) {
                notification.textContent = message;
                notification.classList.add('show');
                
                setTimeout(() => {
                    notification.classList.remove('show');
                }, 2000);
            }
            
            // 复制所有颜色
            function copyAllColors() {
                const colorBoxes = document.querySelectorAll('.color-value');
                const allColors = Array.from(colorBoxes).map(box => box.textContent).join('\n');
                copyToClipboard(allColors);
                showNotification('所有颜色值已复制到剪贴板');
            }
            
            // 初始化
            displayColors();
            
            // 事件监听
            generateBtn.addEventListener('click', displayColors);
            copyAllBtn.addEventListener('click', copyAllColors);
        });
    </script>
</body>
</html>

机器学习介绍

机器学习也借鉴了人类学习模式,分为有监督学习(如识别物体)、无监督学习(无监督学习就像是让计算机自己在一堆杂乱的数据里找规律、做分类,不需要人提前告诉它 “答案”。从定义看,对于给定任务 T,在合理性能度量方案 P 下,计算机程序可自主学习任务 T 的经验 E,且随着优质、大量经验 E 的积累,程序对任务 T 的性能会逐步提升。机器学习的运作,依赖计算机系统依据训练数据按特定方式学习,随着训练次数增加,系统性能不断改进,经参数优化的学习模型能预测相关问题输出。

设计模式从游戏角度开始了解设计模式-抽象工厂模式

本文介绍了抽象工厂设计模式,通过游戏装备系统的案例展示了其实现方式。文章首先将抽象工厂与普通工厂模式进行对比,指出抽象工厂适用于多维度产品变种场景。随后以C++代码示例详细演示了装备基类、具体产品、抽象工厂和具体工厂的实现过程,并总结了四大要素。文章列举了抽象工厂的典型应用场景,包括GUI框架、游戏引擎文件系统、UI主题切换和跨平台网络库等。最后分析了模式的优缺点,强调其多维定制化能力但伴随复杂性增加的特点,并指出抽象工厂产品通常需要协同工作。

ubuntu22.04-安装Docker

本文提供了在Ubuntu系统上安装Docker的详细步骤:1)更新系统并安装依赖;2)添加Docker官方GPG密钥和APT仓库;3)安装Docker引擎及相关组件;4)配置镜像加速器;5)重启服务并验证安装。最后还介绍了如何配置免sudo使用Docker,通过将用户加入docker组来简化操作。整个流程涵盖了从环境准备到安装验证的完整过程,适合Ubuntu用户快速部署Docker环境。