DimensionReduce[{example1,example2,…}]
把实例 examplei 投影成低维近似流形.
DimensionReduce[examples,n]
投影到 n 维空间中的近似流形.
DimensionReduce
DimensionReduce[{example1,example2,…}]
把实例 examplei 投影成低维近似流形.
DimensionReduce[examples,n]
投影到 n 维空间中的近似流形.
更多信息和选项
- DimensionReduce 可用于多种数据类型,包括数值、 文本、 声音和图像,以及这些类型的组合.
- 每个 examplei 可以是单个数据元素、数据元素列表、数据元素关联或 Dataset 对象.
- DimensionReduce[examples] 自动为近似流形选择合适的维度.
- DimensionReduce[examples] 等价于 DimensionReduce[examples,Automatic].
- 可以给出以下选项:
-
FeatureExtractor Identity 怎样提取要学习的特征 FeatureNames Automatic 分配给 examplei 的元素的名称 FeatureTypes Automatic 假设 examplei 的元素的特征类型 Method Automatic 要使用哪种降维算法 PerformanceGoal Automatic 优化目标 RandomSeeding 1234 内部应怎样对伪随机数字生成器进行播种 TargetDevice "CPU" 执行培训的目标设备 - PerformanceGoal 的可能设置包括:
-
"Quality" 最大化降维质量 "Speed" 最大化降维速度 - Method 的可能设置包括:
-
Automatic 自动选择方法 "Autoencoder" 使用可训练的自动编码器 "Hadamard" 使用 Hadamard 矩阵对数据进行投影 "Isomap" 等距映射 "LatentSemanticAnalysis" 潜在语义分析方法 "Linear" 自动选择最佳的线性方法 "LLE" 本地线性嵌入 "MultidimensionalScaling" 度量多维尺度分析 (metric multidimensional scaling) "PrincipalComponentsAnalysis" 主成分分析方法 "TSNE"
-分布随机领域嵌入算法"UMAP" 统一流形逼近与投影 (uniform manifold approximation and projection) - 对于 Method"TSNE",支持下列子选项:
-
"Perplexity" Automatic 使用的困惑度值 "LinearPrereduction" False 在运行 t-SNE 算法前是否进行轻度的线性预降维处理 - RandomSeeding 的可能设置包括:
-
Automatic 每次调用函数时都自动重新播种 Inherited 使用外部播种的随机数字 seed 明确指定整数或字符串作为种子 - DimensionReduce[…,FeatureExtractor"Minimal"] 表明内部预处理应尽可能简单.
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (6)
vectors = Join[RandomReal[{0, 3}, {1000, 3}], RandomReal[{2, 5}, {1000, 3}], RandomReal[{4, 7}, {1000, 3}] ];ListPointPlot3D[vectors]ListPlot[DimensionReduce[vectors, 2]]DimensionReduce[{[image], [image], [image] , [image], [image], [image]}, 5]DimensionReduce[{"the cat is grey", "my cat is fast", "this dog is scary", "the big dog"}]DateObject 列表的降维:
DimensionReduce[{DateObject[{2014, 5, 5, 9, 53, 6.30158}, "Instant", "Gregorian", -6.], DateObject[{2000, 1, 1, 0, 0, 0.}, "Instant", "Gregorian", -6.], DateObject[{2006, 12}, "Month", "Gregorian", -6.], DateObject[{2007, 8, 23}, "Day", "Gregorian", -6.], DateObject[{2016, 4, 4, 15, 59, 18.2738}, "Instant", "Gregorian", -4.]}]DimensionReduce[{{"the cat is grey", [image]}, {"my cat is fast", [image]}, {"this dog is scary", [image]}, {"the big dog", [image]}}]DimensionReduce[{<|"age" -> 32, "height" -> 160, "gender" -> "female"|>,
<|"height" -> 183, "age" -> 41, "gender" -> "female"|>,
<|"height" -> 123, "age" -> 30, "gender" -> "female"|>,
<|"height" -> 175, "age" -> 21, "gender" -> "male"|>,
<|"height" -> 150, "age" -> 11, "gender" -> "male"|>,
<|"age" -> 52, "height" -> 164, "gender" -> "female"|>}]选项 (6)
FeatureExtractor (1)
FeatureTypes (1)
DimensionReduce[{{1, "A"}, {2, "A"}, {2, "B"}, {1, "B"}}]第一个特征被解释为数据型. 使用 FeatureTypes 将第一个特征解释为名义型:
DimensionReduce[{{1, "A"}, {2, "A"}, {2, "B"}, {1, "B"}}, FeatureTypes -> <|1 -> "Nominal"|>]Method (2)
使用 t-SNE 方法对费雪鸢尾花卉(Fisher Iris)数据集降维:
iris = ExampleData[{"MachineLearning", "FisherIris"}, "Data"];features = DimensionReduce[iris[[All, 1]], 2, Method -> "TSNE"];byspecies = GroupBy[Thread[features -> iris[[All, 2]]], Last -> First];
ListPlot[Values[byspecies], PlotLegends -> Keys[byspecies]]features = DimensionReduce[iris[[All, 1]], 2, Method -> {"TSNE", "Perplexity" -> 100}];byspecies = GroupBy[Thread[features -> iris[[All, 2]]], Last -> First];
ListPlot[Values[byspecies], PlotLegends -> Keys[byspecies]]flowers = {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image]};reduced = DimensionReduce[flowers, 2, Method -> "Autoencoder"];ListPlot[MapThread[Labeled[#1, #2]&, {reduced, flowers}]]PerformanceGoal (1)
data = ResourceData[ResourceObject["MNIST"], "TestData"];采用设置 PerformanceGoal"Quality" 对图像数据进行降维,并测量训练时间:
AbsoluteTiming[quality = DimensionReduce[data[[All, 1]], 2, Method -> "TSNE", PerformanceGoal -> "Quality"];]使用 PerformanceGoal"Speed" 进行同一操作:
AbsoluteTiming[speed = DimensionReduce[data[[All, 1]], 2, Method -> "TSNE", PerformanceGoal -> "Speed"];]groupquality = GroupBy[Thread[quality -> data[[All, 2]]], Last -> First];
ListPlot[Values[groupquality], PlotLegends -> Keys[groupquality]]groupspeed = GroupBy[Thread[speed -> data[[All, 2]]], Last -> First];
ListPlot[Values[groupspeed], PlotLegends -> Keys[groupspeed]]TargetDevice (1)
使用系统默认的 GPU 上完全连接的 "AutoEncoder" 约简向量的维数并查看 AbsoluteTiming:
AbsoluteTiming[DimensionReduce[RandomReal[1, {10000, 10}], Method -> {"AutoEncoder", "NetworkType" -> "FullyConnected"}, TargetDevice -> "GPU"]]AbsoluteTiming[DimensionReduce[RandomReal[1, {10000, 10}], Method -> {"AutoEncoder", "NetworkType" -> "FullyConnected"}]]应用 (1)
数据集可视化 (1)
从 ExampleData 加载费雪鸢尾花卉数据集:
iris = ExampleData[{"MachineLearning", "FisherIris"}, "Data"];ExampleData[{"MachineLearning", "FisherIris"}, "LongDescription"]RandomSample[iris, 5]features = DimensionReduce[iris[[All, 1]], 2];byspecies = GroupBy[Thread[features -> iris[[All, 2]]], Last -> First];ListPlot[Values[byspecies], PlotLegends -> Keys[byspecies]]相关指南
-
▪
- 无监督机器学习
文本
Wolfram Research (2015),DimensionReduce,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DimensionReduce.html (更新于 2018 年).
CMS
Wolfram 语言. 2015. "DimensionReduce." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2018. https://reference.wolfram.com/language/ref/DimensionReduce.html.
APA
Wolfram 语言. (2015). DimensionReduce. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DimensionReduce.html 年
BibTeX
@misc{reference.wolfram_2026_dimensionreduce, author="Wolfram Research", title="{DimensionReduce}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/DimensionReduce.html}", note=[Accessed: 05-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_dimensionreduce, organization={Wolfram Research}, title={DimensionReduce}, year={2018}, url={https://reference.wolfram.com/language/ref/DimensionReduce.html}, note=[Accessed: 05-September-2026]}