From b8ffb919e39348a0f3865036988d805116d42e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Thu, 25 May 2023 20:09:10 +0200 Subject: [PATCH 1/8] Updated examples to plot PCA with Roassal 3. This needs https://github.com/PolyMathOrg/DataFrame/pull/237 to be merged. --- .../PMPrincipalComponentAnalyserSVD.class.st | 91 +++++++++++++++---- 1 file changed, 75 insertions(+), 16 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 01571bbe..ead19fd8 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -11,28 +11,87 @@ Class { { #category : #examples } PMPrincipalComponentAnalyserSVD class >> example1 [ + "Extract 4 columns from original data" -"Extract 4 columns from original data" -| d m pca m1 d1 | -d := (DataFrame loadIris) columnsFrom: 1 to: 4. + | d m pca m1 d1 irisDataFrame roassalChart scatterPlotShapes | + + irisDataFrame := AIDatasets loadIris. + d := irisDataFrame columnsFrom: 1 to: 4. + + "Transform DF as matrix" + m := PMMatrix rows: d asArrayOfRows. + + "Data standardization (mean = 0 and variance = 1)" + m := PMStandardizationScaler new fitAndTransform: m. + + "Compute PCA components" + pca := PMPrincipalComponentAnalyserSVD new. + pca componentsNumber: 2. + pca fit: m. + pca transformMatrix. + + m1 := pca transform: m. -"Transform DF as matrix" -m := PMMatrix rows: (d asArrayOfRows). + d1 := DataFrame withRows: m1 rows. + d1 + addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first + named: 'type'. + + roassalChart := RSChart new + title: 'PCA of Iris Data Frame'; + addDecoration: (RSHorizontalTick new doNotUseNiceLabel asFloat: 3); + addDecoration: RSVerticalTick new; + yourself. -"Data standardization (mean = 0 and variance = 1)" -m := (PMStandardizationScaler new) fitAndTransform: m. + scatterPlotShapes := (d1 column: 'type') asSet collect: [ : type | + (d1 select: [ : e | e values includes: type ]) + addScatterPlotShapeToChart: roassalChart ]. -"Compute PCA components" -pca := PMPrincipalComponentAnalyserSVD new. -pca componentsNumber: 2. -pca fit: m. -pca transformMatrix. + roassalChart padding: 10. + scatterPlotShapes asOrderedCollection + with: { Color red . Color green . Color blue } + do: [ : scatterPlotShape : scatterPlotDotColor | + scatterPlotShape color: scatterPlotDotColor ]. -m1 := pca transform: m. + roassalChart open. + + +] + +{ #category : #examples } +PMPrincipalComponentAnalyserSVD class >> example2 [ + "Extract 4 columns from original data. This example uses Random colors for each flower type" -d1 := DataFrame fromRows: m1 rows. -d1 addColumn: ((DataFrame loadIris) columnsFrom:5 to:5) asArrayOfColumns first named:''. -d1 scatterplotMatrix. + | d m pca m1 d1 irisDataFrame | + + irisDataFrame := AIDatasets loadIris. + d := irisDataFrame columnsFrom: 1 to: 4. + + "Transform DF as matrix" + m := PMMatrix rows: d asArrayOfRows. + + "Data standardization (mean = 0 and variance = 1)" + m := PMStandardizationScaler new fitAndTransform: m. + + "Compute PCA components" + pca := PMPrincipalComponentAnalyserSVD new. + pca componentsNumber: 2. + pca fit: m. + pca transformMatrix. + + m1 := pca transform: m. + + d1 := DataFrame withRows: m1 rows. + d1 + addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first + named: 'type'. + + d1 + openScatterPlotWithTitle: 'PCA of Iris data set' + forColumn: 'type'. + + + ] { #category : #accessing } From f24cbfbe20b03d9ae0e475be61b4fc6e99895fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Wed, 27 Dec 2023 15:54:31 +0100 Subject: [PATCH 2/8] Add visualizations package with dependencies. Update baseline dependencies. Also reduce baseline long method. Update Roassal deprecated class names. --- .../BaselineOfPolyMath.class.st | 261 ++++++++++++------ src/BaselineOfPolyMath/package.st | 2 +- .../PMDataTransformer.class.st | 13 +- .../PMPrincipalComponentAnalyser.class.st | 17 +- ...onentAnalyserJacobiTransformation.class.st | 21 +- .../PMPrincipalComponentAnalyserSVD.class.st | 21 +- .../PMSciKitLearnSVDFlipAlgorithm.class.st | 23 +- .../PMStandardizationScaler.class.st | 17 +- .../package.st | 2 +- 9 files changed, 240 insertions(+), 137 deletions(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 8f323990..d47e3c05 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -10,12 +10,13 @@ PolyMath is a Smalltalk project, similar to existing scientific libraries like N " Class { - #name : #BaselineOfPolyMath, - #superclass : #BaselineOf, - #category : #BaselineOfPolyMath + #name : 'BaselineOfPolyMath', + #superclass : 'BaselineOf', + #category : 'BaselineOfPolyMath', + #package : 'BaselineOfPolyMath' } -{ #category : #baseline } +{ #category : 'baselines' } BaselineOfPolyMath >> baseline: spec [ @@ -24,80 +25,13 @@ BaselineOfPolyMath >> baseline: spec [ sMark: spec; xmlWriter: spec; vectorMatrix: spec; - randomNumbers: spec. + randomNumbers: spec; + datasets: spec; + dataFrameInspector: spec. - spec - package: 'ExtendedNumberParser'; - package: 'Math-Accuracy-Core'; - package: 'Math-Accuracy-ODE' with: [ spec requires: #( 'Math-ODE' 'XMLWriter' ) ]; - package: 'Math-ArbitraryPrecisionFloat' with: [ spec requires: #( 'ExtendedNumberParser' ) ]; - package: 'Math-AutomaticDifferenciation' with: [ spec requires: #( 'Math-Numerical' 'MathVectorMatrix' ) ]; - package: 'Math-Benchmarks-KDTree' with: [ spec requires: #( 'Math-KDTree' 'SMark' ) ]; - package: 'Math-Benchmarks-ODE' with: [ spec requires: #( 'Math-ODE' 'SMark' 'XMLWriter' ) ]; - package: 'Math-Chromosome' with: [ spec requires: #( 'MathVectorMatrix' ) ]; - package: 'Math-Clustering' with: [ spec requires: #( 'Math-Numerical' 'Math-Core-Process' 'MathVectorMatrix' ) ]; - package: 'Math-Complex' with: [ spec requires: #( 'Math-Numerical' 'Math-Polynomials' ) ]; - package: 'Math-Helpers'; - package: 'Math-Distributions' with: [ spec requires: #( 'MathVectorMatrix' 'Math-Quantile' 'Math-Core-Process' ) ]; - package: 'Math-Core-Process'; - package: 'Math-Numerical' - with: [ spec requires: #( 'MathVectorMatrix' 'Math-Core-Process' 'Math-Distributions' 'Math-StatisticalMoments' - 'Math-Series' ) ]; - package: 'Math-Polynomials' - with: [ spec requires: #( 'MathVectorMatrix' 'Math-Core-Process' 'Math-Distributions' 'Math-StatisticalMoments' - 'Math-Series' ) ]; - package: 'Math-FastFourierTransform' with: [ spec requires: #( 'Math-Complex' ) ]; - package: 'Math-FunctionFit' - with: [ spec requires: #( 'Math-Numerical' 'Math-Chromosome' 'Math-Accuracy-Core' 'MathVectorMatrix' 'Math-Helpers' 'Math-Polynomials' ) ]; - package: 'Math-KDTree'; - package: 'Math-Number-Extensions'; - package: 'Math-ODE' with: [ spec requires: #( 'Math-Numerical' 'MathVectorMatrix' 'Math-Polynomials' ) ]; - package: 'Math-Permutation' with: [ spec requires: #( 'MathVectorMatrix' 'Math-Core-Process' ) ]; - package: 'Math-Physics-Constants'; - package: 'Math-PrincipalComponentAnalysis' with: [ spec requires: #( 'Math-Numerical' 'MathVectorMatrix' 'Math-Polynomials' ) ]; - package: 'Math-Quantile'; - package: 'Math-Quaternion' with: [ spec requires: #( 'Math-Complex' 'Math-Numerical' 'Math-Polynomials' ) ]; - package: 'Math-Series'; - package: 'Math-StatisticalMoments' with: [ spec requires: #( 'Math-Helpers' 'Math-Distributions' ) ]; - package: 'Math-TSNE'; - package: 'Math-Tests-Accuracy' with: [ spec requires: #( 'Math-Accuracy-Core' ) ]; - package: 'Math-Tests-ArbitraryPrecisionFloat' with: [ spec requires: #( 'Math-ArbitraryPrecisionFloat' ) ]; - package: 'Math-Tests-AutomaticDifferenciation' with: [ spec requires: #( 'Math-AutomaticDifferenciation' 'MathVectorMatrix' ) ]; - package: 'Math-Tests-Clustering' with: [ spec requires: #( 'Math-Clustering' 'Math-Distributions' 'Math-UtilsDataServer' ) ]; - package: 'Math-Tests-Complex' with: [ spec requires: #( 'Math-Complex' ) ]; - package: 'Math-Tests-Distributions' with: [ spec requires: #( 'Math-Distributions' ) ]; - package: 'Math-Tests-Core-Process' with: [ spec requires: #( 'Math-Core-Process' ) ]; - package: 'Math-Tests-Numerical' with: [ spec requires: #( 'Math-Numerical' 'Math-UtilsDataServer' ) ]; - package: 'Math-Tests-FastFourierTransform' with: [ spec requires: #( 'Math-FastFourierTransform' 'Math-Numerical' 'Math-Polynomials' ) ]; - package: 'Math-Tests-FunctionFit'; - package: 'Math-Tests-KDTree' with: [ spec requires: #( 'Math-KDTree' ) ]; - package: 'Math-Tests-Number-Extensions' with: [ spec requires: #( 'Math-Number-Extensions' ) ]; - package: 'Math-Tests-ODE' with: [ spec requires: #( 'Math-ODE' ) ]; - package: 'Math-Tests-Permutation' with: [ spec requires: #( 'Math-Permutation' ) ]; - package: 'Math-Tests-PrincipalComponentAnalysis' with: [ spec requires: #( 'Math-PrincipalComponentAnalysis' ) ]; - package: 'Math-Tests-Quantile' with: [ spec requires: #( 'Math-Quantile' ) ]; - package: 'Math-Tests-Polynomials' with: [ spec requires: #( 'Math-Polynomials' ) ]; - package: 'Math-Tests-Quaternion' with: [ spec requires: #( 'Math-Quaternion' ) ]; - package: 'Math-Tests-TSNE' with: [ spec requires: #( 'Math-TSNE' ) ]; - package: 'Math-UtilsDataServer'. - spec - group: 'Accuracy' with: #( 'Math-Accuracy-ODE' 'Math-Accuracy-Core' ); - group: 'Benchmarks' with: #( 'Math-Benchmarks-ODE' 'Math-Benchmarks-KDTree' ); - group: 'Core' - with: - #( 'Math-Complex' 'Math-Quaternion' 'Math-Numerical' 'MathRandomNumbers' 'Math-KDTree' 'Math-ODE' 'Math-ArbitraryPrecisionFloat' - 'Math-FastFourierTransform' 'ExtendedNumberParser' 'Math-Quantile' 'Math-Physics-Constants' 'Math-Polynomials' 'Math-TSNE' 'Math-Core-Process' - 'Math-Helpers' 'MathVectorMatrix' 'Math-Distributions' ); - group: 'Extensions' - with: #( 'Math-Clustering' 'Math-Number-Extensions' 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' 'Math-FunctionFit' 'Math-AutomaticDifferenciation' - 'Math-Permutation' ); - group: 'Tests' - with: - #( 'Math-Tests-Clustering' 'Math-Tests-Numerical' 'Math-Tests-Complex' 'Math-Tests-Quaternion' 'Math-Tests-ODE' 'Math-Tests-KDTree' 'Math-Tests-FunctionFit' - 'Math-Tests-AutomaticDifferenciation' 'Math-Tests-FastFourierTransform' 'Math-Tests-Accuracy' 'Math-Tests-ArbitraryPrecisionFloat' - 'Math-Tests-Quantile' 'Math-Tests-Polynomials' 'Math-Tests-PrincipalComponentAnalysis' 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' - 'Math-Tests-TSNE' 'Math-Tests-Core-Process' 'Math-Tests-Distributions' ); - group: 'default' with: #( 'Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy' ) ]. + self + packages: spec; + groups: spec ]. spec for: #( #'pharo6.x' #'pharo7.x' #'pharo8.x' #'pharo9.x' #'pharo10.x' ) do: [ spec @@ -107,32 +41,195 @@ BaselineOfPolyMath >> baseline: spec [ package: 'Math-CompatibilityUpToPharo11' ] ] -{ #category : #accessing } +{ #category : 'dependencies' } +BaselineOfPolyMath >> dataFrameInspector: spec [ + + spec + baseline: 'AIDataInspector' + with: [ spec repository: 'github://pharo-ai/data-inspector/src' ] +] + +{ #category : 'dependencies' } +BaselineOfPolyMath >> datasets: spec [ + + spec + baseline: 'AIDatasets' + with: [ spec repository: 'github://pharo-ai/datasets' ]. +] + +{ #category : 'baselines' } +BaselineOfPolyMath >> groups: spec [ + + spec + group: 'Accuracy' + with: #( 'Math-Accuracy-ODE' 'Math-Accuracy-Core' ); + group: 'Benchmarks' + with: #( 'Math-Benchmarks-ODE' 'Math-Benchmarks-KDTree' ); + group: 'Core' + with: + #( 'Math-Complex' 'Math-Quaternion' 'Math-Numerical' + 'MathRandomNumbers' 'Math-KDTree' 'Math-ODE' 'Math-ArbitraryPrecisionFloat' + 'Math-FastFourierTransform' 'ExtendedNumberParser' + 'Math-Quantile' 'Math-Physics-Constants' + 'Math-Polynomials' 'Math-TSNE' 'Math-Core-Process' + 'Math-Helpers' 'MathVectorMatrix' 'Math-Distributions' ); + group: 'Extensions' + with: + #( 'Math-Clustering' 'Math-Number-Extensions' + 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' + 'Math-FunctionFit' 'Math-AutomaticDifferenciation' + 'Math-Permutation' ); + group: 'Tests' + with: #( 'Math-Tests-Clustering' 'Math-Tests-Numerical' + 'Math-Tests-Complex' 'Math-Tests-Quaternion' + 'Math-Tests-ODE' 'Math-Tests-KDTree' 'Math-Tests-FunctionFit' + 'Math-Tests-AutomaticDifferenciation' + 'Math-Tests-FastFourierTransform' + 'Math-Tests-Accuracy' 'Math-Tests-ArbitraryPrecisionFloat' + 'Math-Tests-Quantile' 'Math-Tests-Polynomials' + 'Math-Tests-PrincipalComponentAnalysis' + 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' + 'Math-Tests-TSNE' 'Math-Tests-Core-Process' + 'Math-Tests-Distributions' ); + group: 'visualizations' + with: + #( 'Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy' 'Math-Visualizations' ); + group: 'default' + with: #( 'Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy' ) +] + +{ #category : 'baselines' } +BaselineOfPolyMath >> packages: spec [ + + spec + package: 'ExtendedNumberParser'; + package: 'Math-Accuracy-Core'; + package: 'Math-Accuracy-ODE' + with: [ spec requires: #( 'Math-ODE' 'XMLWriter' ) ]; + package: 'Math-ArbitraryPrecisionFloat' + with: [ spec requires: #( 'ExtendedNumberParser' ) ]; + package: 'Math-AutomaticDifferenciation' + with: [ spec requires: #( 'Math-Numerical' 'MathVectorMatrix' ) ]; + package: 'Math-Benchmarks-KDTree' + with: [ spec requires: #( 'Math-KDTree' 'SMark' ) ]; + package: 'Math-Benchmarks-ODE' + with: [ spec requires: #( 'Math-ODE' 'SMark' 'XMLWriter' ) ]; + package: 'Math-Chromosome' + with: [ spec requires: #( 'MathVectorMatrix' ) ]; + package: 'Math-Clustering' with: [ + spec requires: + #( 'Math-Numerical' 'Math-Core-Process' 'MathVectorMatrix' ) ]; + package: 'Math-Complex' + with: [ spec requires: #( 'Math-Numerical' 'Math-Polynomials' ) ]; + package: 'Math-Helpers'; + package: 'Math-Distributions' with: [ + spec requires: + #( 'MathVectorMatrix' 'Math-Quantile' 'Math-Core-Process' ) ]; + package: 'Math-Core-Process'; + package: 'Math-Numerical' with: [ + spec requires: + #( 'MathVectorMatrix' 'Math-Core-Process' 'Math-Distributions' + 'Math-StatisticalMoments' 'Math-Series' ) ]; + package: 'Math-Polynomials' with: [ + spec requires: + #( 'MathVectorMatrix' 'Math-Core-Process' 'Math-Distributions' + 'Math-StatisticalMoments' 'Math-Series' ) ]; + package: 'Math-FastFourierTransform' + with: [ spec requires: #( 'Math-Complex' ) ]; + package: 'Math-FunctionFit' with: [ + spec requires: + #( 'Math-Numerical' 'Math-Chromosome' 'Math-Accuracy-Core' + 'MathVectorMatrix' 'Math-Helpers' 'Math-Polynomials' ) ]; + package: 'Math-KDTree'; + package: 'Math-Number-Extensions'; + package: 'Math-ODE' with: [ + spec requires: + #( 'Math-Numerical' 'MathVectorMatrix' 'Math-Polynomials' ) ]; + package: 'Math-Permutation' + with: [ spec requires: #( 'MathVectorMatrix' 'Math-Core-Process' ) ]; + package: 'Math-Physics-Constants'; + package: 'Math-PrincipalComponentAnalysis' with: [ + spec requires: + #( 'Math-Numerical' 'MathVectorMatrix' 'Math-Polynomials' ) ]; + package: 'Math-Quantile'; + package: 'Math-Quaternion' with: [ + spec requires: + #( 'Math-Complex' 'Math-Numerical' 'Math-Polynomials' ) ]; + package: 'Math-Series'; + package: 'Math-StatisticalMoments' + with: [ spec requires: #( 'Math-Helpers' 'Math-Distributions' ) ]; + package: 'Math-TSNE'; + package: 'Math-Tests-Accuracy' + with: [ spec requires: #( 'Math-Accuracy-Core' ) ]; + package: 'Math-Tests-ArbitraryPrecisionFloat' + with: [ spec requires: #( 'Math-ArbitraryPrecisionFloat' ) ]; + package: 'Math-Tests-AutomaticDifferenciation' with: [ + spec requires: + #( 'Math-AutomaticDifferenciation' + 'MathVectorMatrix' ) ]; + package: 'Math-Tests-Clustering' with: [ + spec requires: + #( 'Math-Clustering' 'Math-Distributions' 'Math-UtilsDataServer' ) ]; + package: 'Math-Tests-Complex' + with: [ spec requires: #( 'Math-Complex' ) ]; + package: 'Math-Tests-Distributions' + with: [ spec requires: #( 'Math-Distributions' ) ]; + package: 'Math-Tests-Core-Process' + with: [ spec requires: #( 'Math-Core-Process' ) ]; + package: 'Math-Tests-Numerical' + with: [ spec requires: #( 'Math-Numerical' 'Math-UtilsDataServer' ) ]; + package: 'Math-Tests-FastFourierTransform' with: [ + spec requires: + #( 'Math-FastFourierTransform' 'Math-Numerical' 'Math-Polynomials' ) ]; + package: 'Math-Tests-FunctionFit'; + package: 'Math-Tests-KDTree' + with: [ spec requires: #( 'Math-KDTree' ) ]; + package: 'Math-Tests-Number-Extensions' + with: [ spec requires: #( 'Math-Number-Extensions' ) ]; + package: 'Math-Tests-ODE' with: [ spec requires: #( 'Math-ODE' ) ]; + package: 'Math-Tests-Permutation' + with: [ spec requires: #( 'Math-Permutation' ) ]; + package: 'Math-Tests-PrincipalComponentAnalysis' + with: [ spec requires: #( 'Math-PrincipalComponentAnalysis' ) ]; + package: 'Math-Tests-Quantile' + with: [ spec requires: #( 'Math-Quantile' ) ]; + package: 'Math-Tests-Polynomials' + with: [ spec requires: #( 'Math-Polynomials' ) ]; + package: 'Math-Tests-Quaternion' + with: [ spec requires: #( 'Math-Quaternion' ) ]; + package: 'Math-Tests-TSNE' + with: [ spec requires: #( 'Math-TSNE' ) ]; + package: 'Math-UtilsDataServer'; + package: 'Math-Visualizations' + with: [ spec requires: #( 'Roassal' 'AIDatasets' 'AIDataInspector') ] +] + +{ #category : 'accessing' } BaselineOfPolyMath >> projectClass [ ^ [ self class environment at: #MetacelloCypressBaselineProject ] on: NotFound do: [ super projectClass ] ] -{ #category : #dependencies } +{ #category : 'dependencies' } BaselineOfPolyMath >> randomNumbers: spec [ spec baseline: 'MathRandomNumbers' with: [ spec repository: 'github://PolyMathOrg/random-numbers:v1.x.x/src' ] ] -{ #category : #dependencies } +{ #category : 'dependencies' } BaselineOfPolyMath >> sMark: spec [ spec baseline: 'SMark' with: [ spec repository: 'github://smarr/SMark:v1.0.4' ] ] -{ #category : #dependencies } +{ #category : 'dependencies' } BaselineOfPolyMath >> vectorMatrix: spec [ spec baseline: 'MathVectorMatrix' with: [ spec repository: 'github://PolyMathOrg/vector-matrix:v1.x.x/src' ] ] -{ #category : #dependencies } +{ #category : 'dependencies' } BaselineOfPolyMath >> xmlWriter: spec [ spec baseline: 'XMLWriter' with: [ spec repository: 'github://pharo-contributions/XML-XMLWriter:2.9.x/src' ] diff --git a/src/BaselineOfPolyMath/package.st b/src/BaselineOfPolyMath/package.st index c3d8b930..0d2ce2ab 100644 --- a/src/BaselineOfPolyMath/package.st +++ b/src/BaselineOfPolyMath/package.st @@ -1 +1 @@ -Package { #name : #BaselineOfPolyMath } +Package { #name : 'BaselineOfPolyMath' } diff --git a/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st index 90d715c7..56654531 100644 --- a/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st @@ -3,22 +3,23 @@ PMDataTransformer is the abstract root class of transformers. All data transform " Class { - #name : #PMDataTransformer, - #superclass : #Object, - #category : #'Math-PrincipalComponentAnalysis' + #name : 'PMDataTransformer', + #superclass : 'Object', + #category : 'Math-PrincipalComponentAnalysis', + #package : 'Math-PrincipalComponentAnalysis' } -{ #category : #accessing } +{ #category : 'accessing' } PMDataTransformer >> fit: aPMMatrix [ ^ self subclassResponsibility ] -{ #category : #accessing } +{ #category : 'accessing' } PMDataTransformer >> fitAndTransform: aPMMatrix [ ^ (self fit: aPMMatrix) transform: aPMMatrix ] -{ #category : #transforming } +{ #category : 'transforming' } PMDataTransformer >> transform: aPMMatrix [ ^ self subclassResponsibility ] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st index 591c1771..12cb528b 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st @@ -1,33 +1,34 @@ Class { - #name : #PMPrincipalComponentAnalyser, - #superclass : #Object, + #name : 'PMPrincipalComponentAnalyser', + #superclass : 'Object', #instVars : [ 'componentsNumber' ], - #category : #'Math-PrincipalComponentAnalysis' + #category : 'Math-PrincipalComponentAnalysis', + #package : 'Math-PrincipalComponentAnalysis' } -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyser >> componentsNumber [ ^ componentsNumber ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyser >> componentsNumber: anInteger [ componentsNumber := anInteger ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyser >> fit: aPMMatrix [ ^ self subclassResponsibility ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyser >> fitAndTransform: aPMMatrix [ ^ (self fit: aPMMatrix) transform: aPMMatrix ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyser >> transform: aPMMatrix [ ^ self subclassResponsibility ] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st index aa699459..54002e12 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st @@ -8,53 +8,54 @@ Clients should first " Class { - #name : #PMPrincipalComponentAnalyserJacobiTransformation, - #superclass : #PMPrincipalComponentAnalyser, + #name : 'PMPrincipalComponentAnalyserJacobiTransformation', + #superclass : 'PMPrincipalComponentAnalyser', #instVars : [ 'accumulatorForCovarianceMatrix', 'jacobiTransform' ], - #category : #'Math-PrincipalComponentAnalysis' + #category : 'Math-PrincipalComponentAnalysis', + #package : 'Math-PrincipalComponentAnalysis' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } PMPrincipalComponentAnalyserJacobiTransformation class >> new: anInteger [ "anInteger is the size of the elements you will accumulate: the elements you want to compare using the component analysis." ^ self basicNew initialize: anInteger; yourself ] -{ #category : #transformation } +{ #category : 'transformation' } PMPrincipalComponentAnalyserJacobiTransformation >> accumulate: aPMVectorOrArray [ accumulatorForCovarianceMatrix accumulate: aPMVectorOrArray ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserJacobiTransformation >> components [ "Precondition: accumulate: should have been used." ^ self jacobiTransform evaluate copyFrom: 1 to: componentsNumber ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserJacobiTransformation >> fit: aPMMatrix [ accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: aPMMatrix numberOfColumns. aPMMatrix rowsDo: [ :eachRow | self accumulate: eachRow ]. self components ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserJacobiTransformation >> jacobiTransform [ ^ jacobiTransform ifNil: [ jacobiTransform := PMJacobiTransformation matrix: accumulatorForCovarianceMatrix covarianceMatrix ] ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserJacobiTransformation >> transform: aPMMatrix [ "Apply dimensionality reduction to aPMMatrix" ^ aPMMatrix * self transformMatrix transpose ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserJacobiTransformation >> transformMatrix [ "Return a matrix that can be applied to any data vector to extract the relevant component of the data vector" diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 1f0d1f11..301e9d27 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -1,15 +1,16 @@ Class { - #name : #PMPrincipalComponentAnalyserSVD, - #superclass : #PMPrincipalComponentAnalyser, + #name : 'PMPrincipalComponentAnalyserSVD', + #superclass : 'PMPrincipalComponentAnalyser', #instVars : [ 'svd', 'u', 'v' ], - #category : #'Math-PrincipalComponentAnalysis' + #category : 'Math-PrincipalComponentAnalysis', + #package : 'Math-PrincipalComponentAnalysis' } -{ #category : #examples } +{ #category : 'examples' } PMPrincipalComponentAnalyserSVD class >> example1 [ "Extract 4 columns from original data" @@ -37,7 +38,7 @@ PMPrincipalComponentAnalyserSVD class >> example1 [ addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first named: 'type'. - roassalChart := RSChart new + roassalChart := RSCompositeChart new title: 'PCA of Iris Data Frame'; addDecoration: (RSHorizontalTick new doNotUseNiceLabel asFloat: 3); addDecoration: RSVerticalTick new; @@ -58,7 +59,7 @@ PMPrincipalComponentAnalyserSVD class >> example1 [ ] -{ #category : #examples } +{ #category : 'examples' } PMPrincipalComponentAnalyserSVD class >> example2 [ "Extract 4 columns from original data. This example uses Random colors for each flower type" @@ -91,7 +92,7 @@ PMPrincipalComponentAnalyserSVD class >> example2 [ forColumn: 'type'. ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [ svd := aPMMatrix decomposeSV. @@ -100,7 +101,7 @@ PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [ self flipEigenvectorsSign ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserSVD >> flipEigenvectorsSign [ "flip eigenvectors sign to enforce deterministic output" "U-based decision like : https://github.com/scikit-learn/scikit-learn/blob/4c65d8e615c9331d37cbb6225c5b67c445a5c959/sklearn/utils/extmath.py#L609" @@ -112,14 +113,14 @@ PMPrincipalComponentAnalyserSVD >> flipEigenvectorsSign [ v := algo vFlipped . ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserSVD >> transform: aPMMatrix [ "Apply dimensionality reduction to aPMMatrix" ^ aPMMatrix * self transformMatrix transpose ] -{ #category : #accessing } +{ #category : 'accessing' } PMPrincipalComponentAnalyserSVD >> transformMatrix [ "Return a matrix that can be applied to any data vector to extract the relevant component of the data vector" diff --git a/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st index b442cd5e..c1436bd2 100644 --- a/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st @@ -6,24 +6,25 @@ This class uses the SciKit-Learn SVD flip algorithm to ensure the signs of the e " Class { - #name : #PMSciKitLearnSVDFlipAlgorithm, - #superclass : #Object, + #name : 'PMSciKitLearnSVDFlipAlgorithm', + #superclass : 'Object', #instVars : [ 'u', 'v', 'signs' ], - #category : #'Math-PrincipalComponentAnalysis' + #category : 'Math-PrincipalComponentAnalysis', + #package : 'Math-PrincipalComponentAnalysis' } -{ #category : #'instance creation' } +{ #category : 'instance creation' } PMSciKitLearnSVDFlipAlgorithm class >> flipU: u andV: v [ ^ self new initializeWithU: u andV: v; yourself ] -{ #category : #accessing } +{ #category : 'accessing' } PMSciKitLearnSVDFlipAlgorithm >> computeSignsFromU [ | maxAbsCols i maxElements | maxAbsCols := u abs argMaxOnColumns. @@ -35,7 +36,7 @@ PMSciKitLearnSVDFlipAlgorithm >> computeSignsFromU [ ^ maxElements sign asPMVector ] -{ #category : #initialization } +{ #category : 'initialization' } PMSciKitLearnSVDFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ "instantiate the algorithm" u := uMatrix . @@ -43,7 +44,7 @@ PMSciKitLearnSVDFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ signs := self computeSignsFromU ] -{ #category : #accessing } +{ #category : 'accessing' } PMSciKitLearnSVDFlipAlgorithm >> signMatrixForU [ ^ PMMatrix rows: @@ -55,7 +56,7 @@ PMSciKitLearnSVDFlipAlgorithm >> signMatrixForU [ yourself ]) ] -{ #category : #accessing } +{ #category : 'accessing' } PMSciKitLearnSVDFlipAlgorithm >> signMatrixForV [ | signsForV | signsForV := self signs copyFrom: 1 to: v numberOfColumns. @@ -69,17 +70,17 @@ PMSciKitLearnSVDFlipAlgorithm >> signMatrixForV [ yourself ])) transpose ] -{ #category : #accessing } +{ #category : 'accessing' } PMSciKitLearnSVDFlipAlgorithm >> signs [ ^ signs ] -{ #category : #accessing } +{ #category : 'accessing' } PMSciKitLearnSVDFlipAlgorithm >> uFlipped [ ^ u hadamardProduct: (self signMatrixForU) ] -{ #category : #accessing } +{ #category : 'accessing' } PMSciKitLearnSVDFlipAlgorithm >> vFlipped [ ^ v hadamardProduct: (self signMatrixForV) ] diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index e4619c71..9f9ea96f 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -1,13 +1,14 @@ Class { - #name : #PMStandardizationScaler, - #superclass : #PMDataTransformer, + #name : 'PMStandardizationScaler', + #superclass : 'PMDataTransformer', #instVars : [ 'accumulator' ], - #category : #'Math-PrincipalComponentAnalysis' + #category : 'Math-PrincipalComponentAnalysis', + #package : 'Math-PrincipalComponentAnalysis' } -{ #category : #accessing } +{ #category : 'accessing' } PMStandardizationScaler >> fit: aPMMatrix [ "Compute the mean and the scale of a PMMatrix (in order to have a std of 1)" @@ -15,12 +16,12 @@ PMStandardizationScaler >> fit: aPMMatrix [ aPMMatrix rowsDo: [ :each | accumulator accumulate: each ] ] -{ #category : #accessing } +{ #category : 'accessing' } PMStandardizationScaler >> mean [ ^ accumulator average ] -{ #category : #accessing } +{ #category : 'accessing' } PMStandardizationScaler >> scale [ ^ self variance collect: [ :element | | root | @@ -29,7 +30,7 @@ PMStandardizationScaler >> scale [ ] ] -{ #category : #transforming } +{ #category : 'transforming' } PMStandardizationScaler >> transform: aPMMatrix [ "Perform standardization by centering and scaling" @@ -39,7 +40,7 @@ PMStandardizationScaler >> transform: aPMMatrix [ ^ PMMatrix rows: ((PMMatrix rows: (aPMMatrix rowsCollect: [ :each | each - mean ])) rowsCollect: [ :each| each / scale]) ] -{ #category : #information } +{ #category : 'information' } PMStandardizationScaler >> variance [ "Return the diagonal of the covarianceMatrix" diff --git a/src/Math-PrincipalComponentAnalysis/package.st b/src/Math-PrincipalComponentAnalysis/package.st index d6d1052e..84a57df6 100644 --- a/src/Math-PrincipalComponentAnalysis/package.st +++ b/src/Math-PrincipalComponentAnalysis/package.st @@ -1 +1 @@ -Package { #name : #'Math-PrincipalComponentAnalysis' } +Package { #name : 'Math-PrincipalComponentAnalysis' } From 1cd367a0f106ef5390404ca75f976aa38fc1aafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Wed, 27 Dec 2023 15:58:38 +0100 Subject: [PATCH 3/8] Add missing baseline reference to Roassal --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index d47e3c05..bf8269b3 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -27,6 +27,7 @@ BaselineOfPolyMath >> baseline: spec [ vectorMatrix: spec; randomNumbers: spec; datasets: spec; + roassal: spec; dataFrameInspector: spec. self @@ -217,6 +218,14 @@ BaselineOfPolyMath >> randomNumbers: spec [ spec baseline: 'MathRandomNumbers' with: [ spec repository: 'github://PolyMathOrg/random-numbers:v1.x.x/src' ] ] +{ #category : 'dependencies' } +BaselineOfPolyMath >> roassal: spec [ + + spec + baseline: 'Roassal' + with: [ spec repository: 'github://pharo-graphics/Roassal' ]. +] + { #category : 'dependencies' } BaselineOfPolyMath >> sMark: spec [ From f6ffd1918f5ab66dee2d19c891cb346e3a874b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Wed, 27 Dec 2023 16:03:51 +0100 Subject: [PATCH 4/8] Repackage methods --- .../PMPrincipalComponentAnalyserSVD.class.st | 82 ------------------ ...PrincipalComponentAnalyserSVD.extension.st | 83 +++++++++++++++++++ src/Math-Visualizations/package.st | 1 + 3 files changed, 84 insertions(+), 82 deletions(-) create mode 100644 src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st create mode 100644 src/Math-Visualizations/package.st diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 301e9d27..f613984c 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -10,88 +10,6 @@ Class { #package : 'Math-PrincipalComponentAnalysis' } -{ #category : 'examples' } -PMPrincipalComponentAnalyserSVD class >> example1 [ - "Extract 4 columns from original data" - - | d m pca m1 d1 irisDataFrame roassalChart scatterPlotShapes | - - irisDataFrame := AIDatasets loadIris. - d := irisDataFrame columnsFrom: 1 to: 4. - - "Transform DF as matrix" - m := PMMatrix rows: d asArrayOfRows. - - "Data standardization (mean = 0 and variance = 1)" - m := PMStandardizationScaler new fitAndTransform: m. - - "Compute PCA components" - pca := PMPrincipalComponentAnalyserSVD new. - pca componentsNumber: 2. - pca fit: m. - pca transformMatrix. - - m1 := pca transform: m. - - d1 := DataFrame withRows: m1 rows. - d1 - addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first - named: 'type'. - - roassalChart := RSCompositeChart new - title: 'PCA of Iris Data Frame'; - addDecoration: (RSHorizontalTick new doNotUseNiceLabel asFloat: 3); - addDecoration: RSVerticalTick new; - yourself. - - scatterPlotShapes := (d1 column: 'type') asSet collect: [ : type | - (d1 select: [ : e | e values includes: type ]) - addScatterPlotShapeToChart: roassalChart ]. - - roassalChart padding: 10. - scatterPlotShapes asOrderedCollection - with: { Color red . Color green . Color blue } - do: [ : scatterPlotShape : scatterPlotDotColor | - scatterPlotShape color: scatterPlotDotColor ]. - - roassalChart open. - - -] - -{ #category : 'examples' } -PMPrincipalComponentAnalyserSVD class >> example2 [ - "Extract 4 columns from original data. This example uses Random colors for each flower type" - - | d m pca m1 d1 irisDataFrame | - - irisDataFrame := AIDatasets loadIris. - d := irisDataFrame columnsFrom: 1 to: 4. - - "Transform DF as matrix" - m := PMMatrix rows: d asArrayOfRows. - - "Data standardization (mean = 0 and variance = 1)" - m := PMStandardizationScaler new fitAndTransform: m. - - "Compute PCA components" - pca := PMPrincipalComponentAnalyserSVD new. - pca componentsNumber: 2. - pca fit: m. - pca transformMatrix. - - m1 := pca transform: m. - - d1 := DataFrame withRows: m1 rows. - d1 - addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first - named: 'type'. - - d1 - openScatterPlotWithTitle: 'PCA of Iris data set' - forColumn: 'type'. -] - { #category : 'accessing' } PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [ diff --git a/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st b/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st new file mode 100644 index 00000000..297b0c30 --- /dev/null +++ b/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st @@ -0,0 +1,83 @@ +Extension { #name : 'PMPrincipalComponentAnalyserSVD' } + +{ #category : '*Math-Visualizations' } +PMPrincipalComponentAnalyserSVD class >> example1 [ + "Extract 4 columns from original data" + + | d m pca m1 d1 irisDataFrame roassalChart scatterPlotShapes | + + irisDataFrame := AIDatasets loadIris. + d := irisDataFrame columnsFrom: 1 to: 4. + + "Transform DF as matrix" + m := PMMatrix rows: d asArrayOfRows. + + "Data standardization (mean = 0 and variance = 1)" + m := PMStandardizationScaler new fitAndTransform: m. + + "Compute PCA components" + pca := PMPrincipalComponentAnalyserSVD new. + pca componentsNumber: 2. + pca fit: m. + pca transformMatrix. + + m1 := pca transform: m. + + d1 := DataFrame withRows: m1 rows. + d1 + addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first + named: 'type'. + + roassalChart := RSCompositeChart new + title: 'PCA of Iris Data Frame'; + addDecoration: (RSHorizontalTick new doNotUseNiceLabel asFloat: 3); + addDecoration: RSVerticalTick new; + yourself. + + scatterPlotShapes := (d1 column: 'type') asSet collect: [ : type | + (d1 select: [ : e | e values includes: type ]) + addScatterPlotShapeToChart: roassalChart ]. + + roassalChart padding: 10. + scatterPlotShapes asOrderedCollection + with: { Color red . Color green . Color blue } + do: [ : scatterPlotShape : scatterPlotDotColor | + scatterPlotShape color: scatterPlotDotColor ]. + + roassalChart open. + + +] + +{ #category : '*Math-Visualizations' } +PMPrincipalComponentAnalyserSVD class >> example2 [ + "Extract 4 columns from original data. This example uses Random colors for each flower type" + + | d m pca m1 d1 irisDataFrame | + + irisDataFrame := AIDatasets loadIris. + d := irisDataFrame columnsFrom: 1 to: 4. + + "Transform DF as matrix" + m := PMMatrix rows: d asArrayOfRows. + + "Data standardization (mean = 0 and variance = 1)" + m := PMStandardizationScaler new fitAndTransform: m. + + "Compute PCA components" + pca := PMPrincipalComponentAnalyserSVD new. + pca componentsNumber: 2. + pca fit: m. + pca transformMatrix. + + m1 := pca transform: m. + + d1 := DataFrame withRows: m1 rows. + d1 + addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first + named: 'type'. + + d1 + openScatterPlotWithTitle: 'PCA of Iris data set' + forColumn: 'type'. +] diff --git a/src/Math-Visualizations/package.st b/src/Math-Visualizations/package.st new file mode 100644 index 00000000..d4aa197f --- /dev/null +++ b/src/Math-Visualizations/package.st @@ -0,0 +1 @@ +Package { #name : 'Math-Visualizations' } From c044efce054c556f160bbf31c72790c09e961986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Thu, 28 Dec 2023 19:34:51 +0100 Subject: [PATCH 5/8] Remove Roassal reference in Baseline --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index bf8269b3..d1b332db 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -202,7 +202,7 @@ BaselineOfPolyMath >> packages: spec [ with: [ spec requires: #( 'Math-TSNE' ) ]; package: 'Math-UtilsDataServer'; package: 'Math-Visualizations' - with: [ spec requires: #( 'Roassal' 'AIDatasets' 'AIDataInspector') ] + with: [ spec requires: #( 'AIDatasets' 'AIDataInspector') ] ] { #category : 'accessing' } From bb48d99a3b0563850ac9d744aca8cb2b2ccbb571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Thu, 28 Dec 2023 19:41:09 +0100 Subject: [PATCH 6/8] AIDataInspector -> AIDataFrameInspector --- .../BaselineOfPolyMath.class.st | 31 +++++++++---------- src/BaselineOfPolyMath/package.st | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index d1b332db..b57fb0ab 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -10,13 +10,12 @@ PolyMath is a Smalltalk project, similar to existing scientific libraries like N " Class { - #name : 'BaselineOfPolyMath', - #superclass : 'BaselineOf', - #category : 'BaselineOfPolyMath', - #package : 'BaselineOfPolyMath' + #name : #BaselineOfPolyMath, + #superclass : #BaselineOf, + #category : #BaselineOfPolyMath } -{ #category : 'baselines' } +{ #category : #baselines } BaselineOfPolyMath >> baseline: spec [ @@ -42,15 +41,15 @@ BaselineOfPolyMath >> baseline: spec [ package: 'Math-CompatibilityUpToPharo11' ] ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> dataFrameInspector: spec [ spec - baseline: 'AIDataInspector' + baseline: 'AIDataFrameInspector' with: [ spec repository: 'github://pharo-ai/data-inspector/src' ] ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> datasets: spec [ spec @@ -58,7 +57,7 @@ BaselineOfPolyMath >> datasets: spec [ with: [ spec repository: 'github://pharo-ai/datasets' ]. ] -{ #category : 'baselines' } +{ #category : #baselines } BaselineOfPolyMath >> groups: spec [ spec @@ -99,7 +98,7 @@ BaselineOfPolyMath >> groups: spec [ with: #( 'Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy' ) ] -{ #category : 'baselines' } +{ #category : #baselines } BaselineOfPolyMath >> packages: spec [ spec @@ -205,20 +204,20 @@ BaselineOfPolyMath >> packages: spec [ with: [ spec requires: #( 'AIDatasets' 'AIDataInspector') ] ] -{ #category : 'accessing' } +{ #category : #accessing } BaselineOfPolyMath >> projectClass [ ^ [ self class environment at: #MetacelloCypressBaselineProject ] on: NotFound do: [ super projectClass ] ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> randomNumbers: spec [ spec baseline: 'MathRandomNumbers' with: [ spec repository: 'github://PolyMathOrg/random-numbers:v1.x.x/src' ] ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> roassal: spec [ spec @@ -226,19 +225,19 @@ BaselineOfPolyMath >> roassal: spec [ with: [ spec repository: 'github://pharo-graphics/Roassal' ]. ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> sMark: spec [ spec baseline: 'SMark' with: [ spec repository: 'github://smarr/SMark:v1.0.4' ] ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> vectorMatrix: spec [ spec baseline: 'MathVectorMatrix' with: [ spec repository: 'github://PolyMathOrg/vector-matrix:v1.x.x/src' ] ] -{ #category : 'dependencies' } +{ #category : #dependencies } BaselineOfPolyMath >> xmlWriter: spec [ spec baseline: 'XMLWriter' with: [ spec repository: 'github://pharo-contributions/XML-XMLWriter:2.9.x/src' ] diff --git a/src/BaselineOfPolyMath/package.st b/src/BaselineOfPolyMath/package.st index 0d2ce2ab..c3d8b930 100644 --- a/src/BaselineOfPolyMath/package.st +++ b/src/BaselineOfPolyMath/package.st @@ -1 +1 @@ -Package { #name : 'BaselineOfPolyMath' } +Package { #name : #BaselineOfPolyMath } From cb9a018975f79360556d58b0dfb09da286b77dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Thu, 28 Dec 2023 19:43:04 +0100 Subject: [PATCH 7/8] Fix another reference: AIDataInspector -> AIDataFrameInspector --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index b57fb0ab..2dfe9ce7 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -201,7 +201,7 @@ BaselineOfPolyMath >> packages: spec [ with: [ spec requires: #( 'Math-TSNE' ) ]; package: 'Math-UtilsDataServer'; package: 'Math-Visualizations' - with: [ spec requires: #( 'AIDatasets' 'AIDataInspector') ] + with: [ spec requires: #( 'AIDatasets' 'AIDataFrameInspector') ] ] { #category : #accessing } From 2c845546501bb64da6589ca5fe4245ca1a5e3056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A1n=20Morales=20Durand?= Date: Thu, 28 Dec 2023 19:48:32 +0100 Subject: [PATCH 8/8] Add compatibility method because Roassal chart class name changes between different Pharo versions --- ...PMPrincipalComponentAnalyserSVD.extension.st | 17 +++++++++++++---- src/Math-Visualizations/package.st | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st b/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st index 297b0c30..ac79699f 100644 --- a/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st +++ b/src/Math-Visualizations/PMPrincipalComponentAnalyserSVD.extension.st @@ -1,6 +1,6 @@ -Extension { #name : 'PMPrincipalComponentAnalyserSVD' } +Extension { #name : #PMPrincipalComponentAnalyserSVD } -{ #category : '*Math-Visualizations' } +{ #category : #'*Math-Visualizations' } PMPrincipalComponentAnalyserSVD class >> example1 [ "Extract 4 columns from original data" @@ -28,7 +28,7 @@ PMPrincipalComponentAnalyserSVD class >> example1 [ addColumn: (irisDataFrame columnsFrom: 5 to: 5) asArrayOfColumns first named: 'type'. - roassalChart := RSCompositeChart new + roassalChart := self roassalChartClass new title: 'PCA of Iris Data Frame'; addDecoration: (RSHorizontalTick new doNotUseNiceLabel asFloat: 3); addDecoration: RSVerticalTick new; @@ -49,7 +49,7 @@ PMPrincipalComponentAnalyserSVD class >> example1 [ ] -{ #category : '*Math-Visualizations' } +{ #category : #'*Math-Visualizations' } PMPrincipalComponentAnalyserSVD class >> example2 [ "Extract 4 columns from original data. This example uses Random colors for each flower type" @@ -81,3 +81,12 @@ PMPrincipalComponentAnalyserSVD class >> example2 [ openScatterPlotWithTitle: 'PCA of Iris data set' forColumn: 'type'. ] + +{ #category : #'*Math-Visualizations' } +PMPrincipalComponentAnalyserSVD class >> roassalChartClass [ + + ^ SystemVersion current major < 12 + ifTrue: [ Smalltalk at: #RSChart ] + ifFalse: [ Smalltalk at: #RSCompositeChart ] + +] diff --git a/src/Math-Visualizations/package.st b/src/Math-Visualizations/package.st index d4aa197f..2b4afcd5 100644 --- a/src/Math-Visualizations/package.st +++ b/src/Math-Visualizations/package.st @@ -1 +1 @@ -Package { #name : 'Math-Visualizations' } +Package { #name : #'Math-Visualizations' }