Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冯丙见
Python_01
提交
4feb6e2e
P
Python_01
项目概览
冯丙见
/
Python_01
与 Fork 源项目一致
Fork自
inscode / Python
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Python_01
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4feb6e2e
编写于
4月 14, 2023
作者:
6
622aa39c1f9b166ab1a38c05
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fri Apr 14 09:35:00 UTC 2023 inscode
上级
457f92e4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
14 deletion
+80
-14
main.py
main.py
+21
-6
test.json
test.json
+27
-8
test2.py
test2.py
+32
-0
未找到文件。
main.py
浏览文件 @
4feb6e2e
print
(
'欢迎来到 InsCode'
)
import
os
print
(
os
.
path
.
dirname
(
'./'
))
import
numpy
print
(
numpy
.
__version__
)
import
\ No newline at end of file
import
numpy
as
np
# 生成一个10x10的随机矩阵
rand_mat
=
np
.
random
.
rand
(
10
,
10
)
# 输出矩阵的形状和数据类型
print
(
rand_mat
)
print
(
"Matrix shape:"
,
rand_mat
.
shape
)
print
(
"Matrix data type:"
,
rand_mat
.
dtype
)
# 计算矩阵的平均值、最小值、最大值和总和
mean
=
np
.
mean
(
rand_mat
)
min_val
=
np
.
min
(
rand_mat
)
max_val
=
np
.
max
(
rand_mat
)
sum_val
=
np
.
sum
(
rand_mat
)
# 输出计算结果
print
(
"Mean value:"
,
mean
)
print
(
"Minimum value:"
,
min_val
)
print
(
"Maximum value:"
,
max_val
)
print
(
"Sum value:"
,
sum_val
)
test.json
浏览文件 @
4feb6e2e
{
"$schema"
:
"https://www.quickapi.cloud/schema.json"
,
"pipeline"
:
[
{
"name"
:
"redis"
,
"action"
:
"get"
,
"key"
:
"user_${param.session_id}"
,
"output"
:
"user"
,
"json"
:
true
,
"property"
:
"common_redis"
},
{
"name"
:
"pipeline"
,
"uri"
:
"/test"
,
...
...
@@ -33,5 +25,32 @@
}
]
}
],
"response_code"
:
[
{
"name"
:
"success"
,
"code"
:
200
,
"message"
:
"success"
},
{
"name"
:
"fail"
,
"code"
:
500
,
"message"
:
"fail"
}
],
"property"
:
{
"common_redis"
:
{
"url"
:
"redis://127.0.0.1:6379"
},
"db_interview"
:
{
"driver"
:
"com.mysql.jdbc.Driver"
,
"url"
:
"jdbc:mysql://localhost:3306/xxx?useUnicode=true&characterEncoding=utf8"
,
"user_name"
:
"root"
,
"password"
:
"123456"
}
},
"include"
:
[
"config/db.json"
,
"http://localhost:8081/api/b/v1/t_config?app=test"
]
}
\ No newline at end of file
test2.py
0 → 100644
浏览文件 @
4feb6e2e
from
sklearn.datasets
import
fetch_20newsgroups
from
sklearn.feature_extraction.text
import
CountVectorizer
from
sklearn.naive_bayes
import
MultinomialNB
from
sklearn.metrics
import
accuracy_score
# 加载新闻数据集
news_data
=
fetch_20newsgroups
(
subset
=
'all'
,
categories
=
[
'alt.atheism'
,
'talk.religion.misc'
])
print
(
news_data
.
data
[
0
])
# 将数据集分为训练集和测试集
train_data
=
fetch_20newsgroups
(
subset
=
'train'
,
categories
=
[
'alt.atheism'
,
'talk.religion.misc'
])
test_data
=
fetch_20newsgroups
(
subset
=
'test'
,
categories
=
[
'alt.atheism'
,
'talk.religion.misc'
])
print
(
'---------------'
)
print
(
test_data
.
data
[
0
])
print
(
'---------a-------a-------'
)
print
(
test_data
.
target
[
0
])
# 将文本转换为特征向量
vectorizer
=
CountVectorizer
()
train_features
=
vectorizer
.
fit_transform
(
train_data
.
data
)
test_features
=
vectorizer
.
transform
(
test_data
.
data
)
# 训练朴素贝叶斯分类器
clf
=
MultinomialNB
()
clf
.
fit
(
train_features
,
train_data
.
target
)
# 预测测试集并计算准确率
pred
=
clf
.
predict
(
test_features
)
accuracy
=
accuracy_score
(
test_data
.
target
,
pred
)
print
(
"Accuracy:"
,
accuracy
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录